@@ -136,6 +136,7 @@ protected function setUp(): void
136136 $ typeHelperMock ->method ('ensureString ' )->willReturnArgument (0 );
137137 $ typeHelperMock ->method ('ensureNonEmptyString ' )->willReturnArgument (0 );
138138 $ typeHelperMock ->method ('ensureInt ' )->willReturnArgument (0 );
139+ $ typeHelperMock ->method ('ensureArrayWithValuesAsNonEmptyStrings ' )->willReturnArgument (0 );
139140
140141 $ this ->claimFactoryMock = $ this ->createMock (ClaimFactory::class);
141142 $ this ->federationClaimFactoryMock = $ this ->createMock (FederationClaimFactory::class);
@@ -277,6 +278,61 @@ public function testThrowsIfAuthorityHintsNotInConfigurationStatement(): void
277278 }
278279
279280
281+ public function testCanDefineTrustAnchorHints (): void
282+ {
283+ $ this ->validPayload ['trust_anchor_hints ' ] = ['trust-anchor-id ' ];
284+
285+ $ this ->signatureMock ->method ('getProtectedHeader ' )->willReturn ($ this ->sampleHeader );
286+ $ this ->jsonHelperMock ->method ('decode ' )->willReturn ($ this ->validPayload );
287+
288+
289+ $ this ->assertSame (['trust-anchor-id ' ], $ this ->sut ()->getTrustAnchorHints ());
290+ }
291+
292+
293+ public function testThrowsOnInvalidTrustAnchorHints (): void
294+ {
295+ $ this ->validPayload ['trust_anchor_hints ' ] = 'invalid ' ;
296+
297+ $ this ->expectException (JwsException::class);
298+ $ this ->expectExceptionMessage ('Invalid ' );
299+
300+ $ this ->signatureMock ->method ('getProtectedHeader ' )->willReturn ($ this ->sampleHeader );
301+ $ this ->jsonHelperMock ->method ('decode ' )->willReturn ($ this ->validPayload );
302+
303+ $ this ->sut ();
304+ }
305+
306+
307+ public function testThrowsOnEmptyTrustAnchorHints (): void
308+ {
309+ $ this ->validPayload ['trust_anchor_hints ' ] = [];
310+
311+ $ this ->expectException (JwsException::class);
312+ $ this ->expectExceptionMessage ('Empty ' );
313+
314+ $ this ->signatureMock ->method ('getProtectedHeader ' )->willReturn ($ this ->sampleHeader );
315+ $ this ->jsonHelperMock ->method ('decode ' )->willReturn ($ this ->validPayload );
316+
317+ $ this ->sut ();
318+ }
319+
320+
321+ public function testThrowsIfTrustAnchorHintsNotInConfigurationStatement (): void
322+ {
323+ $ this ->validPayload ['trust_anchor_hints ' ] = ['trust-anchor-id ' ];
324+ $ this ->validPayload ['iss ' ] = 'something-else ' ;
325+
326+ $ this ->expectException (JwsException::class);
327+ $ this ->expectExceptionMessage ('non-configuration ' );
328+
329+ $ this ->signatureMock ->method ('getProtectedHeader ' )->willReturn ($ this ->sampleHeader );
330+ $ this ->jsonHelperMock ->method ('decode ' )->willReturn ($ this ->validPayload );
331+
332+ $ this ->sut ();
333+ }
334+
335+
280336 public function testTrustMarksAreOptional (): void
281337 {
282338 $ payload = $ this ->validPayload ;
0 commit comments