public function testJsonProperties() { $pair = new KeyPair(); $pair->public_id = 'wowowowow'; $pair->secret_key = 'omgomgomgomgomg'; $pair->type = 'testing'; $pair->data = ['name' => 'dolan']; $pair->save(); $pair2 = KeyPair::query()->where('public_id', 'wowowowow')->firstOrFail(); $this->assertEquals(['name' => 'dolan'], $pair2->data); }
public function testFindByPublicId() { $pair = new KeyPair(); $pair2 = new KeyPair(); $pair3 = new KeyPair(); $finder = new KeyPairFinder(); $pair->public_id = 'omg'; $pair->secret_key = 'wow'; $pair->type = KeyPairTypes::TYPE_GENERIC; $pair->save(); $pair2->public_id = 'omg'; $pair2->secret_key = 'dolan'; $pair2->type = KeyPairTypes::TYPE_HMAC; $pair2->save(); $pair3->public_id = 'omgs'; $pair3->secret_key = 'doges'; $pair3->type = KeyPairTypes::TYPE_HMAC; $pair3->save(); $fetchSecret = function ($id, $type) use($finder) { return $finder->byPublicId($id, $type)->secret_key; }; $this->assertEqualsMatrix([['wow', $fetchSecret('omg', KeyPairTypes::TYPE_GENERIC)], ['dolan', $fetchSecret('omg', KeyPairTypes::TYPE_HMAC)], ['doges', $fetchSecret('omgs', KeyPairTypes::TYPE_HMAC)]]); }