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;
 }
 /** @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();
 }
 /** @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();
 }