/**
  * @test
  * @group AttributeSet
  * @group AttributeDictionary
  * @group AssertionAdapter
  */
 public function attribute_set_with_fallbacks_can_be_configured_when_creating_an_assertion_adapter()
 {
     $assertion = Mockery::mock(SAML2_Assertion::class);
     $assertion->shouldReceive('getAttributes')->andReturn([]);
     $dictionary = new AttributeDictionary();
     ConfigurableAttributeSetFactory::configureWhichAttributeSetToCreate(AttributeSetWithFallbacks::class);
     $adapter = new AssertionAdapter($assertion, $dictionary);
     $attributeSet = $adapter->getAttributeSet();
     ConfigurableAttributeSetFactory::configureWhichAttributeSetToCreate(AttributeSet::class);
     $this->assertInstanceOf(AttributeSetWithFallbacks::class, $attributeSet);
 }
 /**
  * @param AssertionAdapter $assertionAdapter
  * @param EntityId[] $authenticatingAuthorities
  *
  * @return AuthenticatedUser
  * @throws RuntimeException
  */
 public static function createFrom(AssertionAdapter $assertionAdapter, array $authenticatingAuthorities)
 {
     $attributes = [];
     /** @var Attribute $attribute */
     foreach ($assertionAdapter->getAttributeSet() as $attribute) {
         $definition = $attribute->getAttributeDefinition();
         // We only want to replace the eduPersonTargetedID attribute value as that is a nested NameID attribute
         if ($definition->getName() !== 'eduPersonTargetedID') {
             $attributes[] = $attribute;
             continue;
         }
         $eptiValues = $attribute->getValue();
         $attributes[] = new Attribute($definition, [$eptiValues[0]['Value']]);
     }
     return new self($assertionAdapter->getNameId(), AttributeSet::create($attributes), $authenticatingAuthorities);
 }
 /**
  * @test
  * @group AssertionAdapter
  */
 public function attribute_set_has_no_duplicate_attribute_definitions_when_same_attributes_found()
 {
     $oidAttributeUrn = 'urn:oid:0.0.0.0.0.0.0.0.0';
     $maceAttributeUrn = 'urn:mace:some:attribute';
     $attributeValue = ['oid-attribute-value'];
     $existingAttributeDefinition = new AttributeDefinition('existingOidAttribute', $maceAttributeUrn, $oidAttributeUrn);
     $assertion = m::mock('\\SAML2_Assertion');
     $assertion->shouldReceive('getAttributes')->andReturn([$oidAttributeUrn => $attributeValue, $maceAttributeUrn => $attributeValue]);
     $dictionary = new AttributeDictionary();
     $dictionary->addAttributeDefinition($existingAttributeDefinition);
     $adapter = new AssertionAdapter($assertion, $dictionary);
     $attributeSet = $adapter->getAttributeSet();
     $this->assertCount(1, $attributeSet, 'Expected attribute AttributeSet to have exactly one attribute');
 }