public function testGetFacebookProvider() { $clientId = makeUniqueName("mockClientId"); $clientSecret = makeUniqueName("mockClientSecret"); $provider = self::$client->dataStore->instantiate(\Stormpath\Stormpath::FACEBOOK_PROVIDER); $provider->clientId = $clientId; $provider->clientSecret = $clientSecret; $directoryName = makeUniqueName("my-facebook-directory-2"); $directoryDescription = makeUniqueName("A Facebook directory"); $directory = self::$client->dataStore->instantiate(\Stormpath\Stormpath::DIRECTORY); $directory->name = $directoryName; $directory->description = $directoryDescription; $directory->provider = $provider; $tenant = self::$client->getCurrentTenant(); $returnedDirectory = $tenant->createDirectory($directory); $this->assertNotNull($returnedDirectory); $returnedProvider = self::$client->dataStore->getResource($returnedDirectory->href . "/" . Provider::PATH, \Stormpath\Stormpath::FACEBOOK_PROVIDER); $this->assertEquals(FacebookProvider::FACEBOOK_PROVIDER_ID, $returnedProvider->providerId); $this->assertNotEmpty($returnedProvider->createdAt); $this->assertNotEmpty($returnedProvider->modifiedAt); $this->assertEquals($clientId, $returnedProvider->clientId); $this->assertEquals($clientSecret, $returnedProvider->clientSecret); $tokens = explode('/', $returnedDirectory->href); $directoryId = end($tokens); $this->assertEquals($returnedProvider, FacebookProvider::get($directoryId)); $this->assertEquals($returnedProvider, FacebookProvider::get($directoryId . '/' . Provider::PATH)); $this->assertEquals($returnedProvider, FacebookProvider::get(Directory::PATH . '/' . $directoryId . '/' . Provider::PATH)); $this->assertEquals($returnedProvider, FacebookProvider::get($returnedDirectory->href)); $this->assertEquals($returnedProvider, FacebookProvider::get($returnedDirectory->href . '/' . Provider::PATH)); $returnedDirectory->delete(); }
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::$samlProvider = \Stormpath\Resource\SamlProvider::instantiate(['ssoLoginUrl' => 'http://google.com/login', 'ssoLogoutUrl' => 'http://google.com/logout', 'encodedX509SigningCert' => self::getDummyCertForSaml(), 'requestSignatureAlgorithm' => 'RSA-SHA1']); self::$directory = \Stormpath\Resource\Directory::create(['name' => makeUniqueName('DirectoryTest samlProvider'), 'provider' => self::$samlProvider]); $parts = explode('/', self::$directory->href); self::$directoryId = end($parts); self::$metadata = SamlProvider::get(self::$directory->provider->href)->serviceProviderMetadata; }
public function testCreateDirectory() { $tenant = self::$client->tenant; $name = makeUniqueName('TenantTest createDirectory'); $directory = \Stormpath\Resource\Directory::instantiate(array('name' => $name)); $tenant->createDirectory($directory); //$this->assertInstanceOf('\Stormpath\Resource\Directory', $directory); $this->assertEquals($tenant->name, $directory->tenant->name); $this->assertEquals($name, $directory->name); foreach ($tenant->directories as $dir) { $this->assertInstanceOf('\\Stormpath\\Resource\\Directory', $dir); } $directory->delete(); }
/** * @expectedException \Stormpath\Resource\ResourceError */ public function testDelete() { $group = \Stormpath\Resource\Group::instantiate(array('name' => makeUniqueName('GroupMembershipTest testDelete'))); self::$directory->createGroup($group); $account = \Stormpath\Resource\Account::instantiate(array('givenName' => 'Account Name', 'surname' => 'Surname', 'email' => makeUniqueName('GroupMembershipTest testDelete') . '@unknown12345678.kot', 'password' => 'superP4ss')); self::$directory->createAccount($account); $groupMembership = \Stormpath\Resource\GroupMembership::create(array('account' => $account, 'group' => $group)); $groupMembership = \Stormpath\Resource\GroupMembership::get($groupMembership->href); $this->assertInstanceOf('\\Stormpath\\Resource\\GroupMembership', $groupMembership); $this->assertContains('testDelete', $groupMembership->group->name); $this->assertContains('@unknown12345678.kot', $groupMembership->account->email); $href = $groupMembership->href; $groupMembership->delete(); \Stormpath\Resource\GroupMembership::get($href); }
private function createDirectory() { $directory = \Stormpath\Resource\Directory::instantiate(array('name' => makeUniqueName('Directory For Request Signer Test'), 'description' => 'Main Directory description')); return self::createResource(\Stormpath\Resource\Directory::PATH, $directory); }
/** * @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 testShouldBeAbleToGetGroupViaHTMLFragment() { $group = \Stormpath\Resource\Group::instantiate(array('name' => makeUniqueName('GroupTest htmlFragment'))); self::$directory->createGroup($group); $href = $group->href; $hrefParts = array_reverse(explode('/', $href)); $group = \Stormpath\Resource\Group::get($hrefParts[0]); $this->assertInstanceOf('\\Stormpath\\Resource\\Group', $group); $this->assertEquals($href, $group->href); $group2 = \Stormpath\Client::get($hrefParts[1] . '/' . $hrefParts[0], Stormpath::GROUP); $this->assertInstanceOf('\\Stormpath\\Resource\\Group', $group2); $this->assertEquals($href, $group2->href); $group->delete(); }
/** @test */ public function an_application_should_allow_setting_authorized_callback_uri() { $application = \Stormpath\Resource\Application::create(array('name' => makeUniqueName('ApplicationTest authorizedCallbackUri'))); $application->setAuthorizedCallbackUris(['http://myapplication.com/whatever/callback', 'http://myapplication.com/whatever/callback2']); $application->save(); $application = \Stormpath\Resource\Application::get($application->href); $this->assertCount(2, $application->authorizedCallbackUris); $application->delete(); }
public static function setUpBeforeClass() { parent::setUpBeforeClass(); self::$directory = \Stormpath\Resource\Directory::create(array('name' => makeUniqueName('AccountCreationPolicyTest'))); self::$acp = self::$directory->accountCreationPolicy; }
public function testShouldBeAbleToGetDirectoryViaHTMLFragment() { $directory = \Stormpath\Resource\Directory::create(array('name' => makeUniqueName('DirectoryTest htmlFragment'))); $href = $directory->href; $hrefParts = array_reverse(explode('/', $href)); $dir = \Stormpath\Resource\Directory::get($hrefParts[0]); $this->assertInstanceOf('\\Stormpath\\Resource\\Directory', $dir); $this->assertEquals($href, $dir->href); $dir2 = \Stormpath\Client::get($hrefParts[1] . '/' . $hrefParts[0], Stormpath::DIRECTORY); $this->assertInstanceOf('\\Stormpath\\Resource\\Directory', $dir2); $this->assertEquals($href, $dir2->href); $directory->delete(); }
/** @test */ public function a_directory_can_add_a_saml_provider() { $samlProvider = \Stormpath\Resource\SamlProvider::instantiate(['ssoLoginUrl' => 'http://google.com/login', 'ssoLogoutUrl' => 'http://google.com/logout', 'encodedX509SigningCert' => $this->getDummyCertForSaml(), 'requestSignatureAlgorithm' => 'RSA-SHA1']); $directory = \Stormpath\Resource\Directory::create(['name' => makeUniqueName('DirectoryTest samlProvider'), 'provider' => $samlProvider]); $this->assertInstanceOf('Stormpath\\Resource\\Directory', $directory); $this->assertInstanceOf('Stormpath\\Resource\\Provider', $directory->provider); $this->assertEquals('saml', $directory->provider->providerId); $directory->delete(); }
/** * @expectedException \Stormpath\Resource\ResourceError */ public function testDelete() { $application = \Stormpath\Resource\Application::create(array('name' => makeUniqueName('ApplicationTest testDelete'))); $this->assertInstanceOf('Stormpath\\Resource\\Application', $application); $this->assertContains('testDelete', $application->name); $href = $application->href; $application->delete(); \Stormpath\Resource\Application::get($href); }
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 testShouldBeAbleToGetApplicationViaHTMLFragment() { $application = \Stormpath\Resource\Application::create(array('name' => makeUniqueName('ApplicationTest testFragment'))); $href = $application->href; $hrefParts = array_reverse(explode('/', $href)); $app = \Stormpath\Resource\Application::get($hrefParts[0]); $this->assertInstanceOf('\\Stormpath\\Resource\\Application', $app); $this->assertEquals($href, $app->href); $app2 = \Stormpath\Client::get($hrefParts[1] . '/' . $hrefParts[0], Stormpath::APPLICATION); $this->assertInstanceOf('\\Stormpath\\Resource\\Application', $app2); $this->assertEquals($href, $app2->href); $application->delete(); }
/** * @expectedException \Stormpath\Resource\ResourceError * @expectedExceptionMessage The imported password designates an algorithm that is an unsupported value. */ public function testImportingInvalidPasswordFormatTypeShouldThrowException() { $username = makeUniqueName('AccountTest testImportingInvalidPasswordFormat') . 'username'; $client = Client::getInstance(); self::$application = \Stormpath\Resource\Application::instantiate(array('name' => 'Main App for passwordImport' . makeUniqueName('AccountTest testImportingInvalidPasswordFormat'), '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(); }
/** @test */ public function a_provider_can_save_an_attribute_statement_mapping_rule() { $samlProvider = \Stormpath\Resource\SamlProvider::instantiate(['ssoLoginUrl' => 'http://google.com/login', 'ssoLogoutUrl' => 'http://google.com/logout', 'encodedX509SigningCert' => self::getDummyCertForSaml(), 'requestSignatureAlgorithm' => 'RSA-SHA1']); $directory = \Stormpath\Resource\Directory::create(['name' => makeUniqueName('DirectoryTest samlProvider'), 'provider' => $samlProvider]); $providerHref = $directory->provider->href; $provider = SamlProvider::get($providerHref); $ruleBuilder = new \Stormpath\Saml\AttributeStatementMappingRuleBuilder(); $rule = $ruleBuilder->setName('test1')->setAccountAttributes(['customData.test1'])->build(); $rule2 = $ruleBuilder->setName('test2')->setAccountAttributes(['customData.test2'])->build(); $rulesBuilder = new \Stormpath\Saml\AttributeStatementMappingRulesBuilder(); $rulesBuilder->setAttributeStatementMappingRules([$rule, $rule2]); $rules = $rulesBuilder->build(); $provider->setAttributeStatementMappingRules($rules); $provider->save(); $provider = SamlProvider::get($providerHref); $mappingRules = $provider->getAttributeStatementMappingRules(); $this->assertCount(2, $mappingRules->items); foreach ($mappingRules->items as $item) { $this->assertInstanceOf('Stormpath\\Saml\\AttributeStatementMappingRule', $item); } $this->assertEquals('test2', $mappingRules->items[1]->name); $directory->delete(); }