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

Method TestQueryRemoveUnauthorizedPred

acl/acl_test.go:1062–1210  ·  view source on GitHub ↗
()

Source from the content-addressed store, hash-verified

1060}
1061
1062func (asuite *AclTestSuite) TestQueryRemoveUnauthorizedPred() {
1063 t := asuite.T()
1064 ctx, cancel := context.WithTimeout(context.Background(), 100*time.Second)
1065 defer cancel()
1066
1067 gc, cleanup, err := asuite.dc.Client()
1068 require.NoError(t, err)
1069 defer cleanup()
1070 require.NoError(t, gc.LoginIntoNamespace(ctx, dgraphapi.DefaultUser,
1071 dgraphapi.DefaultPassword, x.RootNamespace))
1072
1073 hc, err := asuite.dc.HTTPClient()
1074 require.NoError(t, err)
1075 require.NoError(t, hc.LoginIntoNamespace(dgraphapi.DefaultUser,
1076 dgraphapi.DefaultPassword, x.RootNamespace))
1077
1078 require.NoError(t, gc.DropAll())
1079
1080 op := api.Operation{Schema: `
1081 name : string @index(exact) .
1082 nickname : string @index(exact) .
1083 age : int .
1084 type TypeName {
1085 name: string
1086 age: int
1087 }
1088 `}
1089 require.NoError(t, gc.Alter(ctx, &op))
1090
1091 resetUser(t, hc)
1092 createdGroup, err := hc.CreateGroup(devGroup)
1093 require.NoError(t, err)
1094 require.Equal(t, devGroup, createdGroup)
1095 require.NoError(t, hc.AddUserToGroup(userid, devGroup))
1096
1097 mu := &api.Mutation{
1098 SetNquads: []byte(`
1099 _:a <name> "RandomGuy" .
1100 _:a <age> "23" .
1101 _:a <nickname> "RG" .
1102 _:a <dgraph.type> "TypeName" .
1103 _:b <name> "RandomGuy2" .
1104 _:b <age> "25" .
1105 _:b <nickname> "RG2" .
1106 _:b <dgraph.type> "TypeName" .`),
1107 CommitNow: true,
1108 }
1109 _, err = gc.Mutate(mu)
1110 require.NoError(t, err)
1111
1112 // give read access of <name> to alice
1113 require.NoError(t, hc.AddRulesToGroup(devGroup,
1114 []dgraphapi.AclRule{{Predicate: "name", Permission: Read.Code}}, true))
1115 asuite.Upgrade()
1116 userClient, cleanup, err := asuite.dc.Client()
1117 require.NoError(t, err)
1118 defer cleanup()
1119

Callers

nothing calls this directly

Calls 14

UpgradeMethod · 0.95
PollTillPassOrTimeoutFunction · 0.92
cleanupFunction · 0.85
resetUserFunction · 0.85
LoginIntoNamespaceMethod · 0.80
DropAllMethod · 0.80
AlterMethod · 0.80
CreateGroupMethod · 0.80
AddUserToGroupMethod · 0.80
AddRulesToGroupMethod · 0.80
ClientMethod · 0.65
HTTPClientMethod · 0.65

Tested by

no test coverage detected