Code development platform for open source projects from the European Union institutions

Skip to content
Snippets Groups Projects
Commit 1fe2c099 authored by Pol Dellaiera's avatar Pol Dellaiera
Browse files

refactor: Get rid of mock, use real objects.

parent e3d41360
No related branches found
Tags 2.3.5
No related merge requests found
...@@ -57,7 +57,14 @@ EOF; ...@@ -57,7 +57,14 @@ EOF;
$this $this
->getAuthenticationFactors() ->getAuthenticationFactors()
->shouldReturn(['ecphp@ec.europa.eu']); ->shouldReturn([
'moniker' => [
'@value' => 'ecphp@ec.europa.eu',
'@attributes' => [
'number' => '1',
],
],
]);
$this $this
->getDepartmentNumber() ->getDepartmentNumber()
...@@ -116,7 +123,7 @@ EOF; ...@@ -116,7 +123,7 @@ EOF;
$this $this
->getStrengths() ->getStrengths()
->shouldReturn(['bar']); ->shouldReturn(['strength1']);
$this $this
->getTelephoneNumber() ->getTelephoneNumber()
...@@ -137,6 +144,18 @@ EOF; ...@@ -137,6 +144,18 @@ EOF;
$this $this
->getAttributes() ->getAttributes()
->shouldReturn($this->getAttributesData()); ->shouldReturn($this->getAttributesData());
$this
->getUserManager()
->shouldReturn('userManager');
$this
->getTimeZone()
->shouldReturn('timeZone');
$this
->getProxyGrantingProtocol()
->shouldReturn('proxyGrantingProtocol');
} }
public function it_can_get_the_attributes_only(CasUserInterface $user) public function it_can_get_the_attributes_only(CasUserInterface $user)
...@@ -162,10 +181,6 @@ EOF; ...@@ -162,10 +181,6 @@ EOF;
->getSalt() ->getSalt()
->shouldBeNull(); ->shouldBeNull();
$this
->getAttribute('user')
->shouldReturn('username');
$this $this
->getUser() ->getUser()
->shouldReturn('username'); ->shouldReturn('username');
...@@ -179,7 +194,7 @@ EOF; ...@@ -179,7 +194,7 @@ EOF;
->shouldBeNull(); ->shouldBeNull();
} }
public function let(CasUserInterface $user) public function let()
{ {
$body = <<<'EOF' $body = <<<'EOF'
<cas:serviceResponse xmlns:cas="http://www.yale.edu/tp/cas"> <cas:serviceResponse xmlns:cas="http://www.yale.edu/tp/cas">
...@@ -193,12 +208,72 @@ EOF; ...@@ -193,12 +208,72 @@ EOF;
proxyGrantingTicket proxyGrantingTicket
</cas:proxyGrantingTicket> </cas:proxyGrantingTicket>
<cas:attributes> <cas:attributes>
<cas:departmentNumber>
departmentNumber
</cas:departmentNumber>
<cas:domain>
domain
</cas:domain>
<cas:domainUsername>
domainUsername
</cas:domainUsername>
<cas:email>
email
</cas:email>
<cas:employeeNumber>
employeeNumber
</cas:employeeNumber>
<cas:employeeType>
employeeType
</cas:employeeType>
<cas:firstName>
firstName
</cas:firstName>
<cas:lastName>
lastName
</cas:lastName>
<cas:locale>
locale
</cas:locale>
<cas:loginDate>
loginDate
</cas:loginDate>
<cas:orgId>
orgId
</cas:orgId>
<cas:sso>
sso
</cas:sso>
<cas:strengths number="1">
<cas:strength>strength1</cas:strength>
</cas:strengths>
<cas:telephoneNumber>
telephoneNumber
</cas:telephoneNumber>
<cas:teleworkingPriority>
teleworkingPriority
</cas:teleworkingPriority>
<cas:ticketType>
ticketType
</cas:ticketType>
<cas:uid>
uid
</cas:uid>
<cas:authenticationFactors> <cas:authenticationFactors>
<cas:moniker number="1"> <cas:moniker number="1">
ecphp@ec.europa.eu ecphp@ec.europa.eu
</cas:moniker> </cas:moniker>
</cas:authenticationFactors> </cas:authenticationFactors>
<cas:assuranceLevel>40</cas:assuranceLevel> <cas:assuranceLevel>40</cas:assuranceLevel>
<cas:proxyGrantingProtocol>
proxyGrantingProtocol
</cas:proxyGrantingProtocol>
<cas:userManager>
userManager
</cas:userManager>
<cas:timeZone>
timeZone
</cas:timeZone>
<cas:groups number="2"> <cas:groups number="2">
<cas:group>group1</cas:group> <cas:group>group1</cas:group>
<cas:group>group2</cas:group> <cas:group>group2</cas:group>
...@@ -217,134 +292,7 @@ EOF; ...@@ -217,134 +292,7 @@ EOF;
$response = new Response(200, ['Content-Type' => 'application/xml'], $body); $response = new Response(200, ['Content-Type' => 'application/xml'], $body);
$data = (new Introspector())->parse($response)['serviceResponse']['authenticationSuccess']; $data = (new Introspector())->parse($response)['serviceResponse']['authenticationSuccess'];
$user $user = new CasUser($data);
->beConstructedWith($data);
$user
->getAttribute('extendedAttributes', [])
->willReturn([
'extendedAttribute' => [
'attributeValue' => [
'value1',
'value2',
],
'@attributes' => [
'name' => 'attr1',
],
],
]);
$user
->get('foo', 'bar')
->willReturn('bar');
$user
->getUsername()
->willReturn('username');
$user
->getAttribute('user', null)
->willReturn('username');
$user
->getPgt()
->willReturn('proxyGrantingTicket');
$user
->getAttribute('assuranceLevel')
->willReturn($data['attributes']['assuranceLevel']);
$user
->getAttribute('authenticationFactors', [])
->willReturn([
'ecphp@ec.europa.eu',
]);
$user
->getAttribute('departmentNumber')
->willReturn('departmentNumber');
$user
->getAttribute('domain')
->willReturn('domain');
$user
->getAttribute('domainUsername')
->willReturn('domainUsername');
$user
->getAttribute('email')
->willReturn('email');
$user
->getAttribute('employeeNumber')
->willReturn('employeeNumber');
$user
->getAttribute('employeeType')
->willReturn('employeeType');
$user
->getAttribute('firstName')
->willReturn('firstName');
$user
->getAttribute('groups', ['group' => []])
->willReturn([
'group' => [
'group1',
'group2',
],
'@attributes' => [
'number' => 2,
],
]);
$user
->getAttribute('lastName')
->willReturn('lastName');
$user
->getAttribute('locale')
->willReturn('locale');
$user
->getAttribute('loginDate')
->willReturn('loginDate');
$user
->getAttribute('orgId')
->willReturn('orgId');
$user
->getAttribute('sso')
->willReturn('sso');
$user
->getAttribute('strengths', [])
->willReturn([
'bar',
]);
$user
->getAttribute('telephoneNumber')
->willReturn('telephoneNumber');
$user
->getAttribute('teleworkingPriority')
->willReturn('teleworkingPriority');
$user
->getAttribute('ticketType')
->willReturn('ticketType');
$user
->getAttribute('uid')
->willReturn('uid');
$user
->getAttributes()
->willReturn($this->getAttributesData());
$this $this
->beConstructedWith($user); ->beConstructedWith($user);
...@@ -354,26 +302,47 @@ EOF; ...@@ -354,26 +302,47 @@ EOF;
{ {
return [ return [
'departmentNumber' => 'departmentNumber', 'departmentNumber' => 'departmentNumber',
'domain' => 'domain',
'domainUsername' => 'domainUsername',
'email' => 'email', 'email' => 'email',
'employeeNumber' => 'employeeNumber', 'employeeNumber' => 'employeeNumber',
'employeeType' => 'employeeType', 'employeeType' => 'employeeType',
'extendedAttributes' => [ 'firstName' => 'firstName',
'extendedAttribute' => [ 'lastName' => 'lastName',
[ 'locale' => 'locale',
'attr1' => [ 'loginDate' => 'loginDate',
'value1', 'orgId' => 'orgId',
'value2', 'sso' => 'sso',
], 'strengths' => [
'strength' => [
'strength1',
],
'@attributes' => [
'number' => '1',
],
],
'telephoneNumber' => 'telephoneNumber',
'teleworkingPriority' => 'teleworkingPriority',
'ticketType' => 'ticketType',
'uid' => 'uid',
'authenticationFactors' => [
'moniker' => [
'@value' => 'ecphp@ec.europa.eu',
'@attributes' => [
'number' => '1',
], ],
], ],
], ],
'assuranceLevel' => '40',
'proxyGrantingProtocol' => 'proxyGrantingProcotol',
'userManager' => 'userManager',
'timeZone' => 'timeZone',
'firstName' => 'firstName', 'firstName' => 'firstName',
'lastName' => 'lastName', 'lastName' => 'lastName',
'domain' => 'domain', 'domain' => 'domain',
'domainUsername' => 'domainUsername', 'domainUsername' => 'domainUsername',
'telephoneNumber' => 'telephoneNumber', 'telephoneNumber' => 'telephoneNumber',
'locale' => 'locale', 'locale' => 'locale',
'assuranceLevel' => '40',
'uid' => 'uid', 'uid' => 'uid',
'orgId' => 'orgId', 'orgId' => 'orgId',
'teleworkingPriority' => 'teleworkingPriority', 'teleworkingPriority' => 'teleworkingPriority',
...@@ -382,19 +351,29 @@ EOF; ...@@ -382,19 +351,29 @@ EOF;
'group1', 'group1',
'group2', 'group2',
], ],
], '@attributes' => [
'strengths' => [ 'number' => '2',
'strength' => [
'bar',
], ],
], ],
'authenticationFactors' => [ 'extendedAttributes' => [
'ecphp@ec.europa.eu', 'extendedAttribute' => [
[
'attributeValue' => [
'rex',
'snoopy',
],
'@attributes' => [
'name' => 'http://stork.eu/motherInLawDogName',
],
],
],
], ],
'loginDate' => 'loginDate',
'sso' => 'sso', 'sso' => 'sso',
'ticketType' => 'ticketType', 'ticketType' => 'ticketType',
'assuranceLevel' => '40',
'proxyGrantingProtocol' => 'proxyGrantingProtocol', 'proxyGrantingProtocol' => 'proxyGrantingProtocol',
'timeZone' => 'timeZone',
'userManager' => 'userManager',
]; ];
} }
} }
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment