Copilot commented on code in PR #5274:
URL: https://github.com/apache/texera/pull/5274#discussion_r3366146768


##########
agent-service/src/api/auth-api.test.ts:
##########
@@ -0,0 +1,78 @@
+/**
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License.  You may obtain a copy of the License at
+ *
+ *   http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied.  See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+
+import { describe, expect, test } from "bun:test";
+import { createAuthHeaders, extractUserFromToken, validateToken } from 
"./auth-api";
+
+// Builds a syntactically valid (unsigned) JWT for the given payload. The
+// service only base64-decodes the payload — it does not verify the signature —
+// so a dummy signature segment is sufficient for these tests.
+function makeJwt(payload: Record<string, unknown>): string {
+  const header = Buffer.from(JSON.stringify({ alg: "HS256", typ: "JWT" 
})).toString("base64");
+  const body = Buffer.from(JSON.stringify(payload)).toString("base64");
+  return `${header}.${body}.signature`;
+}

Review Comment:
   The helper `makeJwt` is described as producing a “syntactically valid JWT”, 
but it base64-encodes the header/payload (and may include `+`, `/`, and `=` 
padding), while JWTs are base64url-encoded without padding. This mismatch makes 
the comment inaccurate and can make the test tokens diverge from real tokens.
   
   Consider base64url-encoding the segments (and updating the comment 
accordingly) so the tests exercise the same format produced by real JWT issuers.



-- 
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]

Reply via email to