aboutsummaryrefslogtreecommitdiffhomepage
path: root/tests/Wallabag
diff options
context:
space:
mode:
authorJeremy Benoist <jeremy.benoist@gmail.com>2019-04-23 22:28:36 +0200
committerJeremy Benoist <jeremy.benoist@gmail.com>2019-04-23 22:39:31 +0200
commitf45496336f5bbd31b69553fcfae9cdfd03b280cc (patch)
treecd085115f041cf0e56a5c5a23dd2706160f2950d /tests/Wallabag
parentbfd69c74e5b4f2ebfcb304b1983bf771c2bb11f7 (diff)
downloadwallabag-f45496336f5bbd31b69553fcfae9cdfd03b280cc.tar.gz
wallabag-f45496336f5bbd31b69553fcfae9cdfd03b280cc.tar.zst
wallabag-f45496336f5bbd31b69553fcfae9cdfd03b280cc.zip
Add ability to match many domains for credentials
Instead of fetching one domain, we use the same method as in site config (to retrieve the matching file) and handle api.example.org, example.org, .org (yes the last one isn’t useful). If one of these match, we got it and use it.
Diffstat (limited to 'tests/Wallabag')
-rw-r--r--tests/Wallabag/CoreBundle/GuzzleSiteAuthenticator/GrabySiteConfigBuilderTest.php18
1 files changed, 9 insertions, 9 deletions
diff --git a/tests/Wallabag/CoreBundle/GuzzleSiteAuthenticator/GrabySiteConfigBuilderTest.php b/tests/Wallabag/CoreBundle/GuzzleSiteAuthenticator/GrabySiteConfigBuilderTest.php
index 1173fc3d..90609180 100644
--- a/tests/Wallabag/CoreBundle/GuzzleSiteAuthenticator/GrabySiteConfigBuilderTest.php
+++ b/tests/Wallabag/CoreBundle/GuzzleSiteAuthenticator/GrabySiteConfigBuilderTest.php
@@ -24,7 +24,7 @@ class GrabySiteConfigBuilderTest extends TestCase
24 24
25 $grabySiteConfig = new GrabySiteConfig(); 25 $grabySiteConfig = new GrabySiteConfig();
26 $grabySiteConfig->requires_login = true; 26 $grabySiteConfig->requires_login = true;
27 $grabySiteConfig->login_uri = 'http://www.example.com/login'; 27 $grabySiteConfig->login_uri = 'http://api.example.com/login';
28 $grabySiteConfig->login_username_field = 'login'; 28 $grabySiteConfig->login_username_field = 'login';
29 $grabySiteConfig->login_password_field = 'password'; 29 $grabySiteConfig->login_password_field = 'password';
30 $grabySiteConfig->login_extra_fields = ['field=value']; 30 $grabySiteConfig->login_extra_fields = ['field=value'];
@@ -32,7 +32,7 @@ class GrabySiteConfigBuilderTest extends TestCase
32 32
33 $grabyConfigBuilderMock 33 $grabyConfigBuilderMock
34 ->method('buildForHost') 34 ->method('buildForHost')
35 ->with('example.com') 35 ->with('api.example.com')
36 ->will($this->returnValue($grabySiteConfig)); 36 ->will($this->returnValue($grabySiteConfig));
37 37
38 $logger = new Logger('foo'); 38 $logger = new Logger('foo');
@@ -43,8 +43,8 @@ class GrabySiteConfigBuilderTest extends TestCase
43 ->disableOriginalConstructor() 43 ->disableOriginalConstructor()
44 ->getMock(); 44 ->getMock();
45 $siteCrentialRepo->expects($this->once()) 45 $siteCrentialRepo->expects($this->once())
46 ->method('findOneByHostAndUser') 46 ->method('findOneByHostsAndUser')
47 ->with('example.com', 1) 47 ->with(['api.example.com', '.example.com'], 1)
48 ->willReturn(['username' => 'foo', 'password' => 'bar']); 48 ->willReturn(['username' => 'foo', 'password' => 'bar']);
49 49
50 $user = $this->getMockBuilder('Wallabag\UserBundle\Entity\User') 50 $user = $this->getMockBuilder('Wallabag\UserBundle\Entity\User')
@@ -66,11 +66,11 @@ class GrabySiteConfigBuilderTest extends TestCase
66 $logger 66 $logger
67 ); 67 );
68 68
69 $config = $this->builder->buildForHost('www.example.com'); 69 $config = $this->builder->buildForHost('api.example.com');
70 70
71 $this->assertSame('example.com', $config->getHost()); 71 $this->assertSame('api.example.com', $config->getHost());
72 $this->assertTrue($config->requiresLogin()); 72 $this->assertTrue($config->requiresLogin());
73 $this->assertSame('http://www.example.com/login', $config->getLoginUri()); 73 $this->assertSame('http://api.example.com/login', $config->getLoginUri());
74 $this->assertSame('login', $config->getUsernameField()); 74 $this->assertSame('login', $config->getUsernameField());
75 $this->assertSame('password', $config->getPasswordField()); 75 $this->assertSame('password', $config->getPasswordField());
76 $this->assertSame(['field' => 'value'], $config->getExtraFields()); 76 $this->assertSame(['field' => 'value'], $config->getExtraFields());
@@ -103,8 +103,8 @@ class GrabySiteConfigBuilderTest extends TestCase
103 ->disableOriginalConstructor() 103 ->disableOriginalConstructor()
104 ->getMock(); 104 ->getMock();
105 $siteCrentialRepo->expects($this->once()) 105 $siteCrentialRepo->expects($this->once())
106 ->method('findOneByHostAndUser') 106 ->method('findOneByHostsAndUser')
107 ->with('unknown.com', 1) 107 ->with(['unknown.com', '.com'], 1)
108 ->willReturn(null); 108 ->willReturn(null);
109 109
110 $user = $this->getMockBuilder('Wallabag\UserBundle\Entity\User') 110 $user = $this->getMockBuilder('Wallabag\UserBundle\Entity\User')