File tree 3 files changed +32
-2
lines changed
3 files changed +32
-2
lines changed Original file line number Diff line number Diff line change @@ -40,10 +40,13 @@ private function normaliseBaseUri(string $baseUri):Uri {
40
40
?? "https " ;
41
41
$ host = parse_url ($ baseUri , PHP_URL_HOST )
42
42
?? parse_url ($ baseUri , PHP_URL_PATH );
43
+ $ port = parse_url ($ baseUri , PHP_URL_PORT )
44
+ ?? 80 ;
43
45
44
46
$ uri = (new Uri ())
45
47
->withScheme ($ scheme )
46
- ->withHost ($ host );
48
+ ->withHost ($ host )
49
+ ->withPort ($ port );
47
50
48
51
if ($ uri ->getHost () !== "localhost "
49
52
&& $ uri ->getScheme () !== "https " ) {
Original file line number Diff line number Diff line change @@ -62,7 +62,11 @@ public function login():void {
62
62
}
63
63
64
64
$ token = new Token ($ this ->clientKey , $ this ->clientSecret );
65
- $ loginUri = new AuthUri ($ token , $ this ->authwaveHost );
65
+ $ loginUri = new AuthUri (
66
+ $ token ,
67
+ $ this ->redirectPath ,
68
+ $ this ->authwaveHost
69
+ );
66
70
$ this ->redirectHandler ->redirect ($ loginUri );
67
71
}
68
72
Original file line number Diff line number Diff line change @@ -89,4 +89,27 @@ public function testLoginRedirects() {
89
89
);
90
90
$ sut ->login ();
91
91
}
92
+
93
+ public function testLoginRedirectsLocalhost () {
94
+ $ _SESSION = [];
95
+
96
+ $ redirectHandler = self ::createMock (RedirectHandler::class);
97
+ $ redirectHandler ->expects (self ::once ())
98
+ ->method ("redirect " )
99
+ ->with (self ::callback (fn (UriInterface $ uri ) =>
100
+ $ uri ->getScheme () === "http "
101
+ && $ uri ->getHost () === "localhost "
102
+ && $ uri ->getPort () === 8081
103
+ ));
104
+
105
+ $ sut = new Authenticator (
106
+ "test-key " ,
107
+ "test-secret " ,
108
+ "/ " ,
109
+ "http://localhost:8081 " ,
110
+ null ,
111
+ $ redirectHandler
112
+ );
113
+ $ sut ->login ();
114
+ }
92
115
}
You can’t perform that action at this time.
0 commit comments