You are viewing a plain text version of this content. The canonical link for it is here.
Posted to notifications@couchdb.apache.org by GitBox <gi...@apache.org> on 2020/03/23 20:05:40 UTC

[GitHub] [couchdb] atrauzzi commented on a change in pull request #2694: Add support for roles to be obtained from JWTs.

atrauzzi commented on a change in pull request #2694: Add support for roles to be obtained from JWTs.
URL: https://github.com/apache/couchdb/pull/2694#discussion_r396724895
 
 

 ##########
 File path: test/elixir/test/jwtauth_test.exs
 ##########
 @@ -103,13 +103,14 @@ defmodule JwtAuthTest do
   end
 
   def test_fun(alg, key) do
-    {:ok, token} = :jwtf.encode({[{"alg", alg}, {"typ", "JWT"}]}, {[{"sub", "couch@apache.org"}]}, key)
+    {:ok, token} = :jwtf.encode({[{"alg", alg}, {"typ", "JWT"}]}, {[{"sub", "couch@apache.org"}, {"roles", ["testing"]}]}, key)
 
     resp = Couch.get("/_session",
       headers: [authorization: "Bearer #{token}"]
     )
 
     assert resp.body["userCtx"]["name"] == "couch@apache.org"
+    assert resp.body["userCtx"]["roles"] == [<<"testing">>]
     assert resp.body["info"]["authenticated"] == "jwt"
 
 Review comment:
   I've added assertions to this portion of the test to ensure we're verifying what comes out of the session endpoint.

----------------------------------------------------------------
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.
 
For queries about this service, please contact Infrastructure at:
users@infra.apache.org


With regards,
Apache Git Services