smolnar82 commented on code in PR #1195:
URL: https://github.com/apache/knox/pull/1195#discussion_r3058020690
##########
gateway-service-knoxtoken/src/test/java/org/apache/knox/gateway/service/knoxtoken/TokenServiceResourceTest.java:
##########
@@ -514,6 +514,57 @@ public void testSignatureAlgorithm() throws Exception {
assertTrue(parsedToken.getHeader().contains("RS512"));
}
+ @Test
+ public void testDefaultTokenType() throws Exception {
+ final Map<String, String> contextExpectations = new HashMap<>();
+ configureCommonExpectations(contextExpectations);
+
+ TokenResource tr = new TokenResource();
+ tr.request = request;
+ tr.context = context;
+ tr.init();
+
+ // Issue a token
+ Response retResponse = tr.doGet();
+
+ assertEquals(200, retResponse.getStatus());
+
+ // Parse the response
+ String retString = retResponse.getEntity().toString();
+ String accessToken = getTagValue(retString, "access_token");
+ assertNotNull(accessToken);
+
+ // Verify the token
+ JWT parsedToken = new JWTToken(accessToken);
+ assertTrue(parsedToken.getHeader().contains("\"typ\":\"JWT\""));
+ }
+
+ @Test
+ public void testCustomTokenType() throws Exception {
+ final Map<String, String> contextExpectations = new HashMap<>();
+ contextExpectations.put("knox.token.type", "custom-type");
Review Comment:
I'd make
`org.apache.knox.gateway.service.knoxtoken.TokenResource#TOKEN_TYPE_PARAM`
public and use it here.
##########
gateway-service-knoxtoken/src/test/java/org/apache/knox/gateway/service/knoxtoken/TokenServiceResourceTest.java:
##########
@@ -514,6 +514,57 @@ public void testSignatureAlgorithm() throws Exception {
assertTrue(parsedToken.getHeader().contains("RS512"));
}
+ @Test
+ public void testDefaultTokenType() throws Exception {
Review Comment:
I don't think this is needed. A simple verification in the `testGetToken`
method would be enough:
```
...
assertEquals("alice", parsedToken.getSubject());
assertTrue(parsedToken.getHeader().contains("\"typ\":\"JWT\""));
...
```
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: [email protected]
For queries about this service, please contact Infrastructure at:
[email protected]