public static function setUpBeforeClass()
 {
     parent::setUpBeforeClass();
     self::$application = \Stormpath\Resource\Application::instantiate(array('name' => 'Main App for the tests' . md5(time()), 'description' => 'Description of Main App', 'status' => 'enabled'));
     parent::createResource(\Stormpath\Resource\Application::PATH, self::$application, array('createDirectory' => true));
     self::$account = \Stormpath\Resource\Account::instantiate(array('givenName' => 'PHP', 'middleName' => 'BasicRequestAuthenticator', 'surname' => 'Test', 'username' => md5(time() . microtime() . uniqid()) . 'username', 'email' => md5(time() . microtime() . uniqid()) . '@unknown123.kot', 'password' => 'superP4ss'));
     self::$application->createAccount(self::$account);
 }
 protected static function init()
 {
     self::$application = \Stormpath\Resource\Application::instantiate(array('name' => 'Main App for the tests' . md5(time() . microtime() . uniqid()), 'description' => 'Description of Main App', 'status' => 'enabled'));
     self::createResource(\Stormpath\Resource\Application::PATH, self::$application, array('createDirectory' => true));
     self::$account = \Stormpath\Resource\Account::instantiate(array('givenName' => 'Account Name', 'middleName' => 'Middle Name', 'surname' => 'Surname', 'username' => md5(time() . microtime() . uniqid()) . 'username', 'email' => md5(time() . microtime() . uniqid()) . '@unknown123.kot', 'password' => 'superP4ss'));
     self::$application->createAccount(self::$account);
     self::$inited = true;
 }
 public static function setUpBeforeClass()
 {
     parent::setUpBeforeClass();
     self::$application = \Stormpath\Resource\Application::instantiate(array('name' => makeUniqueName('Application ApiRequestAuthenticatorTest'), 'description' => 'Application for ApiRequestAuthenticatorTest', 'status' => 'enabled'));
     parent::createResource(\Stormpath\Resource\Application::PATH, self::$application, array('createDirectory' => true));
     self::$account = \Stormpath\Resource\Account::instantiate(array('givenName' => 'PHP', 'middleName' => 'ApiRequestAuthenticatorTest', 'surname' => 'Test', 'username' => makeUniqueName('ApiRequestAuthenticatorTest'), 'email' => makeUniqueName('ApiRequestAuthenticatorTest') . '@unknown123.kot', 'password' => 'superP4ss'));
     self::$application->createAccount(self::$account);
     self::$apiKey = self::$account->createApiKey();
 }
 public static function setUpBeforeClass()
 {
     parent::setUpBeforeClass();
     self::$application = \Stormpath\Resource\Application::instantiate(array('name' => uniqid() . 'ApplicationTest', 'description' => 'Description of Main App', 'status' => 'enabled'));
     self::createResource(\Stormpath\Resource\Application::PATH, self::$application, array('createDirectory' => true));
     self::$account = \Stormpath\Resource\Account::instantiate(array('givenName' => 'Account Name', 'middleName' => 'Middle Name', 'surname' => 'Surname', 'username' => 'username' . uniqid(), 'email' => 'username' . uniqid() . '@unknown123.kot', 'password' => 'superP4ss'));
     self::$application->createAccount(self::$account);
     self::$provider = new \Stormpath\StormpathUserProvider(self::$client, self::$application);
 }
예제 #5
0
 public function testCreateApplication()
 {
     $tenant = self::$client->tenant;
     $application = \Stormpath\Resource\Application::instantiate(array('name' => makeUniqueName('TenantTest CreateApp')));
     $tenant->createApplication($application);
     $this->assertInstanceOf('\\Stormpath\\Resource\\Application', $application);
     $this->assertEquals($tenant->name, $application->tenant->name);
     $this->assertContains('CreateApp', $application->name);
     foreach ($tenant->applications as $app) {
         $this->assertInstanceOf('\\Stormpath\\Resource\\Application', $app);
     }
     $application->delete();
 }
