@@ -48,7 +48,7 @@ protected function sign($dpop, $privateKey=null)
4848
4949 protected function setUp (): void
5050 {
51- $ keyPath = dirname ( __DIR__ ) . '/../fixtures/keys ' ;
51+ $ keyPath = __DIR__ . '/.. /../fixtures/keys ' ;
5252 $ privateKey = file_get_contents ($ keyPath . '/private.key ' );
5353 $ publicKey = file_get_contents ($ keyPath . '/public.key ' );
5454
@@ -86,20 +86,11 @@ protected function setUp(): void
8686 }
8787
8888 private function getWrongKey () {
89- $ key = <<<EOF
90- -----BEGIN PUBLIC KEY-----
91- MIIBIjANBgkqhkiG9w0BAQEFAAOCAQ8AMIIBCgKCAQEAiGzr51tpH6F2HwMUSKCX
92- zxyYfZyNJpKZWzNb3AMrNZTGlKDHHuVCkxNmHV0yFIxr3flRNmvxebLxsuYPAmCF
93- ccV1r+1Pry244MHOIq3aq5mIRq+smVSPk350WpyO4jn8mOLOiH+CYe9LXmJSPBvO
94- zZHwjEp+VmIGp5oDUZc5nnrf/UkQcj6jvKj0TanD8vGpDg9w3WbkQHWbFAMGPQdc
95- YF5CZ68QPKPS86/aOdcnyoliSyIMn9BhrSXS8+Q3fCZHsYgejUjD7e0sx/+gBCrW
96- MOuzbyD29mgbqETiSCZS1YLxgPnA34NRRKY06G0fMusXSGsXC+y7EU8JjTvTs4/L
97- PwIDAQAB
98- -----END PUBLIC KEY-----
99- EOF ;
100- // Get public key
101- $ pubkey =\openssl_pkey_get_details (\openssl_pkey_get_public ($ key ));
102- return $ pubkey ;
89+ $ keyPath = __DIR__ . '/../../fixtures/keys ' ;
90+ $ wrongKey = file_get_contents ($ keyPath . '/wrong.key ' );
91+
92+ $ keyInfo = \openssl_pkey_get_details (\openssl_pkey_get_public ($ wrongKey ));
93+ return $ keyInfo ;
10394 }
10495
10596 /**
@@ -129,6 +120,7 @@ public function testAlgNone(): void
129120 $ this ->expectException (\Exception::class);
130121 $ this ->expectExceptionMessage ('alg is none ' );
131122 $ result = $ dpop ->validateDpop ($ token ['token ' ], $ this ->serverRequest );
123+ $ this ->assertTrue ($ result );
132124 }
133125
134126 /**
@@ -146,12 +138,11 @@ public function testWrongKey(): void
146138
147139 $ dpop = new DPop ();
148140 try {
149- $ result = $ dpop ->validateDpop ($ token ['token ' ], $ this ->serverRequest );
141+ $ dpop ->validateDpop ($ token ['token ' ], $ this ->serverRequest );
150142 } catch (RequiredConstraintsViolated $ e ) {
151- $ result = false ;
143+ // need to check the actual violation in the exception, so expectExceptionMessage is not sufficient
152144 $ this ->assertSame ($ e ->violations ()[0 ]->getMessage (),'Token signature mismatch ' );
153145 }
154- $ this ->assertFalse ($ result );
155146 }
156147
157148 /**
0 commit comments