1+ <?php
2+ namespace Authwave \Test ;
3+
4+ use Authwave \AuthUri ;
5+ use Authwave \InitVector ;
6+ use Authwave \Token ;
7+ use PHPUnit \Framework \TestCase ;
8+ use Psr \Http \Message \UriInterface ;
9+
10+ class AuthUriTest extends TestCase {
11+ public function testAuthUriHttps () {
12+ $ baseUri = self ::createMock (UriInterface::class);
13+ $ baseUri ->method ("__toString " )
14+ ->willReturn ("https://example.com " );
15+ $ token = self ::createMock (Token::class);
16+
17+ $ sut = new AuthUri ($ baseUri , $ token , "" );
18+ self ::assertEquals (
19+ "https " ,
20+ $ sut ->getScheme ()
21+ );
22+ }
23+
24+ public function testQueryString () {
25+ $ mockCipherValue = str_repeat ("f " , 16 );
26+ $ mockIvValue = str_repeat ("0 " , 16 );
27+ $ iv = self ::createMock (InitVector::class);
28+ $ iv ->method ("__toString " )
29+ ->willReturn ($ mockIvValue );
30+
31+ $ baseUri = self ::createMock (UriInterface::class);
32+ $ token = self ::createMock (Token::class);
33+ $ token ->method ("generateCipher " )
34+ ->willReturn ($ mockCipherValue );
35+ $ token ->method ("getIv " )
36+ ->willReturn ($ iv );
37+
38+ $ returnPath = "/examplePage " ;
39+ $ sut = new AuthUri ($ baseUri , $ token , $ returnPath );
40+ parse_str ($ sut ->getQuery (), $ queryParts );
41+
42+ self ::assertEquals (
43+ $ mockCipherValue ,
44+ $ queryParts [AuthUri::QUERY_STRING_CIPHER ],
45+ );
46+
47+ self ::assertEquals (
48+ $ mockIvValue ,
49+ $ queryParts [AuthUri::QUERY_STRING_INIT_VECTOR ]
50+ );
51+
52+ self ::assertEquals (
53+ base64_encode ($ returnPath ),
54+ $ queryParts [AuthUri::QUERY_STRING_RETURN_PATH ]
55+ );
56+ }
57+ }
0 commit comments