@@ -62,15 +62,37 @@ public function testDefaultUserAgentIsSentWithRequests(): void
6262 /**
6363 * @throws ApiException
6464 */
65- public function testUserAgentFromConstructorReplacesDefaultUserAgent (): void
65+ public function testConfigurationFromConstructorIsUsed (): void
6666 {
67- $ client = $ this ->createClient ([new Response (200 , [], "1.0.0 " )], "test-agent/1.0 " );
67+ $ configuration = new Configuration ()
68+ ->setHost ("https://hangar.example.com " )
69+ ->setUserAgent ("test-agent/1.0 " );
70+ $ client = $ this ->createClient ([new Response (200 , [], "1.0.0 " )], configuration: $ configuration );
6871
6972 $ client ->getLatestReleaseVersion ("mclogs " );
7073
74+ $ this ->assertEquals ("hangar.example.com " , $ this ->getRequest ()->getUri ()->getHost ());
7175 $ this ->assertEquals ("test-agent/1.0 " , $ this ->getRequest ()->getHeaderLine ("User-Agent " ));
7276 }
7377
78+ /**
79+ * @throws ApiException
80+ */
81+ public function testApiKeyFromConstructorIsUsedForAuthentication (): void
82+ {
83+ $ client = $ this ->createClient ([
84+ new Response (200 , [], json_encode (["token " => "test-jwt " , "expiresIn " => 3600 ])),
85+ new Response (200 , [], "1.0.0 " ),
86+ ], "test-api-key " );
87+
88+ $ client ->getLatestReleaseVersion ("mclogs " );
89+
90+ $ this ->assertEquals ("POST " , $ this ->getRequest (0 )->getMethod ());
91+ $ this ->assertEquals ("/api/v1/authenticate " , $ this ->getRequest (0 )->getUri ()->getPath ());
92+ $ this ->assertEquals (["apiKey " => "test-api-key " ], $ this ->getQuery (0 ));
93+ $ this ->assertEquals ("Bearer test-jwt " , $ this ->getRequest (1 )->getHeaderLine ("Authorization " ));
94+ }
95+
7496 /**
7597 * @throws ApiException
7698 */
0 commit comments