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


##########
amber/src/test/scala/org/apache/texera/web/resource/auth/AuthResourceSpec.scala:
##########
@@ -164,6 +193,29 @@ class AuthResourceSpec
     
assertThrows[NotAuthorizedException](resource.login(UserLoginRequest(uname("bad"),
 "nope")))
   }
 
+  // An account can hold a LOCAL and a GOOGLE credential at once, and the 
frontend reads `googleId`
+  // off the token whichever one was used to sign in. It has to be the GOOGLE 
provider id and not
+  // the login handle: `flarum.service.ts` passes the claim on as an account 
password, so a token
+  // that carried the handle under that name would be handing the handle out.
+  it should "carry the account's Google identity in the token of a local 
sign-in" in {
+    val user = seedUser(uname("dual"), "pw")
+    seedExternalProvider(user.getUid, ProviderTypeEnum.GOOGLE, 
s"google-dual-$runId")
+
+    val response = resource.login(UserLoginRequest(uname("dual"), "pw"))
+
+    googleIdClaimOf(response.accessToken) shouldBe s"google-dual-$runId"
+  }
+
+  // The claim is omitted rather than sent as null for an account that has no 
Google identity —
+  // `common/type/user.ts` declares it optional, and a null would reach Flarum 
as a password.
+  it should "omit googleId from the token of an account with no Google 
identity" in {
+    seedUser(uname("localonly"), "pw")
+
+    val response = resource.login(UserLoginRequest(uname("localonly"), "pw"))
+
+    googleIdClaimOf(response.accessToken) shouldBe null

Review Comment:
   The test name/comment says the token should *omit* the `googleId` claim, but 
asserting `getClaimValue("googleId") == null` can’t distinguish “claim absent” 
from “claim present with null value”. This can let a regression slip through 
where `googleId` is reintroduced as an explicit null claim.



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