Beispiel #1
0
 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)]]);
 }
 /**
  * Boot the provider.
  */
 public function boot()
 {
     KeyPair::registerEvents();
 }
 /**
  * Sets up the fixture, for example, open a network connection.
  * This method is called before a test is executed.
  */
 protected function setUp()
 {
     parent::setUp();
     KeyPair::registerEvents();
 }
 /**
  * Setup testing environment.
  */
 protected function setUp()
 {
     parent::setUp();
     $this->migrateAuthDatabase();
     KeyPair::registerEvents();
 }
 /**
  * Find a key pair by its public id.
  *
  * @param string $publicId
  * @param string $type
  *
  * @return KeyPair
  */
 public function byPublicId($publicId, $type)
 {
     return KeyPair::query()->where('public_id', $publicId)->where('type', $type)->firstOrFail();
 }