MCPcopy
hub / github.com/dgraph-io/dgraph / TestValidateToken

Function TestValidateToken

edgraph/access_test.go:35–51  ·  view source on GitHub ↗
(t *testing.T)

Source from the content-addressed store, hash-verified

33}
34
35func TestValidateToken(t *testing.T) {
36 expiry := time.Now().Add(time.Minute * 30).Unix()
37 userDataList := []userData{
38 {1234567890, "user1", []string{"701", "702"}},
39 {2345678901, "user2", []string{"703", "701"}},
40 {3456789012, "user3", []string{"702", "703"}},
41 }
42
43 for _, userdata := range userDataList {
44 tokenString := generateJWT(userdata.namespace, userdata.userId, userdata.groupIds, expiry)
45 ud, err := validateToken(tokenString)
46 require.NoError(t, err)
47 require.Equal(t, userdata.namespace, ud.namespace)
48 require.Equal(t, userdata.userId, ud.userId)
49 require.Equal(t, userdata.groupIds, ud.groupIds)
50 }
51}
52
53func TestGetAccessJwt(t *testing.T) {
54 grpLst := []acl.Group{

Callers

nothing calls this directly

Calls 3

generateJWTFunction · 0.85
validateTokenFunction · 0.85
AddMethod · 0.45

Tested by

no test coverage detected