MCPcopy Create free account
hub / github.com/dgraph-io/dgraph / TestValQueryWithACLPermissions

Method TestValQueryWithACLPermissions

acl/acl_test.go:1436–1654  ·  view source on GitHub ↗
()

Source from the content-addressed store, hash-verified

1434}
1435
1436func (asuite *AclTestSuite) TestValQueryWithACLPermissions() {
1437 t := asuite.T()
1438 ctx, cancel := context.WithTimeout(context.Background(), 100*time.Second)
1439 defer cancel()
1440
1441 gc, cleanup, err := asuite.dc.Client()
1442 require.NoError(t, err)
1443 defer cleanup()
1444 require.NoError(t, gc.LoginIntoNamespace(ctx, dgraphapi.DefaultUser,
1445 dgraphapi.DefaultPassword, x.RootNamespace))
1446
1447 hc, err := asuite.dc.HTTPClient()
1448 require.NoError(t, err)
1449 require.NoError(t, hc.LoginIntoNamespace(dgraphapi.DefaultUser, dgraphapi.DefaultPassword, x.RootNamespace))
1450
1451 require.NoError(t, gc.DropAll())
1452
1453 op := api.Operation{Schema: `
1454 name : string @index(exact) .
1455 nickname : string @index(exact) .
1456 age : int .
1457 type TypeName {
1458 name: string
1459 nickname: string
1460 age: int
1461 }
1462 `}
1463 require.NoError(t, gc.Alter(ctx, &op))
1464
1465 resetUser(t, hc)
1466 createdGroup, err := hc.CreateGroup(devGroup)
1467 require.NoError(t, err)
1468 require.Equal(t, devGroup, createdGroup)
1469 require.NoError(t, hc.AddUserToGroup(userid, devGroup))
1470
1471 mu := &api.Mutation{SetNquads: []byte(`
1472 _:a <name> "RandomGuy" .
1473 _:a <age> "23" .
1474 _:a <nickname> "RG" .
1475 _:a <dgraph.type> "TypeName" .
1476 _:b <name> "RandomGuy2" .
1477 _:b <age> "25" .
1478 _:b <nickname> "RG2" .
1479 _:b <dgraph.type> "TypeName" .
1480 `), CommitNow: true}
1481 _, err = gc.Mutate(mu)
1482 require.NoError(t, err)
1483
1484 query := `{q1(func: has(name)){
1485 v as name
1486 a as age
1487 }
1488 q2(func: eq(val(v), "RandomGuy")) {
1489 val(v)
1490 val(a)
1491 }}`
1492
1493 // Test that groot has access to all the predicates

Callers

nothing calls this directly

Calls 15

UpgradeMethod · 0.95
CompareJSONFunction · 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