|
15 | 15 | */ |
16 | 16 | package org.primeframework.mvc; |
17 | 17 |
|
| 18 | +import javax.annotation.Nullable; |
18 | 19 | import java.io.ByteArrayInputStream; |
19 | 20 | import java.io.File; |
20 | 21 | import java.io.IOException; |
|
49 | 50 | import com.google.inject.Key; |
50 | 51 | import com.google.inject.TypeLiteral; |
51 | 52 | import freemarker.template.Configuration; |
| 53 | +import io.fusionauth.http.HTTPMethod; |
52 | 54 | import io.fusionauth.http.HTTPValues.Headers; |
53 | 55 | import io.fusionauth.http.HTTPValues.Methods; |
54 | 56 | import org.example.action.JwtAuthorizedAction; |
|
72 | 74 | import org.primeframework.mvc.security.CBCCipherProvider; |
73 | 75 | import org.primeframework.mvc.security.DefaultEncryptor; |
74 | 76 | import org.primeframework.mvc.security.Encryptor; |
| 77 | +import org.primeframework.mvc.test.DPoPProofProvider; |
75 | 78 | import org.primeframework.mvc.util.URIBuilder; |
76 | 79 | import org.testng.annotations.BeforeClass; |
77 | 80 | import org.testng.annotations.DataProvider; |
@@ -1554,6 +1557,26 @@ public void headers() throws IOException { |
1554 | 1557 | .assertJSONValuesAt("/foo", List.of("bar", "baz")); |
1555 | 1558 | } |
1556 | 1559 |
|
| 1560 | + @Test |
| 1561 | + public void dpopHeader() throws IOException { |
| 1562 | + // Make sure DPoPProofProvider gets invoked with proper values |
| 1563 | + // (a real DPoPProofProvider would generate a signed JWT) |
| 1564 | + DPoPProofProvider provider = (httpMethod, htu, accessToken) -> httpMethod.toString() + ":" + htu + ":" + accessToken; |
| 1565 | + |
| 1566 | + simulator.test("/header-values") |
| 1567 | + .withDPoPProofProvider(provider) |
| 1568 | + .get() |
| 1569 | + .assertStatusCode(200) |
| 1570 | + .assertJSONValuesAt("/dpop", List.of("GET:http://localhost:9080/header-values:null")); |
| 1571 | + |
| 1572 | + simulator.test("/header-values") |
| 1573 | + .withDPoPProofProvider(provider) |
| 1574 | + .withAuthorizationBearerToken("fake.token") |
| 1575 | + .post() |
| 1576 | + .assertStatusCode(200) |
| 1577 | + .assertJSONValuesAt("/dpop", List.of("POST:http://localhost:9080/header-values:fake.token")); |
| 1578 | + } |
| 1579 | + |
1557 | 1580 | @Test |
1558 | 1581 | public void head() { |
1559 | 1582 | simulator.test("/head") |
|
0 commit comments