Skip to content

Commit e800acc

Browse files
committed
[Security] Modify tests for previous change
1 parent bf2b36f commit e800acc

37 files changed

+122
-59
lines changed

src/Symfony/Bridge/Doctrine/Tests/Fixtures/BaseUser.php

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -37,4 +37,9 @@ public function getUsername(): string
3737
{
3838
return $this->username;
3939
}
40+
41+
public function getUserIdentifier(): string
42+
{
43+
return $this->username;
44+
}
4045
}

src/Symfony/Bridge/Doctrine/Tests/Fixtures/User.php

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -53,6 +53,11 @@ public function getUsername(): string
5353
return $this->name;
5454
}
5555

56+
public function getUserIdentifier(): string
57+
{
58+
return $this->name;
59+
}
60+
5661
public function eraseCredentials()
5762
{
5863
}

src/Symfony/Bridge/Monolog/Tests/Processor/TokenProcessorTest.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -34,7 +34,7 @@ public function testProcessor()
3434
$record = $processor($record);
3535

3636
$this->assertArrayHasKey('token', $record['extra']);
37-
$this->assertEquals($token->getUsername(), $record['extra']['token']['username']);
37+
$this->assertEquals($token->getUserIdentifier(), $record['extra']['token']['user_identifier']);
3838
$this->assertEquals($token->isAuthenticated(), $record['extra']['token']['authenticated']);
3939
$this->assertEquals(['ROLE_USER'], $record['extra']['token']['roles']);
4040
}

src/Symfony/Bundle/FrameworkBundle/Tests/Functional/Bundle/TestBundle/Controller/SecurityController.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,6 @@ class SecurityController implements ContainerAwareInterface
2121

2222
public function profileAction()
2323
{
24-
return new Response('Welcome '.$this->container->get('security.token_storage')->getToken()->getUsername().'!');
24+
return new Response('Welcome '.$this->container->get('security.token_storage')->getToken()->getUserIdentifier().'!');
2525
}
2626
}

src/Symfony/Bundle/SecurityBundle/Tests/DependencyInjection/CompleteConfigurationTest.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -264,7 +264,7 @@ public function testAccess()
264264
} elseif (3 === $i) {
265265
$this->assertEquals('IS_AUTHENTICATED_ANONYMOUSLY', $attributes[0]);
266266
$expression = $container->getDefinition((string) $attributes[1])->getArgument(0);
267-
$this->assertEquals("token.getUsername() matches '/^admin/'", $expression);
267+
$this->assertEquals("token.getUserIdentifier() matches '/^admin/'", $expression);
268268
}
269269
}
270270
}

src/Symfony/Bundle/SecurityBundle/Tests/DependencyInjection/Fixtures/php/container1.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -97,7 +97,7 @@
9797
'access_control' => [
9898
['path' => '/blog/524', 'role' => 'ROLE_USER', 'requires_channel' => 'https', 'methods' => ['get', 'POST'], 'port' => 8000],
9999
['path' => '/blog/.*', 'role' => 'IS_AUTHENTICATED_ANONYMOUSLY'],
100-
['path' => '/blog/524', 'role' => 'IS_AUTHENTICATED_ANONYMOUSLY', 'allow_if' => "token.getUsername() matches '/^admin/'"],
100+
['path' => '/blog/524', 'role' => 'IS_AUTHENTICATED_ANONYMOUSLY', 'allow_if' => "token.getUserIdentifier() matches '/^admin/'"],
101101
],
102102

103103
'role_hierarchy' => [

src/Symfony/Bundle/SecurityBundle/Tests/DependencyInjection/Fixtures/php/legacy_encoders.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -97,7 +97,7 @@
9797
'access_control' => [
9898
['path' => '/blog/524', 'role' => 'ROLE_USER', 'requires_channel' => 'https', 'methods' => ['get', 'POST'], 'port' => 8000],
9999
['path' => '/blog/.*', 'role' => 'IS_AUTHENTICATED_ANONYMOUSLY'],
100-
['path' => '/blog/524', 'role' => 'IS_AUTHENTICATED_ANONYMOUSLY', 'allow_if' => "token.getUsername() matches '/^admin/'"],
100+
['path' => '/blog/524', 'role' => 'IS_AUTHENTICATED_ANONYMOUSLY', 'allow_if' => "token.getUserIdentifier() matches '/^admin/'"],
101101
],
102102

103103
'role_hierarchy' => [

src/Symfony/Bundle/SecurityBundle/Tests/DependencyInjection/Fixtures/xml/container1.xml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -78,6 +78,6 @@
7878

7979
<rule path="/blog/524" role="ROLE_USER" requires-channel="https" methods="get,POST" port="8000" />
8080
<rule role='IS_AUTHENTICATED_ANONYMOUSLY' path="/blog/.*" />
81-
<rule role='IS_AUTHENTICATED_ANONYMOUSLY' allow-if="token.getUsername() matches '/^admin/'" path="/blog/524" />
81+
<rule role='IS_AUTHENTICATED_ANONYMOUSLY' allow-if="token.getUserIdentifier() matches '/^admin/'" path="/blog/524" />
8282
</config>
8383
</srv:container>

src/Symfony/Bundle/SecurityBundle/Tests/DependencyInjection/Fixtures/xml/legacy_encoders.xml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -78,6 +78,6 @@
7878

7979
<rule path="/blog/524" role="ROLE_USER" requires-channel="https" methods="get,POST" port="8000" />
8080
<rule role='IS_AUTHENTICATED_ANONYMOUSLY' path="/blog/.*" />
81-
<rule role='IS_AUTHENTICATED_ANONYMOUSLY' allow-if="token.getUsername() matches '/^admin/'" path="/blog/524" />
81+
<rule role='IS_AUTHENTICATED_ANONYMOUSLY' allow-if="token.getUserIdentifier() matches '/^admin/'" path="/blog/524" />
8282
</config>
8383
</srv:container>

src/Symfony/Bundle/SecurityBundle/Tests/DependencyInjection/Fixtures/yml/container1.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -84,4 +84,4 @@ security:
8484
-
8585
path: /blog/.*
8686
role: IS_AUTHENTICATED_ANONYMOUSLY
87-
- { path: /blog/524, role: IS_AUTHENTICATED_ANONYMOUSLY, allow_if: "token.getUsername() matches '/^admin/'" }
87+
- { path: /blog/524, role: IS_AUTHENTICATED_ANONYMOUSLY, allow_if: "token.getUserIdentifier() matches '/^admin/'" }

0 commit comments

Comments
 (0)