예제 #6
0
 public function testCreateApplication()
 {
     $tenant = self::$client->tenant;
     $application = \Stormpath\Resource\Application::instantiate(array('name' => 'App for this test' . md5(time() . microtime() . uniqid())));
     $tenant->createApplication($application);
     $this->assertInstanceOf('\\Stormpath\\Resource\\Application', $application);
     $this->assertEquals($tenant->name, $application->tenant->name);
     $this->assertContains('App for this test', $application->name);
     foreach ($tenant->applications as $app) {
         $this->assertInstanceOf('\\Stormpath\\Resource\\Application', $app);
     }
     $application->delete();
 }
예제 #7
0
 /**
  * @expectedException \Stormpath\Resource\ResourceError
  * @expectedExceptionMessage The imported password designates an algorithm that is an unsupported value.
  */
 public function testImportingInvalidPasswordFormatTypeShouldThrowException()
 {
     $username = md5(time() . microtime() . uniqid()) . 'username';
     $client = Client::getInstance();
     self::$application = \Stormpath\Resource\Application::instantiate(array('name' => 'Main App for passwordImport' . md5(time() . microtime() . uniqid()), 'description' => 'Description of Main App', 'status' => 'enabled'));
     self::createResource(\Stormpath\Resource\Application::PATH, self::$application, array('createDirectory' => true));
     $account = $client->dataStore->instantiate(\Stormpath\Stormpath::ACCOUNT);
     $account->email = '*****@*****.**';
     $account->givenName = 'John';
     $account->password = '******';
     $account->surname = 'Smith';
     $account->username = $username;
     self::$application->createAccount($account, array('passwordFormat' => 'someOtherMCF'));
     $result = self::$application->authenticate($username, 'SomePassw0rd!');
     $this->assertEquals($username, $result->account->username);
     $account->delete();
 }
 public function testDelete()
 {
     $application = \Stormpath\Resource\Application::instantiate(array('name' => makeUniqueName('AccountStoreMappingTest Test Delete')));
     self::createResource(\Stormpath\Resource\Application::PATH, $application);
     $accountStoreMappingWithDir = \Stormpath\Resource\AccountStoreMapping::create(array('accountStore' => self::$directory, 'application' => $application));
     $href = $accountStoreMappingWithDir->href;
     $accountStoreMapping = \Stormpath\Resource\AccountStoreMapping::get($href);
     $this->assertInstanceOf('Stormpath\\Resource\\AccountStoreMapping', $accountStoreMapping);
     $this->assertInstanceOf('Stormpath\\Resource\\Directory', $accountStoreMapping->accountStore);
     $accountStoreMapping->delete();
     try {
         \Stormpath\Resource\AccountStoreMapping::get($href);
         $application->delete();
         $this->fail('Should have thrown a ResourceError.');
     } catch (\Stormpath\Resource\ResourceError $re) {
         $this->assertTrue(true);
     }
     $application->delete();
 }
 public function testCreate()
 {
     $application = \Stormpath\Resource\Application::create(array('name' => 'Another App' . md5(time() . microtime() . uniqid())));
     $this->assertInstanceOf('Stormpath\\Resource\\Application', $application);
     $this->assertContains('Another App', $application->name);
     // testing the creation from an application instance
     $application2 = \Stormpath\Resource\Application::instantiate(array('name' => 'Yet another App' . md5(time() . microtime() . uniqid())));
     \Stormpath\Resource\Application::create($application2);
     $this->assertInstanceOf('Stormpath\\Resource\\Application', $application2);
     $this->assertContains('Yet another App', $application2->name);
     $application->delete();
     $application2->delete();
 }
 /**
  * @test
  */
 public function it_can_add_an_account_store_mapping()
 {
     $application = \Stormpath\Resource\Application::instantiate(['name' => makeUniqueName('OrgTest'), 'description' => 'Description of Main App', 'status' => 'enabled']);
     $application = self::createResource(\Stormpath\Resource\Application::PATH, $application);
     $accountStoreMapping = \Stormpath\Resource\AccountStoreMapping::instantiate(['organization' => self::$organization, 'accountStore' => self::$directory, 'isDefaultAccountStore' => true, 'isDefaultGroupStore' => true]);
     $test1 = self::$organization->createOrganizationAccountStoreMapping($accountStoreMapping);
     $this->assertInstanceOf('\\Stormpath\\Resource\\AccountStoreMapping', $test1);
     $accountStoreMapping = \Stormpath\Resource\AccountStoreMapping::instantiate(['accountStore' => self::$organization, 'application' => $application, 'isDefaultAccountStore' => true]);
     $test2 = $application->createAccountStoreMapping($accountStoreMapping);
     $this->assertInstanceOf('\\Stormpath\\Resource\\AccountStoreMapping', $test2);
     $org = Organization::get(self::$organization->href);
     $this->assertNotNull($org->accountStoreMappings->href);
     $this->assertInstanceOf('Stormpath\\Resource\\AccountStore', $org->defaultAccountStoreMapping);
     $this->assertInstanceOf('Stormpath\\Resource\\AccountStore', $org->defaultGroupStoreMapping);
     $asm = $org->accountStoreMappings;
     foreach ($asm as $mapping) {
         $this->assertEquals($org->href, $mapping->organization->href);
         $this->assertEquals(self::$directory->href, $mapping->accountStore->href);
     }
     $app = Application::get($application->href);
     $this->assertNotNull($app->accountStoreMappings->href);
     $asm = $app->accountStoreMappings;
     foreach ($asm as $mapping) {
         $this->assertEquals($app->href, $mapping->application->href);
         $this->assertEquals(self::$organization->href, $mapping->accountStore->href);
     }
     $application->delete();
 }
 public function testCreate()
 {
     $application = \Stormpath\Resource\Application::create(array('name' => makeUniqueName('ApplicationTest testCreate')));
     $this->assertInstanceOf('Stormpath\\Resource\\Application', $application);
     $this->assertContains('testCreate', $application->name);
     // testing the creation from an application instance
     $application2 = \Stormpath\Resource\Application::instantiate(array('name' => makeUniqueName('ApplicationTest testCreate2')));
     \Stormpath\Resource\Application::create($application2);
     $this->assertInstanceOf('Stormpath\\Resource\\Application', $application2);
     $this->assertContains('testCreate2', $application2->name);
     $application->delete();
     $application2->delete();
 }
