[ 
https://issues.apache.org/jira/browse/KNOX-3295?focusedWorklogId=1014246&page=com.atlassian.jira.plugin.system.issuetabpanels:worklog-tabpanel#worklog-1014246
 ]

ASF GitHub Bot logged work on KNOX-3295:
----------------------------------------

                Author: ASF GitHub Bot
            Created on: 09/Apr/26 13:09
            Start Date: 09/Apr/26 13:09
    Worklog Time Spent: 10m 
      Work Description: 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\""));
   ...
   ```





Issue Time Tracking
-------------------

    Worklog Id:     (was: 1014246)
    Time Spent: 20m  (was: 10m)

> Set default type to JWT on issued tokens
> ----------------------------------------
>
>                 Key: KNOX-3295
>                 URL: https://issues.apache.org/jira/browse/KNOX-3295
>             Project: Apache Knox
>          Issue Type: Task
>          Components: Server
>    Affects Versions: 2.1.0
>            Reporter: Tamás Hanicz
>            Assignee: Tamás Hanicz
>            Priority: Major
>          Time Spent: 20m
>  Remaining Estimate: 0h
>
> If knox.token.type is not set for the KNOXTOKEN service there is no type in 
> the issued JWT header. This change will make it default to 'JWT'



--
This message was sent by Atlassian Jira
(v8.20.10#820010)

Reply via email to