/**
  * @test
  * @group AttributeReleasePolicy
  */
 public function consent_list_and_attributes_are_correctly_converted_to_a_request_and_the_response_is_mapped_correctly_to_a_result()
 {
     $someAttributeDefinition = new AttributeDefinition('someAttribute', 'urn:mace:some-attribute', 'urn:oid:0.0.0.0.0.1');
     $anotherAttributeDefinition = new AttributeDefinition('anotherAttribute', null, 'urn:oid:0.0.0.0.0.2');
     $attributeDictionary = new AttributeDictionary();
     $attributeDictionary->addAttributeDefinition($someAttributeDefinition);
     $attributeDictionary->addAttributeDefinition($anotherAttributeDefinition);
     $client = Mockery::mock(JsonApiClient::class);
     $arpService = new AttributeReleasePolicyService($client, $attributeDictionary);
     $client->shouldReceive('post')->withArgs([['entityIds' => ['some-entity-id', 'another-entity-id'], 'attributes' => ['urn:mace:some-attribute' => ['some-value'], 'urn:oid:0.0.0.0.0.1' => ['some-value'], 'urn:oid:0.0.0.0.0.2' => ['another-value']]], '/arp'])->andReturn(['some-entity-id' => ['urn:mace:some-attribute' => ['some-value'], 'urn:oid:0.0.0.0.0.1' => ['some-value'], 'urn:oid:0.0.0.0.0.2' => ['another-value']], 'another-entity-id' => ['urn:oid:0.0.0.0.0.2' => ['another-value']]]);
     $someConsent = new Consent(new ServiceProvider(new Entity(new EntityId('some-entity-id'), EntityType::SP()), new DisplayName(['en' => 'Some display name']), new Url('http://some-eula-url.example'), new ContactEmailAddress('*****@*****.**')), new DateTimeImmutable(), new DateTimeImmutable(), ConsentType::explicit());
     $anotherConsent = new Consent(new ServiceProvider(new Entity(new EntityId('another-entity-id'), EntityType::SP()), new DisplayName(['en' => 'Another display name']), new Url('http://another-eula-url.example'), new ContactEmailAddress('*****@*****.**')), new DateTimeImmutable(), new DateTimeImmutable(), ConsentType::explicit());
     $consentList = new ConsentList([$someConsent, $anotherConsent]);
     $someAttribute = new Attribute($someAttributeDefinition, ['some-value']);
     $anotherAttribute = new Attribute($anotherAttributeDefinition, ['another-value']);
     $attributeSet = AttributeSet::create([$someAttribute, $anotherAttribute]);
     $expectedResult = SpecifiedConsentList::createWith([SpecifiedConsent::specifies($someConsent, AttributeSetWithFallbacks::create([$someAttribute, $anotherAttribute])), SpecifiedConsent::specifies($anotherConsent, AttributeSetWithFallbacks::create([$anotherAttribute]))]);
     $result = $arpService->applyAttributeReleasePolicies($consentList, $attributeSet);
     $this->assertEquals($expectedResult, $result);
 }
コード例 #2
0
 /**
  * @param AuthenticatedUser $user
  * @return SpecifiedConsentList
  */
 public function getListFor(AuthenticatedUser $user)
 {
     $consentList = $this->consentService->findAllFor($user);
     return $this->attributeReleasePolicyService->applyAttributeReleasePolicies($consentList, $user->getAttributes());
 }