예제 #12
0
 public function setupStormpathApplication()
 {
     $this->application = \Stormpath\Resource\Application::instantiate(array('name' => 'Test Application  - ' . microtime(), 'description' => 'Description of Main App', 'status' => 'enabled'));
     self::createResource(\Stormpath\Resource\Application::PATH, $this->application, array('createDirectory' => true));
     config(['stormpath.application.href' => $this->application->href]);
 }
예제 #13
0
 public function testCanVerifySPToken()
 {
     $application = \Stormpath\Resource\Application::instantiate(array('name' => makeUniqueName('ApplicationTest'), 'description' => 'Description of Main App', 'status' => 'enabled'));
     self::createResource(\Stormpath\Resource\Application::PATH, $application, array('createDirectory' => true));
     $email = makeUniqueName('ApplicationTest SendPassword') . '@unknown123.kot';
     $account = \Stormpath\Resource\Account::instantiate(array('givenName' => 'Account Name', 'surname' => 'Surname', 'username' => 'super_unique_username', 'email' => $email, 'password' => 'superP4ss'));
     $thisAccount = $application->createAccount($account);
     $resetToken = $application->sendPasswordResetEmail($email, [], true);
     $this->assertInstanceOf('\\Stormpath\\Resource\\PasswordResetToken', $resetToken);
     list($junk, $token) = explode('passwordResetTokens/', $resetToken->href);
     $account = $application->verifyPasswordResetToken($token);
     $this->assertInstanceOf('\\Stormpath\\Resource\\Account', $account);
     $thisAccount->delete();
     $application->delete();
 }