MCPcopy Index your code
hub / github.com/dgraph-io/dgraph / TestQueryUserInfo

Method TestQueryUserInfo

acl/acl_test.go:2031–2206  ·  view source on GitHub ↗
()

Source from the content-addressed store, hash-verified

2029}
2030
2031func (asuite *AclTestSuite) TestQueryUserInfo() {
2032 t := asuite.T()
2033 ctx, cancel := context.WithTimeout(context.Background(), 100*time.Second)
2034 defer cancel()
2035
2036 gc, cleanup, err := asuite.dc.Client()
2037 require.NoError(t, err)
2038 defer cleanup()
2039 require.NoError(t, gc.LoginIntoNamespace(ctx, dgraphapi.DefaultUser,
2040 dgraphapi.DefaultPassword, x.RootNamespace))
2041
2042 hc, err := asuite.dc.HTTPClient()
2043 require.NoError(t, err)
2044 require.NoError(t, hc.LoginIntoNamespace(dgraphapi.DefaultUser, dgraphapi.DefaultPassword, x.RootNamespace))
2045
2046 addDataAndRules(ctx, t, gc, hc)
2047 require.NoError(t, hc.LoginIntoNamespace(userid, userpassword, x.RootNamespace))
2048
2049 gqlQuery := `
2050 query {
2051 queryUser {
2052 name
2053 groups {
2054 name
2055 rules {
2056 predicate
2057 permission
2058 }
2059 users {
2060 name
2061 }
2062 }
2063 }
2064 }
2065 `
2066 params := dgraphapi.GraphQLParams{
2067 Query: gqlQuery,
2068 }
2069 gqlResp, err := hc.RunGraphqlQuery(params, true)
2070 require.NoError(t, err)
2071 require.NoError(t, dgraphapi.CompareJSON(`
2072 {
2073 "queryUser": [
2074 {
2075 "name": "alice",
2076 "groups": [
2077 {
2078 "name": "dev",
2079 "rules": [
2080 {
2081 "predicate": "name",
2082 "permission": 4
2083 },
2084 {
2085 "predicate": "nickname",
2086 "permission": 2
2087 }
2088 ],

Callers

nothing calls this directly

Calls 9

UpgradeMethod · 0.95
CompareJSONFunction · 0.92
cleanupFunction · 0.85
addDataAndRulesFunction · 0.85
LoginIntoNamespaceMethod · 0.80
RunGraphqlQueryMethod · 0.80
ClientMethod · 0.65
HTTPClientMethod · 0.65
QueryMethod · 0.45

Tested by

no test coverage detected