diff --git a/acl/acl_curl_test.go b/acl/acl_curl_test.go index a89a9ec8360..b9672cddae5 100644 --- a/acl/acl_curl_test.go +++ b/acl/acl_curl_test.go @@ -33,16 +33,16 @@ func (asuite *AclTestSuite) TestCurlAuthorization() { require.NoError(t, err) defer cleanup() require.NoError(t, gc.LoginIntoNamespace(ctx, dgraphapi.DefaultUser, - dgraphapi.DefaultPassword, x.GalaxyNamespace)) + dgraphapi.DefaultPassword, x.RootNamespace)) hc, err := asuite.dc.HTTPClient() require.NoError(t, err) require.NoError(t, hc.LoginIntoNamespace(dgraphapi.DefaultUser, - dgraphapi.DefaultPassword, x.GalaxyNamespace)) + dgraphapi.DefaultPassword, x.RootNamespace)) createAccountAndData(t, gc, hc) // test query through curl - require.NoError(t, hc.LoginIntoNamespace(userid, userpassword, x.GalaxyNamespace)) + require.NoError(t, hc.LoginIntoNamespace(userid, userpassword, x.RootNamespace)) // No ACL rules are specified, so query should return empty response, // alter and mutate should fail. queryArgs := func(jwt string) []string { @@ -96,12 +96,12 @@ func (asuite *AclTestSuite) TestCurlAuthorization() { DgraphErrMsg: "Token is expired", }) // login again using the refreshJwt - require.NoError(t, hc.LoginUsingToken(x.GalaxyNamespace)) + require.NoError(t, hc.LoginUsingToken(x.RootNamespace)) require.NoError(t, err, fmt.Sprintf("login through refresh httpToken failed: %v", err)) hcWithGroot, err := asuite.dc.HTTPClient() require.NoError(t, err) require.NoError(t, hcWithGroot.LoginIntoNamespace(dgraphapi.DefaultUser, - dgraphapi.DefaultPassword, x.GalaxyNamespace)) + dgraphapi.DefaultPassword, x.RootNamespace)) createGroupAndAcls(t, unusedGroup, false, hcWithGroot) time.Sleep(expireJwtSleep) testutil.VerifyCurlCmd(t, queryArgs(hc.AccessJwt), &testutil.CurlFailureConfig{ @@ -109,7 +109,7 @@ func (asuite *AclTestSuite) TestCurlAuthorization() { DgraphErrMsg: "Token is expired", }) // refresh the jwts again - require.NoError(t, hc.LoginUsingToken(x.GalaxyNamespace)) + require.NoError(t, hc.LoginUsingToken(x.RootNamespace)) require.NoError(t, err, fmt.Sprintf("login through refresh httpToken failed: %v", err)) // verify that with an ACL rule defined, all the operations except query should @@ -126,11 +126,11 @@ func (asuite *AclTestSuite) TestCurlAuthorization() { DgraphErrMsg: "PermissionDenied", }) require.NoError(t, hcWithGroot.LoginIntoNamespace(dgraphapi.DefaultUser, - dgraphapi.DefaultPassword, x.GalaxyNamespace)) + dgraphapi.DefaultPassword, x.RootNamespace)) createGroupAndAcls(t, devGroup, true, hcWithGroot) time.Sleep(defaultTimeToSleep) // refresh the jwts again - require.NoError(t, hc.LoginUsingToken(x.GalaxyNamespace)) + require.NoError(t, hc.LoginUsingToken(x.RootNamespace)) require.NoError(t, err, fmt.Sprintf("login through refresh httpToken failed: %v", err)) // verify that the operations should be allowed again through the dev group diff --git a/acl/acl_integration_test.go b/acl/acl_integration_test.go index 24bd5903154..eacdb66bda5 100644 --- a/acl/acl_integration_test.go +++ b/acl/acl_integration_test.go @@ -36,7 +36,7 @@ func (asuite *AclTestSuite) TestPasswordReturn() { hc, err := asuite.dc.HTTPClient() require.NoError(t, err) require.NoError(t, hc.LoginIntoNamespace(dgraphapi.DefaultUser, - dgraphapi.DefaultPassword, x.GalaxyNamespace)) + dgraphapi.DefaultPassword, x.RootNamespace)) query := dgraphapi.GraphQLParams{ Query: ` query { @@ -56,10 +56,10 @@ func (asuite *AclTestSuite) TestHealthForAcl() { hc, err := asuite.dc.HTTPClient() require.NoError(t, err) require.NoError(t, hc.LoginIntoNamespace(dgraphapi.DefaultUser, - dgraphapi.DefaultPassword, x.GalaxyNamespace)) + dgraphapi.DefaultPassword, x.RootNamespace)) resetUser(t, hc) - require.NoError(t, hc.LoginIntoNamespace(userid, userpassword, x.GalaxyNamespace)) + require.NoError(t, hc.LoginIntoNamespace(userid, userpassword, x.RootNamespace)) gqlResp, err := hc.HealthForInstance() require.Error(t, err) // assert errors for non-guardians @@ -67,7 +67,7 @@ func (asuite *AclTestSuite) TestHealthForAcl() { // assert data for guardians require.NoError(t, hc.LoginIntoNamespace(dgraphapi.DefaultUser, - dgraphapi.DefaultPassword, x.GalaxyNamespace)) + dgraphapi.DefaultPassword, x.RootNamespace)) resp, err := hc.HealthForInstance() require.NoError(t, err, "health request failed") @@ -313,10 +313,10 @@ func (asuite *AclTestSuite) TestGuardianOnlyAccessForAdminEndpoints() { hc, err := asuite.dc.HTTPClient() require.NoError(t, err) require.NoError(t, hc.LoginIntoNamespace(dgraphapi.DefaultUser, - dgraphapi.DefaultPassword, x.GalaxyNamespace)) + dgraphapi.DefaultPassword, x.RootNamespace)) resetUser(t, hc) - require.NoError(t, hc.LoginIntoNamespace(userid, userpassword, x.GalaxyNamespace)) + require.NoError(t, hc.LoginIntoNamespace(userid, userpassword, x.RootNamespace)) gqlResp, err := hc.RunGraphqlQuery(params, true) require.Error(t, err) // assert ACL error for non-guardians @@ -325,7 +325,7 @@ func (asuite *AclTestSuite) TestGuardianOnlyAccessForAdminEndpoints() { // for guardians, assert non-ACL error or success if tcase.testGuardianAccess { require.NoError(t, hc.LoginIntoNamespace(dgraphapi.DefaultUser, - dgraphapi.DefaultPassword, x.GalaxyNamespace)) + dgraphapi.DefaultPassword, x.RootNamespace)) resp, err := hc.RunGraphqlQuery(params, true) if tcase.guardianErr == "" { @@ -352,12 +352,12 @@ func (asuite *AclTestSuite) TestFailedLogin() { require.NoError(t, err) defer cleanup() require.NoError(t, gc.LoginIntoNamespace(ctx, dgraphapi.DefaultUser, - dgraphapi.DefaultPassword, x.GalaxyNamespace)) + dgraphapi.DefaultPassword, x.RootNamespace)) hc, err := asuite.dc.HTTPClient() require.NoError(t, err) require.NoError(t, hc.LoginIntoNamespace(dgraphapi.DefaultUser, - dgraphapi.DefaultPassword, x.GalaxyNamespace)) + dgraphapi.DefaultPassword, x.RootNamespace)) require.NoError(t, gc.DropAll()) @@ -365,13 +365,13 @@ func (asuite *AclTestSuite) TestFailedLogin() { require.NoError(t, err) // User is not present - err = client.LoginIntoNamespace(ctx, userid, "simplepassword", x.GalaxyNamespace) + err = client.LoginIntoNamespace(ctx, userid, "simplepassword", x.RootNamespace) require.Error(t, err) require.Contains(t, err.Error(), x.ErrorInvalidLogin.Error()) resetUser(t, hc) // User is present - require.Error(t, client.LoginIntoNamespace(ctx, userid, "randomstring", x.GalaxyNamespace)) + require.Error(t, client.LoginIntoNamespace(ctx, userid, "randomstring", x.RootNamespace)) require.Contains(t, err.Error(), x.ErrorInvalidLogin.Error()) } @@ -384,7 +384,7 @@ func (asuite *AclTestSuite) TestWrongPermission() { require.NoError(t, err) defer cleanup() require.NoError(t, gc.LoginIntoNamespace(ctx, dgraphapi.DefaultUser, - dgraphapi.DefaultPassword, x.GalaxyNamespace)) + dgraphapi.DefaultPassword, x.RootNamespace)) require.NoError(t, gc.DropAll()) mu := &api.Mutation{SetNquads: []byte(` @@ -418,7 +418,7 @@ func (asuite *AclTestSuite) TestACLNamespaceEdge() { require.NoError(t, err) defer cleanup() require.NoError(t, gc.LoginIntoNamespace(context.Background(), - dgraphapi.DefaultUser, dgraphapi.DefaultPassword, x.GalaxyNamespace)) + dgraphapi.DefaultUser, dgraphapi.DefaultPassword, x.RootNamespace)) json := ` { @@ -449,7 +449,7 @@ func (asuite *AclTestSuite) TestACLDuplicateGrootUser() { require.NoError(t, err) defer cleanup() require.NoError(t, gc.LoginIntoNamespace(context.Background(), - dgraphapi.DefaultUser, dgraphapi.DefaultPassword, x.GalaxyNamespace)) + dgraphapi.DefaultUser, dgraphapi.DefaultPassword, x.RootNamespace)) rdfs := `_:a "groot" . _:a "dgraph.type.User" .` diff --git a/acl/acl_test.go b/acl/acl_test.go index 7fba3c011c7..de0b98c0aa2 100644 --- a/acl/acl_test.go +++ b/acl/acl_test.go @@ -468,7 +468,7 @@ func (asuite *AclTestSuite) TestGetCurrentUser() { hc, err := asuite.dc.HTTPClient() require.NoError(t, err) require.NoError(t, hc.LoginIntoNamespace(dgraphapi.DefaultUser, - dgraphapi.DefaultPassword, x.GalaxyNamespace), "login failed") + dgraphapi.DefaultPassword, x.RootNamespace), "login failed") currentUser, err := hc.GetCurrentUser() require.NoError(t, err) require.Equal(t, currentUser, "groot") @@ -485,7 +485,7 @@ func (asuite *AclTestSuite) TestGetCurrentUser() { hc, err = asuite.dc.HTTPClient() require.NoError(t, err) - require.NoError(t, hc.LoginIntoNamespace(userid, userpassword, x.GalaxyNamespace), "login failed") + require.NoError(t, hc.LoginIntoNamespace(userid, userpassword, x.RootNamespace), "login failed") currentUser, err = hc.GetCurrentUser() require.NoError(t, err) require.Equal(t, currentUser, userid) @@ -500,7 +500,7 @@ func (asuite *AclTestSuite) TestCreateAndDeleteUsers() { // adding the user again should fail require.NoError(t, hc.LoginIntoNamespace(dgraphapi.DefaultUser, - dgraphapi.DefaultPassword, x.GalaxyNamespace)) + dgraphapi.DefaultPassword, x.RootNamespace)) user, err := hc.CreateUser(userid, userpassword) require.Error(t, err) require.Contains(t, err.Error(), "because id alice already exists") @@ -512,7 +512,7 @@ func (asuite *AclTestSuite) TestCreateAndDeleteUsers() { hc, err = asuite.dc.HTTPClient() require.NoError(t, err) require.NoError(t, hc.LoginIntoNamespace(dgraphapi.DefaultUser, - dgraphapi.DefaultPassword, x.GalaxyNamespace)) + dgraphapi.DefaultPassword, x.RootNamespace)) require.NoError(t, hc.DeleteUser(userid), "error while deleteing user") user, err = hc.CreateUser(userid, userpassword) require.NoError(t, err) @@ -520,7 +520,7 @@ func (asuite *AclTestSuite) TestCreateAndDeleteUsers() { } func resetUser(t *testing.T, hc *dgraphapi.HTTPClient) { - require.NoError(t, hc.LoginIntoNamespace(dgraphapi.DefaultUser, dgraphapi.DefaultPassword, x.GalaxyNamespace)) + require.NoError(t, hc.LoginIntoNamespace(dgraphapi.DefaultUser, dgraphapi.DefaultPassword, x.RootNamespace)) // clean up the user to allow repeated running of this test require.NoError(t, hc.DeleteUser(userid), "error while deleteing user") @@ -540,7 +540,7 @@ func (asuite *AclTestSuite) TestPreDefinedPredicates() { defer cleanup() ctx := context.Background() require.NoError(t, gc.LoginIntoNamespace(ctx, dgraphapi.DefaultUser, - dgraphapi.DefaultPassword, x.GalaxyNamespace)) + dgraphapi.DefaultPassword, x.RootNamespace)) alterPreDefinedPredicates(t, gc.Dgraph, asuite.dc.GetVersion()) } @@ -554,7 +554,7 @@ func (asuite *AclTestSuite) TestPreDefinedTypes() { defer cleanup() ctx := context.Background() require.NoError(t, gc.LoginIntoNamespace(ctx, dgraphapi.DefaultUser, - dgraphapi.DefaultPassword, x.GalaxyNamespace)) + dgraphapi.DefaultPassword, x.RootNamespace)) alterPreDefinedTypes(t, gc.Dgraph) } @@ -634,11 +634,11 @@ func testAuthorization(t *testing.T, gc *dgraphapi.GrpcClient, hc *dgraphapi.HTT gc, cleanup, err := asuite.dc.Client() defer cleanup() require.NoError(t, err) - require.NoError(t, gc.LoginIntoNamespace(context.Background(), userid, userpassword, x.GalaxyNamespace)) + require.NoError(t, gc.LoginIntoNamespace(context.Background(), userid, userpassword, x.RootNamespace)) hc, err = asuite.dc.HTTPClient() require.NoError(t, err) - require.NoError(t, hc.LoginIntoNamespace(dgraphapi.DefaultUser, dgraphapi.DefaultPassword, x.GalaxyNamespace)) + require.NoError(t, hc.LoginIntoNamespace(dgraphapi.DefaultUser, dgraphapi.DefaultPassword, x.RootNamespace)) // initially the query should return empty result, mutate and alter // operations should all fail when there are no rules defined on the predicates @@ -792,7 +792,7 @@ func alterPredicateWithUserAccount(t *testing.T, gc *dgraphapi.GrpcClient, shoul func createAccountAndData(t *testing.T, gc *dgraphapi.GrpcClient, hc *dgraphapi.HTTPClient) { // use the groot account to clean the database require.NoError(t, gc.LoginIntoNamespace(context.Background(), dgraphapi.DefaultUser, - dgraphapi.DefaultPassword, x.GalaxyNamespace)) + dgraphapi.DefaultPassword, x.RootNamespace)) require.NoError(t, gc.DropAll(), "Unable to cleanup db") require.NoError(t, gc.Alter(context.Background(), &api.Operation{ @@ -854,9 +854,9 @@ func (asuite *AclTestSuite) TestPredicatePermission() { hc, err := asuite.dc.HTTPClient() require.NoError(t, err) - require.NoError(t, hc.LoginIntoNamespace(dgraphapi.DefaultUser, dgraphapi.DefaultPassword, x.GalaxyNamespace)) + require.NoError(t, hc.LoginIntoNamespace(dgraphapi.DefaultUser, dgraphapi.DefaultPassword, x.RootNamespace)) require.NoError(t, gc.LoginIntoNamespace(ctx, dgraphapi.DefaultUser, - dgraphapi.DefaultPassword, x.GalaxyNamespace)) + dgraphapi.DefaultPassword, x.RootNamespace)) createAccountAndData(t, gc, hc) @@ -867,13 +867,13 @@ func (asuite *AclTestSuite) TestPredicatePermission() { defer cleanup() require.NoError(t, gc.LoginIntoNamespace(ctx, dgraphapi.DefaultUser, - dgraphapi.DefaultPassword, x.GalaxyNamespace)) + dgraphapi.DefaultPassword, x.RootNamespace)) hc, err = asuite.dc.HTTPClient() require.NoError(t, err) require.NoError(t, hc.LoginIntoNamespace(dgraphapi.DefaultUser, - dgraphapi.DefaultPassword, x.GalaxyNamespace)) + dgraphapi.DefaultPassword, x.RootNamespace)) - require.NoError(t, gc.LoginIntoNamespace(ctx, userid, userpassword, x.GalaxyNamespace), + require.NoError(t, gc.LoginIntoNamespace(ctx, userid, userpassword, x.RootNamespace), "Logging in with the current password should have succeeded") // Schema query is allowed to all logged in users. @@ -909,9 +909,9 @@ func (asuite *AclTestSuite) TestAccessWithoutLoggingIn() { hc, err := asuite.dc.HTTPClient() require.NoError(t, err) - require.NoError(t, hc.LoginIntoNamespace(dgraphapi.DefaultUser, dgraphapi.DefaultPassword, x.GalaxyNamespace)) + require.NoError(t, hc.LoginIntoNamespace(dgraphapi.DefaultUser, dgraphapi.DefaultPassword, x.RootNamespace)) require.NoError(t, gc.LoginIntoNamespace(ctx, dgraphapi.DefaultUser, - dgraphapi.DefaultPassword, x.GalaxyNamespace)) + dgraphapi.DefaultPassword, x.RootNamespace)) createAccountAndData(t, gc, hc) @@ -941,7 +941,7 @@ func (asuite *AclTestSuite) TestUnauthorizedDeletion() { require.NoError(t, err) defer cleanup() require.NoError(t, gc.LoginIntoNamespace(ctx, dgraphapi.DefaultUser, - dgraphapi.DefaultPassword, x.GalaxyNamespace)) + dgraphapi.DefaultPassword, x.RootNamespace)) require.NoError(t, gc.DropAll()) @@ -952,7 +952,7 @@ func (asuite *AclTestSuite) TestUnauthorizedDeletion() { hc, err := asuite.dc.HTTPClient() require.NoError(t, err) require.NoError(t, hc.LoginIntoNamespace(dgraphapi.DefaultUser, - dgraphapi.DefaultPassword, x.GalaxyNamespace)) + dgraphapi.DefaultPassword, x.RootNamespace)) resetUser(t, hc) @@ -977,7 +977,7 @@ func (asuite *AclTestSuite) TestUnauthorizedDeletion() { time.Sleep(defaultTimeToSleep) - require.NoError(t, userClient.LoginIntoNamespace(ctx, userid, userpassword, x.GalaxyNamespace)) + require.NoError(t, userClient.LoginIntoNamespace(ctx, userid, userpassword, x.RootNamespace)) mu = &api.Mutation{ DelNquads: []byte(fmt.Sprintf("%s %s %s .", "<"+nodeUID+">", "<"+unAuthPred+">", "*")), CommitNow: true, @@ -998,9 +998,9 @@ func (asuite *AclTestSuite) TestGuardianAccess() { hc, err := asuite.dc.HTTPClient() require.NoError(t, err) - require.NoError(t, hc.LoginIntoNamespace(dgraphapi.DefaultUser, dgraphapi.DefaultPassword, x.GalaxyNamespace)) + require.NoError(t, hc.LoginIntoNamespace(dgraphapi.DefaultUser, dgraphapi.DefaultPassword, x.RootNamespace)) require.NoError(t, gc.LoginIntoNamespace(ctx, dgraphapi.DefaultUser, - dgraphapi.DefaultPassword, x.GalaxyNamespace)) + dgraphapi.DefaultPassword, x.RootNamespace)) require.NoError(t, gc.DropAll()) op := api.Operation{Schema: "unauthpred: string @index(exact) ."} @@ -1028,7 +1028,7 @@ func (asuite *AclTestSuite) TestGuardianAccess() { require.NoError(t, err, "Error while creating client") defer cleanup() - require.NoError(t, gClient.LoginIntoNamespace(ctx, "guardian", "guardianpass", x.GalaxyNamespace)) + require.NoError(t, gClient.LoginIntoNamespace(ctx, "guardian", "guardianpass", x.RootNamespace)) mu = &api.Mutation{ SetNquads: []byte(fmt.Sprintf("<%s> \"testdata\" .", nodeUID)), CommitNow: true, @@ -1051,7 +1051,7 @@ func (asuite *AclTestSuite) TestGuardianAccess() { hc, err = asuite.dc.HTTPClient() require.NoError(t, err) - require.NoError(t, hc.LoginIntoNamespace(dgraphapi.DefaultUser, dgraphapi.DefaultPassword, x.GalaxyNamespace)) + require.NoError(t, hc.LoginIntoNamespace(dgraphapi.DefaultUser, dgraphapi.DefaultPassword, x.RootNamespace)) require.NoError(t, hc.RemoveUserFromGroup("guardian", "guardians")) @@ -1068,12 +1068,12 @@ func (asuite *AclTestSuite) TestQueryRemoveUnauthorizedPred() { require.NoError(t, err) defer cleanup() require.NoError(t, gc.LoginIntoNamespace(ctx, dgraphapi.DefaultUser, - dgraphapi.DefaultPassword, x.GalaxyNamespace)) + dgraphapi.DefaultPassword, x.RootNamespace)) hc, err := asuite.dc.HTTPClient() require.NoError(t, err) require.NoError(t, hc.LoginIntoNamespace(dgraphapi.DefaultUser, - dgraphapi.DefaultPassword, x.GalaxyNamespace)) + dgraphapi.DefaultPassword, x.RootNamespace)) require.NoError(t, gc.DropAll()) @@ -1118,7 +1118,7 @@ func (asuite *AclTestSuite) TestQueryRemoveUnauthorizedPred() { defer cleanup() time.Sleep(defaultTimeToSleep) - require.NoError(t, userClient.LoginIntoNamespace(ctx, userid, userpassword, x.GalaxyNamespace)) + require.NoError(t, userClient.LoginIntoNamespace(ctx, userid, userpassword, x.RootNamespace)) tests := []struct { input string @@ -1218,11 +1218,11 @@ func (asuite *AclTestSuite) TestExpandQueryWithACLPermissions() { require.NoError(t, err) defer cleanup() require.NoError(t, gc.LoginIntoNamespace(ctx, dgraphapi.DefaultUser, - dgraphapi.DefaultPassword, x.GalaxyNamespace)) + dgraphapi.DefaultPassword, x.RootNamespace)) hc, err := asuite.dc.HTTPClient() require.NoError(t, err) - require.NoError(t, hc.LoginIntoNamespace(dgraphapi.DefaultUser, dgraphapi.DefaultPassword, x.GalaxyNamespace)) + require.NoError(t, hc.LoginIntoNamespace(dgraphapi.DefaultUser, dgraphapi.DefaultPassword, x.RootNamespace)) require.NoError(t, gc.DropAll()) @@ -1282,11 +1282,11 @@ func (asuite *AclTestSuite) TestExpandQueryWithACLPermissions() { hc, err = asuite.dc.HTTPClient() require.NoError(t, err) require.NoError(t, hc.LoginIntoNamespace(dgraphapi.DefaultUser, - dgraphapi.DefaultPassword, x.GalaxyNamespace)) + dgraphapi.DefaultPassword, x.RootNamespace)) time.Sleep(defaultTimeToSleep) - require.NoError(t, userClient.LoginIntoNamespace(ctx, userid, userpassword, x.GalaxyNamespace)) + require.NoError(t, userClient.LoginIntoNamespace(ctx, userid, userpassword, x.RootNamespace)) // Query via user when user has no permissions require.NoError(t, dgraphapi.PollTillPassOrTimeout(userClient, query, `{}`, timeout)) @@ -1300,7 +1300,7 @@ func (asuite *AclTestSuite) TestExpandQueryWithACLPermissions() { // Login to groot to modify accesses (2) require.NoError(t, hc.LoginIntoNamespace(dgraphapi.DefaultUser, - dgraphapi.DefaultPassword, x.GalaxyNamespace)) + dgraphapi.DefaultPassword, x.RootNamespace)) // Add alice to sre group which has read access to and write access to require.NoError(t, hc.AddUserToGroup(userid, sreGroup)) @@ -1309,7 +1309,7 @@ func (asuite *AclTestSuite) TestExpandQueryWithACLPermissions() { // Login to groot to modify accesses (3) require.NoError(t, hc.LoginIntoNamespace(dgraphapi.DefaultUser, - dgraphapi.DefaultPassword, x.GalaxyNamespace)) + dgraphapi.DefaultPassword, x.RootNamespace)) // Give read access of and , write access of to dev require.NoError(t, hc.AddRulesToGroup(devGroup, []dgraphapi.AclRule{{Predicate: "age", Permission: Write.Code}, @@ -1329,11 +1329,11 @@ func (asuite *AclTestSuite) TestDeleteQueryWithACLPermissions() { require.NoError(t, err) defer cleanup() require.NoError(t, gc.LoginIntoNamespace(ctx, dgraphapi.DefaultUser, - dgraphapi.DefaultPassword, x.GalaxyNamespace)) + dgraphapi.DefaultPassword, x.RootNamespace)) hc, err := asuite.dc.HTTPClient() require.NoError(t, err) - require.NoError(t, hc.LoginIntoNamespace(dgraphapi.DefaultUser, dgraphapi.DefaultPassword, x.GalaxyNamespace)) + require.NoError(t, hc.LoginIntoNamespace(dgraphapi.DefaultUser, dgraphapi.DefaultPassword, x.RootNamespace)) require.NoError(t, gc.DropAll()) @@ -1391,13 +1391,13 @@ func (asuite *AclTestSuite) TestDeleteQueryWithACLPermissions() { gc, _, err = asuite.dc.Client() require.NoError(t, err) require.NoError(t, gc.LoginIntoNamespace(ctx, dgraphapi.DefaultUser, - dgraphapi.DefaultPassword, x.GalaxyNamespace)) + dgraphapi.DefaultPassword, x.RootNamespace)) userClient, cleanup, err := asuite.dc.Client() require.NoError(t, err) defer cleanup() time.Sleep(defaultTimeToSleep) - require.NoError(t, userClient.LoginIntoNamespace(ctx, userid, userpassword, x.GalaxyNamespace)) + require.NoError(t, userClient.LoginIntoNamespace(ctx, userid, userpassword, x.RootNamespace)) mu = &api.Mutation{DelNquads: []byte(fmt.Sprintf("%s %s %s .", "<"+nodeUID+">", "*", "*")), CommitNow: true} // delete S * * (user now has permission to name and age) @@ -1407,7 +1407,7 @@ func (asuite *AclTestSuite) TestDeleteQueryWithACLPermissions() { hc, err = asuite.dc.HTTPClient() require.NoError(t, err) require.NoError(t, hc.LoginIntoNamespace(dgraphapi.DefaultUser, - dgraphapi.DefaultPassword, x.GalaxyNamespace)) + dgraphapi.DefaultPassword, x.RootNamespace)) resp, err = gc.Query(query) require.NoError(t, err, "Error while querying data") @@ -1442,11 +1442,11 @@ func (asuite *AclTestSuite) TestValQueryWithACLPermissions() { require.NoError(t, err) defer cleanup() require.NoError(t, gc.LoginIntoNamespace(ctx, dgraphapi.DefaultUser, - dgraphapi.DefaultPassword, x.GalaxyNamespace)) + dgraphapi.DefaultPassword, x.RootNamespace)) hc, err := asuite.dc.HTTPClient() require.NoError(t, err) - require.NoError(t, hc.LoginIntoNamespace(dgraphapi.DefaultUser, dgraphapi.DefaultPassword, x.GalaxyNamespace)) + require.NoError(t, hc.LoginIntoNamespace(dgraphapi.DefaultUser, dgraphapi.DefaultPassword, x.RootNamespace)) require.NoError(t, gc.DropAll()) @@ -1599,12 +1599,12 @@ func (asuite *AclTestSuite) TestValQueryWithACLPermissions() { userClient, cleanup, err := asuite.dc.Client() require.NoError(t, err) defer cleanup() - require.NoError(t, userClient.LoginIntoNamespace(ctx, userid, userpassword, x.GalaxyNamespace)) + require.NoError(t, userClient.LoginIntoNamespace(ctx, userid, userpassword, x.RootNamespace)) hc, err = asuite.dc.HTTPClient() require.NoError(t, err) require.NoError(t, hc.LoginIntoNamespace(dgraphapi.DefaultUser, - dgraphapi.DefaultPassword, x.GalaxyNamespace)) + dgraphapi.DefaultPassword, x.RootNamespace)) time.Sleep(defaultTimeToSleep) @@ -1634,7 +1634,7 @@ func (asuite *AclTestSuite) TestValQueryWithACLPermissions() { // Login to groot to modify accesses (1) require.NoError(t, hc.LoginIntoNamespace(dgraphapi.DefaultUser, - dgraphapi.DefaultPassword, x.GalaxyNamespace)) + dgraphapi.DefaultPassword, x.RootNamespace)) // Give read access of and to dev require.NoError(t, hc.AddRulesToGroup(devGroup, []dgraphapi.AclRule{{Predicate: "name", Permission: Read.Code}, @@ -1662,12 +1662,12 @@ func (asuite *AclTestSuite) TestAllPredsPermission() { require.NoError(t, err) defer cleanup() require.NoError(t, gc.LoginIntoNamespace(ctx, dgraphapi.DefaultUser, - dgraphapi.DefaultPassword, x.GalaxyNamespace)) + dgraphapi.DefaultPassword, x.RootNamespace)) hc, err := asuite.dc.HTTPClient() require.NoError(t, err) require.NoError(t, hc.LoginIntoNamespace(dgraphapi.DefaultUser, - dgraphapi.DefaultPassword, x.GalaxyNamespace)) + dgraphapi.DefaultPassword, x.RootNamespace)) require.NoError(t, gc.DropAll()) @@ -1762,7 +1762,7 @@ func (asuite *AclTestSuite) TestAllPredsPermission() { defer cleanup() time.Sleep(defaultTimeToSleep) - require.NoError(t, userClient.LoginIntoNamespace(ctx, userid, userpassword, x.GalaxyNamespace)) + require.NoError(t, userClient.LoginIntoNamespace(ctx, userid, userpassword, x.RootNamespace)) // Query via user when user has no permissions for _, tc := range tests { @@ -1778,7 +1778,7 @@ func (asuite *AclTestSuite) TestAllPredsPermission() { hc, err = asuite.dc.HTTPClient() require.NoError(t, err) require.NoError(t, hc.LoginIntoNamespace(dgraphapi.DefaultUser, - dgraphapi.DefaultPassword, x.GalaxyNamespace)) + dgraphapi.DefaultPassword, x.RootNamespace)) // Give read access of all predicates to dev require.NoError(t, hc.AddRulesToGroup(devGroup, @@ -1824,11 +1824,11 @@ func (asuite *AclTestSuite) TestNewACLPredicates() { require.NoError(t, err) defer cleanup() require.NoError(t, gc.LoginIntoNamespace(ctx, dgraphapi.DefaultUser, - dgraphapi.DefaultPassword, x.GalaxyNamespace)) + dgraphapi.DefaultPassword, x.RootNamespace)) hc, err := asuite.dc.HTTPClient() require.NoError(t, err) - require.NoError(t, hc.LoginIntoNamespace(dgraphapi.DefaultUser, dgraphapi.DefaultPassword, x.GalaxyNamespace)) + require.NoError(t, hc.LoginIntoNamespace(dgraphapi.DefaultUser, dgraphapi.DefaultPassword, x.RootNamespace)) addDataAndRules(ctx, t, gc, hc) @@ -1837,7 +1837,7 @@ func (asuite *AclTestSuite) TestNewACLPredicates() { userClient, cleanup, err := asuite.dc.Client() require.NoError(t, err) defer cleanup() - require.NoError(t, userClient.LoginIntoNamespace(ctx, userid, userpassword, x.GalaxyNamespace)) + require.NoError(t, userClient.LoginIntoNamespace(ctx, userid, userpassword, x.RootNamespace)) time.Sleep(defaultTimeToSleep) @@ -1925,11 +1925,11 @@ func (asuite *AclTestSuite) TestDeleteRule() { require.NoError(t, err) defer cleanup() require.NoError(t, gc.LoginIntoNamespace(ctx, dgraphapi.DefaultUser, - dgraphapi.DefaultPassword, x.GalaxyNamespace)) + dgraphapi.DefaultPassword, x.RootNamespace)) hc, err := asuite.dc.HTTPClient() require.NoError(t, err) - require.NoError(t, hc.LoginIntoNamespace(dgraphapi.DefaultUser, dgraphapi.DefaultPassword, x.GalaxyNamespace)) + require.NoError(t, hc.LoginIntoNamespace(dgraphapi.DefaultUser, dgraphapi.DefaultPassword, x.RootNamespace)) addDataAndRules(ctx, t, gc, hc) @@ -1938,14 +1938,14 @@ func (asuite *AclTestSuite) TestDeleteRule() { hc, err = asuite.dc.HTTPClient() require.NoError(t, err) require.NoError(t, hc.LoginIntoNamespace(dgraphapi.DefaultUser, - dgraphapi.DefaultPassword, x.GalaxyNamespace)) + dgraphapi.DefaultPassword, x.RootNamespace)) userClient, cleanup, err := asuite.dc.Client() require.NoError(t, err) defer cleanup() time.Sleep(defaultTimeToSleep) - require.NoError(t, userClient.LoginIntoNamespace(ctx, userid, userpassword, x.GalaxyNamespace)) + require.NoError(t, userClient.LoginIntoNamespace(ctx, userid, userpassword, x.RootNamespace)) queryName := "{me(func: has(name)) {name}}" resp, err := userClient.Query(queryName) @@ -2037,14 +2037,14 @@ func (asuite *AclTestSuite) TestQueryUserInfo() { require.NoError(t, err) defer cleanup() require.NoError(t, gc.LoginIntoNamespace(ctx, dgraphapi.DefaultUser, - dgraphapi.DefaultPassword, x.GalaxyNamespace)) + dgraphapi.DefaultPassword, x.RootNamespace)) hc, err := asuite.dc.HTTPClient() require.NoError(t, err) - require.NoError(t, hc.LoginIntoNamespace(dgraphapi.DefaultUser, dgraphapi.DefaultPassword, x.GalaxyNamespace)) + require.NoError(t, hc.LoginIntoNamespace(dgraphapi.DefaultUser, dgraphapi.DefaultPassword, x.RootNamespace)) addDataAndRules(ctx, t, gc, hc) - require.NoError(t, hc.LoginIntoNamespace(userid, userpassword, x.GalaxyNamespace)) + require.NoError(t, hc.LoginIntoNamespace(userid, userpassword, x.RootNamespace)) gqlQuery := ` query { @@ -2126,11 +2126,11 @@ func (asuite *AclTestSuite) TestQueryUserInfo() { userClient, cleanup, err := asuite.dc.Client() require.NoError(t, err) defer cleanup() - require.NoError(t, userClient.LoginIntoNamespace(ctx, userid, userpassword, x.GalaxyNamespace)) + require.NoError(t, userClient.LoginIntoNamespace(ctx, userid, userpassword, x.RootNamespace)) hc, err = asuite.dc.HTTPClient() require.NoError(t, err) - require.NoError(t, hc.LoginIntoNamespace(userid, userpassword, x.GalaxyNamespace)) + require.NoError(t, hc.LoginIntoNamespace(userid, userpassword, x.RootNamespace)) resp, err := userClient.Query(query) require.NoError(t, err, "Error while querying ACL") @@ -2215,12 +2215,12 @@ func (asuite *AclTestSuite) TestQueriesWithUserAndGroupOfSameName() { require.NoError(t, err) defer cleanup() require.NoError(t, gc.LoginIntoNamespace(ctx, dgraphapi.DefaultUser, - dgraphapi.DefaultPassword, x.GalaxyNamespace)) + dgraphapi.DefaultPassword, x.RootNamespace)) hc, err := asuite.dc.HTTPClient() require.NoError(t, err) require.NoError(t, hc.LoginIntoNamespace(dgraphapi.DefaultUser, - dgraphapi.DefaultPassword, x.GalaxyNamespace)) + dgraphapi.DefaultPassword, x.RootNamespace)) require.NoError(t, gc.DropAll()) // Creates a user -- alice @@ -2255,7 +2255,7 @@ func (asuite *AclTestSuite) TestQueriesWithUserAndGroupOfSameName() { dc, cleanup, err := asuite.dc.Client() require.NoError(t, err) defer cleanup() - require.NoError(t, dc.LoginIntoNamespace(ctx, userid, userpassword, x.GalaxyNamespace)) + require.NoError(t, dc.LoginIntoNamespace(ctx, userid, userpassword, x.RootNamespace)) query := ` { @@ -2274,7 +2274,7 @@ func (asuite *AclTestSuite) TestQueriesForNonGuardianUserWithoutGroup() { hc, err := asuite.dc.HTTPClient() require.NoError(t, err) require.NoError(t, hc.LoginIntoNamespace(dgraphapi.DefaultUser, - dgraphapi.DefaultPassword, x.GalaxyNamespace)) + dgraphapi.DefaultPassword, x.RootNamespace)) // Create a new user without any groups, queryGroup should return an empty result. resetUser(t, hc) @@ -2283,7 +2283,7 @@ func (asuite *AclTestSuite) TestQueriesForNonGuardianUserWithoutGroup() { hc, err = asuite.dc.HTTPClient() require.NoError(t, err) - require.NoError(t, hc.LoginIntoNamespace(userid, userpassword, x.GalaxyNamespace)) + require.NoError(t, hc.LoginIntoNamespace(userid, userpassword, x.RootNamespace)) gqlQuery := ` query { @@ -2369,11 +2369,11 @@ func (asuite *AclTestSuite) TestSchemaQueryWithACL() { require.NoError(t, err) defer cleanup() require.NoError(t, gc.LoginIntoNamespace(ctx, dgraphapi.DefaultUser, - dgraphapi.DefaultPassword, x.GalaxyNamespace)) + dgraphapi.DefaultPassword, x.RootNamespace)) hc, err := asuite.dc.HTTPClient() require.NoError(t, err) - require.NoError(t, hc.LoginIntoNamespace(dgraphapi.DefaultUser, dgraphapi.DefaultPassword, x.GalaxyNamespace)) + require.NoError(t, hc.LoginIntoNamespace(dgraphapi.DefaultUser, dgraphapi.DefaultPassword, x.RootNamespace)) require.NoError(t, gc.DropAll()) resp, err := gc.Query(schemaQuery) @@ -2400,7 +2400,7 @@ func (asuite *AclTestSuite) TestSchemaQueryWithACL() { gc, cleanup, err = asuite.dc.Client() require.NoError(t, err) defer cleanup() - require.NoError(t, gc.LoginIntoNamespace(context.Background(), userid, userpassword, x.GalaxyNamespace)) + require.NoError(t, gc.LoginIntoNamespace(context.Background(), userid, userpassword, x.RootNamespace)) resp, err = gc.Query(schemaQuery) require.NoError(t, err) @@ -2416,11 +2416,11 @@ func (asuite *AclTestSuite) TestDeleteUserShouldDeleteUserFromGroup() { require.NoError(t, err) defer cleanup() require.NoError(t, gc.LoginIntoNamespace(ctx, dgraphapi.DefaultUser, - dgraphapi.DefaultPassword, x.GalaxyNamespace)) + dgraphapi.DefaultPassword, x.RootNamespace)) hc, err := asuite.dc.HTTPClient() require.NoError(t, err) - require.NoError(t, hc.LoginIntoNamespace(dgraphapi.DefaultUser, dgraphapi.DefaultPassword, x.GalaxyNamespace)) + require.NoError(t, hc.LoginIntoNamespace(dgraphapi.DefaultUser, dgraphapi.DefaultPassword, x.RootNamespace)) resetUser(t, hc) addDataAndRules(ctx, t, gc, hc) @@ -2430,7 +2430,7 @@ func (asuite *AclTestSuite) TestDeleteUserShouldDeleteUserFromGroup() { hc, err = asuite.dc.HTTPClient() require.NoError(t, err) require.NoError(t, hc.LoginIntoNamespace(dgraphapi.DefaultUser, - dgraphapi.DefaultPassword, x.GalaxyNamespace)) + dgraphapi.DefaultPassword, x.RootNamespace)) require.NoError(t, hc.DeleteUser(userid)) gqlQuery := ` @@ -2492,11 +2492,11 @@ func (asuite *AclTestSuite) TestGroupDeleteShouldDeleteGroupFromUser() { require.NoError(t, err) defer cleanup() require.NoError(t, gc.LoginIntoNamespace(ctx, dgraphapi.DefaultUser, - dgraphapi.DefaultPassword, x.GalaxyNamespace)) + dgraphapi.DefaultPassword, x.RootNamespace)) hc, err := asuite.dc.HTTPClient() require.NoError(t, err) - require.NoError(t, hc.LoginIntoNamespace(dgraphapi.DefaultUser, dgraphapi.DefaultPassword, x.GalaxyNamespace)) + require.NoError(t, hc.LoginIntoNamespace(dgraphapi.DefaultUser, dgraphapi.DefaultPassword, x.RootNamespace)) resetUser(t, hc) addDataAndRules(ctx, t, gc, hc) @@ -2506,7 +2506,7 @@ func (asuite *AclTestSuite) TestGroupDeleteShouldDeleteGroupFromUser() { hc, err = asuite.dc.HTTPClient() require.NoError(t, err) require.NoError(t, hc.LoginIntoNamespace(dgraphapi.DefaultUser, - dgraphapi.DefaultPassword, x.GalaxyNamespace)) + dgraphapi.DefaultPassword, x.RootNamespace)) require.NoError(t, hc.DeleteGroup("dev-a")) gqlQuery := ` @@ -2587,7 +2587,7 @@ func (asuite *AclTestSuite) TestAddUpdateGroupWithDuplicateRules() { hc, err := asuite.dc.HTTPClient() require.NoError(t, err) require.NoError(t, hc.LoginIntoNamespace(dgraphapi.DefaultUser, - dgraphapi.DefaultPassword, x.GalaxyNamespace)) + dgraphapi.DefaultPassword, x.RootNamespace)) groupName := "testGroup" addedRules := []dgraphapi.AclRule{ @@ -2617,7 +2617,7 @@ func (asuite *AclTestSuite) TestAddUpdateGroupWithDuplicateRules() { hc, err = asuite.dc.HTTPClient() require.NoError(t, err) require.NoError(t, hc.LoginIntoNamespace(dgraphapi.DefaultUser, - dgraphapi.DefaultPassword, x.GalaxyNamespace)) + dgraphapi.DefaultPassword, x.RootNamespace)) updatedRules := []dgraphapi.AclRule{ { Predicate: "test", @@ -2660,11 +2660,11 @@ func (asuite *AclTestSuite) TestAllowUIDAccess() { require.NoError(t, err) defer cleanup() require.NoError(t, gc.LoginIntoNamespace(ctx, dgraphapi.DefaultUser, - dgraphapi.DefaultPassword, x.GalaxyNamespace)) + dgraphapi.DefaultPassword, x.RootNamespace)) hc, err := asuite.dc.HTTPClient() require.NoError(t, err) - require.NoError(t, hc.LoginIntoNamespace(dgraphapi.DefaultUser, dgraphapi.DefaultPassword, x.GalaxyNamespace)) + require.NoError(t, hc.LoginIntoNamespace(dgraphapi.DefaultUser, dgraphapi.DefaultPassword, x.RootNamespace)) require.NoError(t, gc.DropAll()) op := api.Operation{Schema: ` @@ -2695,7 +2695,7 @@ func (asuite *AclTestSuite) TestAllowUIDAccess() { defer cleanup() time.Sleep(defaultTimeToSleep) - require.NoError(t, userClient.LoginIntoNamespace(ctx, userid, userpassword, x.GalaxyNamespace)) + require.NoError(t, userClient.LoginIntoNamespace(ctx, userid, userpassword, x.RootNamespace)) uidQuery := ` { @@ -2718,11 +2718,11 @@ func (asuite *AclTestSuite) TestAddNewPredicate() { require.NoError(t, err) defer cleanup() require.NoError(t, gc.LoginIntoNamespace(ctx, dgraphapi.DefaultUser, - dgraphapi.DefaultPassword, x.GalaxyNamespace)) + dgraphapi.DefaultPassword, x.RootNamespace)) hc, err := asuite.dc.HTTPClient() require.NoError(t, err) - require.NoError(t, hc.LoginIntoNamespace(dgraphapi.DefaultUser, dgraphapi.DefaultPassword, x.GalaxyNamespace)) + require.NoError(t, hc.LoginIntoNamespace(dgraphapi.DefaultUser, dgraphapi.DefaultPassword, x.RootNamespace)) require.NoError(t, gc.DropAll()) resetUser(t, hc) @@ -2732,11 +2732,11 @@ func (asuite *AclTestSuite) TestAddNewPredicate() { hc, err = asuite.dc.HTTPClient() require.NoError(t, err) require.NoError(t, hc.LoginIntoNamespace(dgraphapi.DefaultUser, - dgraphapi.DefaultPassword, x.GalaxyNamespace)) + dgraphapi.DefaultPassword, x.RootNamespace)) userClient, cancel, err := asuite.dc.Client() defer cleanup() require.NoError(t, err) - require.NoError(t, userClient.LoginIntoNamespace(ctx, userid, userpassword, x.GalaxyNamespace)) + require.NoError(t, userClient.LoginIntoNamespace(ctx, userid, userpassword, x.RootNamespace)) // Alice doesn't have access to create new predicate. err = userClient.Alter(ctx, &api.Operation{Schema: `newpred: string .`}) @@ -2761,12 +2761,12 @@ func (asuite *AclTestSuite) TestCrossGroupPermission() { require.NoError(t, err) defer cleanup() require.NoError(t, gc.LoginIntoNamespace(ctx, dgraphapi.DefaultUser, - dgraphapi.DefaultPassword, x.GalaxyNamespace)) + dgraphapi.DefaultPassword, x.RootNamespace)) hc, err := asuite.dc.HTTPClient() require.NoError(t, err) require.NoError(t, hc.LoginIntoNamespace(dgraphapi.DefaultUser, - dgraphapi.DefaultPassword, x.GalaxyNamespace)) + dgraphapi.DefaultPassword, x.RootNamespace)) require.NoError(t, gc.DropAll()) @@ -2791,7 +2791,7 @@ func (asuite *AclTestSuite) TestCrossGroupPermission() { time.Sleep(defaultTimeToSleep) require.NoError(t, hc.LoginIntoNamespace(dgraphapi.DefaultUser, - dgraphapi.DefaultPassword, x.GalaxyNamespace)) + dgraphapi.DefaultPassword, x.RootNamespace)) // create 8 users. for i := 0; i < 8; i++ { userIdx := strconv.Itoa(i) @@ -2862,7 +2862,7 @@ func (asuite *AclTestSuite) TestCrossGroupPermission() { defer cleanup() require.NoError(t, userClient.LoginIntoNamespace(ctx, "user"+userIdx, - "password"+userIdx, x.GalaxyNamespace), "Login error") + "password"+userIdx, x.RootNamespace), "Login error") dgQuery(userClient, false, "user"+userIdx) // Query won't fail, will return empty result instead. dgMutation(userClient, i&2 == 0, "user"+userIdx) @@ -2879,11 +2879,11 @@ func (asuite *AclTestSuite) TestMutationWithValueVar() { require.NoError(t, err) defer cleanup() require.NoError(t, gc.LoginIntoNamespace(ctx, dgraphapi.DefaultUser, - dgraphapi.DefaultPassword, x.GalaxyNamespace)) + dgraphapi.DefaultPassword, x.RootNamespace)) hc, err := asuite.dc.HTTPClient() require.NoError(t, err) - require.NoError(t, hc.LoginIntoNamespace(dgraphapi.DefaultUser, dgraphapi.DefaultPassword, x.GalaxyNamespace)) + require.NoError(t, hc.LoginIntoNamespace(dgraphapi.DefaultUser, dgraphapi.DefaultPassword, x.RootNamespace)) require.NoError(t, gc.DropAll()) err = gc.Alter(ctx, &api.Operation{ @@ -2948,7 +2948,7 @@ func (asuite *AclTestSuite) TestMutationWithValueVar() { userClient, cleanup, err := asuite.dc.Client() require.NoError(t, err) defer cleanup() - require.NoError(t, userClient.LoginIntoNamespace(ctx, userid, userpassword, x.GalaxyNamespace)) + require.NoError(t, userClient.LoginIntoNamespace(ctx, userid, userpassword, x.RootNamespace)) _, err = userClient.NewTxn().Do(ctx, &api.Request{ Query: query, @@ -2981,11 +2981,11 @@ func (asuite *AclTestSuite) TestDeleteGuardiansGroupShouldFail() { require.NoError(t, err) defer cleanup() require.NoError(t, gc.LoginIntoNamespace(ctx, dgraphapi.DefaultUser, - dgraphapi.DefaultPassword, x.GalaxyNamespace)) + dgraphapi.DefaultPassword, x.RootNamespace)) hc, err := asuite.dc.HTTPClient() require.NoError(t, err) - require.NoError(t, hc.LoginIntoNamespace(dgraphapi.DefaultUser, dgraphapi.DefaultPassword, x.GalaxyNamespace)) + require.NoError(t, hc.LoginIntoNamespace(dgraphapi.DefaultUser, dgraphapi.DefaultPassword, x.RootNamespace)) addDataAndRules(ctx, t, gc, hc) @@ -2993,7 +2993,7 @@ func (asuite *AclTestSuite) TestDeleteGuardiansGroupShouldFail() { hc, err = asuite.dc.HTTPClient() require.NoError(t, err) - require.NoError(t, hc.LoginIntoNamespace(dgraphapi.DefaultUser, dgraphapi.DefaultPassword, x.GalaxyNamespace)) + require.NoError(t, hc.LoginIntoNamespace(dgraphapi.DefaultUser, dgraphapi.DefaultPassword, x.RootNamespace)) err = hc.DeleteGroup("guardians") require.Error(t, err) @@ -3009,12 +3009,12 @@ func (asuite *AclTestSuite) TestDeleteGrootUserShouldFail() { require.NoError(t, err) defer cleanup() require.NoError(t, gc.LoginIntoNamespace(ctx, dgraphapi.DefaultUser, - dgraphapi.DefaultPassword, x.GalaxyNamespace)) + dgraphapi.DefaultPassword, x.RootNamespace)) hc, err := asuite.dc.HTTPClient() require.NoError(t, err) require.NoError(t, hc.LoginIntoNamespace(dgraphapi.DefaultUser, - dgraphapi.DefaultPassword, x.GalaxyNamespace)) + dgraphapi.DefaultPassword, x.RootNamespace)) addDataAndRules(ctx, t, gc, hc) @@ -3022,7 +3022,7 @@ func (asuite *AclTestSuite) TestDeleteGrootUserShouldFail() { hc, err = asuite.dc.HTTPClient() require.NoError(t, err) - require.NoError(t, hc.LoginIntoNamespace(dgraphapi.DefaultUser, dgraphapi.DefaultPassword, x.GalaxyNamespace)) + require.NoError(t, hc.LoginIntoNamespace(dgraphapi.DefaultUser, dgraphapi.DefaultPassword, x.RootNamespace)) err = hc.DeleteUser("groot") require.Error(t, err) @@ -3039,11 +3039,11 @@ func (asuite *AclTestSuite) TestDeleteGrootUserFromGuardiansGroupShouldFail() { require.NoError(t, err) defer cleanup() require.NoError(t, gc.LoginIntoNamespace(ctx, dgraphapi.DefaultUser, - dgraphapi.DefaultPassword, x.GalaxyNamespace)) + dgraphapi.DefaultPassword, x.RootNamespace)) hc, err := asuite.dc.HTTPClient() require.NoError(t, err) - require.NoError(t, hc.LoginIntoNamespace(dgraphapi.DefaultUser, dgraphapi.DefaultPassword, x.GalaxyNamespace)) + require.NoError(t, hc.LoginIntoNamespace(dgraphapi.DefaultUser, dgraphapi.DefaultPassword, x.RootNamespace)) addDataAndRules(ctx, t, gc, hc) @@ -3051,7 +3051,7 @@ func (asuite *AclTestSuite) TestDeleteGrootUserFromGuardiansGroupShouldFail() { hc, err = asuite.dc.HTTPClient() require.NoError(t, err) - require.NoError(t, hc.LoginIntoNamespace(dgraphapi.DefaultUser, dgraphapi.DefaultPassword, x.GalaxyNamespace)) + require.NoError(t, hc.LoginIntoNamespace(dgraphapi.DefaultUser, dgraphapi.DefaultPassword, x.RootNamespace)) err = hc.RemoveUserFromGroup("groot", "guardians") require.Error(t, err) @@ -3067,11 +3067,11 @@ func (asuite *AclTestSuite) TestDeleteGrootAndGuardiansUsingDelNQuadShouldFail() require.NoError(t, err) defer cleanup() require.NoError(t, gc.LoginIntoNamespace(ctx, dgraphapi.DefaultUser, - dgraphapi.DefaultPassword, x.GalaxyNamespace)) + dgraphapi.DefaultPassword, x.RootNamespace)) hc, err := asuite.dc.HTTPClient() require.NoError(t, err) - require.NoError(t, hc.LoginIntoNamespace(dgraphapi.DefaultUser, dgraphapi.DefaultPassword, x.GalaxyNamespace)) + require.NoError(t, hc.LoginIntoNamespace(dgraphapi.DefaultUser, dgraphapi.DefaultPassword, x.RootNamespace)) addDataAndRules(ctx, t, gc, hc) @@ -3081,7 +3081,7 @@ func (asuite *AclTestSuite) TestDeleteGrootAndGuardiansUsingDelNQuadShouldFail() require.NoError(t, err) defer cleanup() require.NoError(t, gc.LoginIntoNamespace(ctx, dgraphapi.DefaultUser, - dgraphapi.DefaultPassword, x.GalaxyNamespace)) + dgraphapi.DefaultPassword, x.RootNamespace)) grootUid, guardiansUid := getGrootAndGuardiansUid(t, gc) @@ -3118,11 +3118,11 @@ func (asuite *AclTestSuite) TestDropAllShouldResetGuardiansAndGroot() { require.NoError(t, err) defer cleanup() require.NoError(t, gc.LoginIntoNamespace(ctx, dgraphapi.DefaultUser, - dgraphapi.DefaultPassword, x.GalaxyNamespace)) + dgraphapi.DefaultPassword, x.RootNamespace)) hc, err := asuite.dc.HTTPClient() require.NoError(t, err) - require.NoError(t, hc.LoginIntoNamespace(dgraphapi.DefaultUser, dgraphapi.DefaultPassword, x.GalaxyNamespace)) + require.NoError(t, hc.LoginIntoNamespace(dgraphapi.DefaultUser, dgraphapi.DefaultPassword, x.RootNamespace)) addDataAndRules(ctx, t, gc, hc) @@ -3132,7 +3132,7 @@ func (asuite *AclTestSuite) TestDropAllShouldResetGuardiansAndGroot() { defer cleanup() require.NoError(t, err) require.NoError(t, gc.LoginIntoNamespace(ctx, dgraphapi.DefaultUser, - dgraphapi.DefaultPassword, x.GalaxyNamespace)) + dgraphapi.DefaultPassword, x.RootNamespace)) // Try Drop All op := api.Operation{ @@ -3147,7 +3147,7 @@ func (asuite *AclTestSuite) TestDropAllShouldResetGuardiansAndGroot() { hc, err = asuite.dc.HTTPClient() require.NoError(t, err) - require.NoError(t, hc.LoginIntoNamespace(dgraphapi.DefaultUser, dgraphapi.DefaultPassword, x.GalaxyNamespace)) + require.NoError(t, hc.LoginIntoNamespace(dgraphapi.DefaultUser, dgraphapi.DefaultPassword, x.RootNamespace)) deleteGuardiansGroupAndGrootUserShouldFail(t, hc) // Try Drop Data @@ -3161,6 +3161,6 @@ func (asuite *AclTestSuite) TestDropAllShouldResetGuardiansAndGroot() { hc, err = asuite.dc.HTTPClient() require.NoError(t, err) - require.NoError(t, hc.LoginIntoNamespace(dgraphapi.DefaultUser, dgraphapi.DefaultPassword, x.GalaxyNamespace)) + require.NoError(t, hc.LoginIntoNamespace(dgraphapi.DefaultUser, dgraphapi.DefaultPassword, x.RootNamespace)) deleteGuardiansGroupAndGrootUserShouldFail(t, hc) } diff --git a/acl/jwt_algo_test.go b/acl/jwt_algo_test.go index 47f4f070a41..5436455e290 100644 --- a/acl/jwt_algo_test.go +++ b/acl/jwt_algo_test.go @@ -39,7 +39,7 @@ func TestACLJwtAlgo(t *testing.T) { require.NoError(t, err) defer cleanup() require.NoError(t, gc.LoginIntoNamespace(context.Background(), - dgraphapi.DefaultUser, dgraphapi.DefaultPassword, x.GalaxyNamespace)) + dgraphapi.DefaultUser, dgraphapi.DefaultPassword, x.RootNamespace)) // op with Grpc client _, err = gc.Query(`{q(func: uid(0x1)) {uid}}`) @@ -53,7 +53,7 @@ func TestACLJwtAlgo(t *testing.T) { hc, err := c.HTTPClient() require.NoError(t, err) require.NoError(t, hc.LoginIntoNamespace(dgraphapi.DefaultUser, - dgraphapi.DefaultPassword, x.GalaxyNamespace)) + dgraphapi.DefaultPassword, x.RootNamespace)) // op with HTTP client require.NoError(t, hc.Backup(c, true, dgraphtest.DefaultBackupDir)) diff --git a/check_upgrade/check_upgrade_test.go b/check_upgrade/check_upgrade_test.go index 7b956095bbc..f09afb6453b 100644 --- a/check_upgrade/check_upgrade_test.go +++ b/check_upgrade/check_upgrade_test.go @@ -16,12 +16,13 @@ import ( "testing" "time" - "github.com/dgraph-io/dgo/v250/protos/api" "github.com/golang-jwt/jwt/v5" + "github.com/stretchr/testify/require" + + "github.com/dgraph-io/dgo/v250/protos/api" "github.com/hypermodeinc/dgraph/v25/dgraphapi" "github.com/hypermodeinc/dgraph/v25/dgraphtest" "github.com/hypermodeinc/dgraph/v25/x" - "github.com/stretchr/testify/require" ) func TestCheckUpgrade(t *testing.T) { @@ -36,14 +37,14 @@ func TestCheckUpgrade(t *testing.T) { require.NoError(t, err) defer cleanup() require.NoError(t, gc.LoginIntoNamespace(context.Background(), - dgraphapi.DefaultUser, dgraphapi.DefaultPassword, x.GalaxyNamespace)) + dgraphapi.DefaultUser, dgraphapi.DefaultPassword, x.RootNamespace)) hc, err := c.HTTPClient() require.NoError(t, err) require.NoError(t, hc.LoginIntoNamespace(dgraphapi.DefaultUser, - dgraphapi.DefaultPassword, x.GalaxyNamespace)) + dgraphapi.DefaultPassword, x.RootNamespace)) - rdfs := ` + rdfs := ` _:a "user1" . _:a "dgraph.type.User" . _:b "user1" . @@ -106,11 +107,11 @@ func TestQueryDuplicateNodes(t *testing.T) { require.NoError(t, err) defer cleanup() require.NoError(t, gc.LoginIntoNamespace(context.Background(), - dgraphapi.DefaultUser, dgraphapi.DefaultPassword, x.GalaxyNamespace)) + dgraphapi.DefaultUser, dgraphapi.DefaultPassword, x.RootNamespace)) hc, err := c.HTTPClient() require.NoError(t, err) require.NoError(t, hc.LoginIntoNamespace(dgraphapi.DefaultUser, - dgraphapi.DefaultPassword, x.GalaxyNamespace)) + dgraphapi.DefaultPassword, x.RootNamespace)) rdfs := ` <0x40> "user1" . <0x40> "dgraph.type.User" . diff --git a/chunker/json_parser.go b/chunker/json_parser.go index a188c5d65d4..6b72f33f2c0 100644 --- a/chunker/json_parser.go +++ b/chunker/json_parser.go @@ -449,7 +449,7 @@ func (buf *NQuadBuffer) mapToNquads(m map[string]interface{}, op int, parentPred mr.uid = getNextBlank() } - namespace := x.GalaxyNamespace + namespace := x.RootNamespace if ns, ok := m["namespace"]; ok { switch nsVal := ns.(type) { case json.Number: diff --git a/dgraph/cmd/alpha/http.go b/dgraph/cmd/alpha/http.go index 7b7cd32cce4..0f714832e36 100644 --- a/dgraph/cmd/alpha/http.go +++ b/dgraph/cmd/alpha/http.go @@ -737,7 +737,7 @@ func resolveWithAdminServer(gqlReq *schema.Request, r *http.Request, ctx = x.AttachAuthToken(ctx, r) ctx = x.AttachJWTNamespace(ctx) - return adminServer.ResolveWithNs(ctx, x.GalaxyNamespace, gqlReq) + return adminServer.ResolveWithNs(ctx, x.RootNamespace, gqlReq) } func writeSuccessResponse(w http.ResponseWriter, r *http.Request) { diff --git a/dgraph/cmd/alpha/run.go b/dgraph/cmd/alpha/run.go index 12bb4761cde..6984e8a21db 100644 --- a/dgraph/cmd/alpha/run.go +++ b/dgraph/cmd/alpha/run.go @@ -532,7 +532,7 @@ func setupServer(closer *z.Closer) { globalEpoch := make(map[uint64]*uint64) e := new(uint64) atomic.StoreUint64(e, 0) - globalEpoch[x.GalaxyNamespace] = e + globalEpoch[x.RootNamespace] = e var mainServer admin.IServeGraphQL var gqlHealthStore *admin.GraphQLHealthStore // Do not use := notation here because adminServer is a global variable. @@ -583,7 +583,7 @@ func setupServer(closer *z.Closer) { <-x.ServerCloser.HasBeenClosed() // TODO - Verify why do we do this and does it have to be done for all namespaces. - e = globalEpoch[x.GalaxyNamespace] + e = globalEpoch[x.RootNamespace] atomic.StoreUint64(e, math.MaxUint64) // Stops grpc/http servers; Already accepted connections are not closed. diff --git a/dgraph/cmd/alpha/run_test.go b/dgraph/cmd/alpha/run_test.go index 0f83ae3495a..9c373b0c61b 100644 --- a/dgraph/cmd/alpha/run_test.go +++ b/dgraph/cmd/alpha/run_test.go @@ -1321,7 +1321,7 @@ func TestGrpcCompressionSupport(t *testing.T) { require.NoError(t, err) dc := dgo.NewDgraphClient(api.NewDgraphClient(conn)) - require.NoError(t, dc.LoginIntoNamespace(context.Background(), x.GrootId, "password", x.GalaxyNamespace)) + require.NoError(t, dc.LoginIntoNamespace(context.Background(), x.GrootId, "password", x.RootNamespace)) q := `schema {}` tx := dc.NewTxn() _, err = tx.Query(context.Background(), q) diff --git a/dgraph/cmd/bulk/loader.go b/dgraph/cmd/bulk/loader.go index 01e05626f34..9d71cc1f602 100644 --- a/dgraph/cmd/bulk/loader.go +++ b/dgraph/cmd/bulk/loader.go @@ -334,7 +334,7 @@ func parseGqlSchema(s string) map[uint64]string { var schemas []x.ExportedGQLSchema if err := json.Unmarshal([]byte(s), &schemas); err != nil { fmt.Println("Error while decoding the graphql schema. Assuming it to be in format < 21.03.") - return map[uint64]string{x.GalaxyNamespace: s} + return map[uint64]string{x.RootNamespace: s} } schemaMap := make(map[uint64]string) diff --git a/dgraph/cmd/bulk/mapper.go b/dgraph/cmd/bulk/mapper.go index 2371d9b12db..df642daf971 100644 --- a/dgraph/cmd/bulk/mapper.go +++ b/dgraph/cmd/bulk/mapper.go @@ -230,10 +230,10 @@ func (m *mapper) run(inputFormat chunker.InputFormat) { } } aclOnce.Do(func() { - if m.opt.Namespace != math.MaxUint64 && m.opt.Namespace != x.GalaxyNamespace { + if m.opt.Namespace != math.MaxUint64 && m.opt.Namespace != x.RootNamespace { // Insert ACL related RDFs force uploading the data into non-galaxy namespace. aclNquads := make([]*api.NQuad, 0) - aclNquads = append(aclNquads, acl.CreateGroupNQuads(x.GuardiansId)...) + aclNquads = append(aclNquads, acl.CreateGroupNQuads(x.SuperAdminId)...) aclNquads = append(aclNquads, acl.CreateUserNQuads(x.GrootId, "password")...) aclNquads = append(aclNquads, &api.NQuad{ Subject: "_:newuser", diff --git a/dgraph/cmd/bulk/schema.go b/dgraph/cmd/bulk/schema.go index a40dc37dff9..1c45c871179 100644 --- a/dgraph/cmd/bulk/schema.go +++ b/dgraph/cmd/bulk/schema.go @@ -40,7 +40,7 @@ func newSchemaStore(initial *schema.ParsedSchema, opt *options, state *state) *s // Initialize only for the default namespace. Initialization for other namespaces will be done // whenever we see data for a new namespace. - s.checkAndSetInitialSchema(x.GalaxyNamespace) + s.checkAndSetInitialSchema(x.RootNamespace) s.types = initial.Types // This is from the schema read from the schema file. diff --git a/dgraph/cmd/debug/run.go b/dgraph/cmd/debug/run.go index e9b05481802..e7007fb9234 100644 --- a/dgraph/cmd/debug/run.go +++ b/dgraph/cmd/debug/run.go @@ -901,7 +901,7 @@ func printSummary(db *badger.DB) { // Some of the keys are badger's internal and couldn't be parsed. // Hence, the error is expected in that case. fmt.Printf("Unable to parse key: %#x\n", key) - return x.GalaxyNamespace + return x.RootNamespace } return x.ParseNamespace(pk.Attr) } diff --git a/dgraph/cmd/live/run.go b/dgraph/cmd/live/run.go index 3885c383606..79c175ffda5 100644 --- a/dgraph/cmd/live/run.go +++ b/dgraph/cmd/live/run.go @@ -169,7 +169,7 @@ func init() { "be used to store blank nodes as an xid") flag.String("tmp", "t", "Directory to store temporary buffers.") flag.Int64("force-namespace", 0, "Namespace onto which to load the data."+ - "Only guardian of galaxy should use this for loading data into multiple namespaces or some"+ + "Only superadmin should use this for loading data into multiple namespaces or some"+ "specific namespace. Setting it to negative value will preserve the namespace.") } @@ -719,7 +719,7 @@ func run() error { forceNs := Live.Conf.GetInt64("force-namespace") switch creds.GetUint64("namespace") { - case x.GalaxyNamespace: + case x.RootNamespace: if forceNs < 0 { opt.preserveNs = true opt.namespaceToLoad = math.MaxUint64 @@ -729,7 +729,7 @@ func run() error { default: if Live.Conf.IsSet("force-namespace") { return errors.Errorf("cannot force namespace %#x when provided creds are not of"+ - " guardian of galaxy user", forceNs) + " superadmin user", forceNs) } opt.namespaceToLoad = creds.GetUint64("namespace") } @@ -745,16 +745,16 @@ func run() error { // singleNsOp is set to false, when loading data into a namespace different from the one user // provided credentials for. singleNsOp := true - if len(creds.GetString("user")) > 0 && creds.GetUint64("namespace") == x.GalaxyNamespace && - opt.namespaceToLoad != x.GalaxyNamespace { + if len(creds.GetString("user")) > 0 && creds.GetUint64("namespace") == x.RootNamespace && + opt.namespaceToLoad != x.RootNamespace { singleNsOp = false } - galaxyOperation := false + rootNsOperation := false if !singleNsOp { - // Attach the galaxy to the context to specify that the query/mutations with this context - // will be galaxy-wide. - galaxyOperation = true - ctx = x.AttachGalaxyOperation(ctx, opt.namespaceToLoad) + // Attach the root namespace to the context to specify that the query/mutations with this context + // will be root namespace wide. + rootNsOperation = true + ctx = x.AttachRootNsOperation(ctx, opt.namespaceToLoad) // We don't support upsert predicate while loading data in multiple namespace. if len(opt.upsertPredicate) > 0 { return errors.Errorf("Upsert Predicate feature is not supported for loading" + @@ -805,7 +805,7 @@ func run() error { fmt.Printf("Processed schema file %q\n\n", opt.schemaFile) } - if l.schema, err = getSchema(ctx, dg, galaxyOperation); err != nil { + if l.schema, err = getSchema(ctx, dg, rootNsOperation); err != nil { fmt.Printf("Error while loading schema from alpha %s\n", err) return err } diff --git a/dgraph/cmd/zero/assign.go b/dgraph/cmd/zero/assign.go index 20b85f78c1d..ac527fd7097 100644 --- a/dgraph/cmd/zero/assign.go +++ b/dgraph/cmd/zero/assign.go @@ -189,8 +189,8 @@ func (s *Server) AssignIds(ctx context.Context, num *pb.Num) (*pb.AssignedIds, e return nil } ns, err := x.ExtractNamespace(ctx) - if err != nil || ns == x.GalaxyNamespace { - // There is no rate limiting for GalaxyNamespace. Also, we allow the requests which do + if err != nil || ns == x.RootNamespace { + // There is no rate limiting for RootNamespace. Also, we allow the requests which do // not contain namespace into context. return nil } diff --git a/dgraph/cmd/zero/http.go b/dgraph/cmd/zero/http.go index 20c132f2c99..0223747c447 100644 --- a/dgraph/cmd/zero/http.go +++ b/dgraph/cmd/zero/http.go @@ -158,7 +158,7 @@ func (st *state) moveTablet(w http.ResponseWriter, r *http.Request) { namespace := r.URL.Query().Get("namespace") namespace = strings.TrimSpace(namespace) - ns := x.GalaxyNamespace + ns := x.RootNamespace if namespace != "" { var err error if ns, err = strconv.ParseUint(namespace, 0, 64); err != nil { diff --git a/dgraph/cmd/zero/zero.go b/dgraph/cmd/zero/zero.go index 754cb433bc8..806f3acea3d 100644 --- a/dgraph/cmd/zero/zero.go +++ b/dgraph/cmd/zero/zero.go @@ -99,7 +99,7 @@ func (s *Server) Init() { } func (s *Server) periodicallyPostTelemetry() { - const scarfBaseUrlFmt = "https://hypermode.gateway.scarf.sh/dgraph-deployments/%v/%v/%v/%v/%v" + const scarfBaseUrlFmt = "https://events.hypermode.com/dgraph-deployments/%v/%v/%v/%v/%v" // sleep so that a leader is elected by this time time.Sleep(time.Minute) diff --git a/dgraphtest/load.go b/dgraphtest/load.go index 68ab2cf5728..f319794ce88 100644 --- a/dgraphtest/load.go +++ b/dgraphtest/load.go @@ -128,7 +128,7 @@ func setDQLSchema(c *LocalCluster, files []string) error { if c.conf.acl { ctx, cancel := context.WithTimeout(context.Background(), requestTimeout) defer cancel() - err := gc.LoginIntoNamespace(ctx, dgraphapi.DefaultUser, dgraphapi.DefaultPassword, x.GalaxyNamespace) + err := gc.LoginIntoNamespace(ctx, dgraphapi.DefaultUser, dgraphapi.DefaultPassword, x.RootNamespace) if err != nil { return errors.Wrap(err, "error login to default namespace") } @@ -223,7 +223,7 @@ func (c *LocalCluster) LiveLoad(opts LiveOpts) error { } if c.conf.acl { args = append(args, fmt.Sprintf("--creds=user=%s;password=%s;namespace=%d", - dgraphapi.DefaultUser, dgraphapi.DefaultPassword, x.GalaxyNamespace)) + dgraphapi.DefaultUser, dgraphapi.DefaultPassword, x.RootNamespace)) } if c.conf.encryption { args = append(args, fmt.Sprintf("--encryption=key-file=%v", c.encKeyPath)) @@ -251,7 +251,7 @@ func findGrootAndGuardians(c *LocalCluster) (string, string, error) { if c.conf.acl { ctx, cancel := context.WithTimeout(context.Background(), requestTimeout) defer cancel() - err = gc.LoginIntoNamespace(ctx, dgraphapi.DefaultUser, dgraphapi.DefaultPassword, x.GalaxyNamespace) + err = gc.LoginIntoNamespace(ctx, dgraphapi.DefaultUser, dgraphapi.DefaultPassword, x.RootNamespace) if err != nil { return "", "", errors.Wrapf(err, "error logging in as groot") } diff --git a/dgraphtest/local_cluster.go b/dgraphtest/local_cluster.go index b8575782da9..06f8c60b110 100644 --- a/dgraphtest/local_cluster.go +++ b/dgraphtest/local_cluster.go @@ -616,7 +616,7 @@ func (c *LocalCluster) waitUntilGraphqlHealthCheck() error { return errors.Wrap(err, "error creating http client while graphql health check") } if c.conf.acl { - if err := hc.LoginIntoNamespace(dgraphapi.DefaultUser, dgraphapi.DefaultPassword, x.GalaxyNamespace); err != nil { + if err := hc.LoginIntoNamespace(dgraphapi.DefaultUser, dgraphapi.DefaultPassword, x.RootNamespace); err != nil { return errors.Wrap(err, "error during login while graphql health check") } } @@ -654,7 +654,7 @@ func (c *LocalCluster) Upgrade(version string, strategy UpgradeStrategy) error { return err } if c.conf.acl { - if err := hc.LoginIntoNamespace(dgraphapi.DefaultUser, dgraphapi.DefaultPassword, x.GalaxyNamespace); err != nil { + if err := hc.LoginIntoNamespace(dgraphapi.DefaultUser, dgraphapi.DefaultPassword, x.RootNamespace); err != nil { return errors.Wrapf(err, "error during login before upgrade") } } @@ -677,7 +677,7 @@ func (c *LocalCluster) Upgrade(version string, strategy UpgradeStrategy) error { return errors.Wrapf(err, "error creating HTTP client after upgrade") } if c.conf.acl { - if err := hc.LoginIntoNamespace(dgraphapi.DefaultUser, dgraphapi.DefaultPassword, x.GalaxyNamespace); err != nil { + if err := hc.LoginIntoNamespace(dgraphapi.DefaultUser, dgraphapi.DefaultPassword, x.RootNamespace); err != nil { return errors.Wrapf(err, "error during login after upgrade") } } @@ -695,7 +695,7 @@ func (c *LocalCluster) Upgrade(version string, strategy UpgradeStrategy) error { return err } if c.conf.acl { - if err := hc.LoginIntoNamespace(dgraphapi.DefaultUser, dgraphapi.DefaultPassword, x.GalaxyNamespace); err != nil { + if err := hc.LoginIntoNamespace(dgraphapi.DefaultUser, dgraphapi.DefaultPassword, x.RootNamespace); err != nil { return errors.Wrapf(err, "error during login before upgrade") } } diff --git a/edgraph/access.go b/edgraph/access.go index 81f8099f577..5584435572f 100644 --- a/edgraph/access.go +++ b/edgraph/access.go @@ -405,12 +405,12 @@ const queryAcls = ` ` var aclPrefixes = [][]byte{ - x.PredicatePrefix(x.GalaxyAttr("dgraph.rule.permission")), - x.PredicatePrefix(x.GalaxyAttr("dgraph.rule.predicate")), - x.PredicatePrefix(x.GalaxyAttr("dgraph.acl.rule")), - x.PredicatePrefix(x.GalaxyAttr("dgraph.user.group")), - x.PredicatePrefix(x.GalaxyAttr("dgraph.type.Group")), - x.PredicatePrefix(x.GalaxyAttr("dgraph.xid")), + x.PredicatePrefix(x.AttrInRootNamespace("dgraph.rule.permission")), + x.PredicatePrefix(x.AttrInRootNamespace("dgraph.rule.predicate")), + x.PredicatePrefix(x.AttrInRootNamespace("dgraph.acl.rule")), + x.PredicatePrefix(x.AttrInRootNamespace("dgraph.user.group")), + x.PredicatePrefix(x.AttrInRootNamespace("dgraph.type.Group")), + x.PredicatePrefix(x.AttrInRootNamespace("dgraph.xid")), } // upserts the Groot account. @@ -424,7 +424,7 @@ func InitializeAcl(closer *z.Closer) { // The acl feature is not turned on. return } - upsertGuardianAndGroot(closer, x.GalaxyNamespace) + upsertGuardianAndGroot(closer, x.RootNamespace) } // Note: The handling of closer should be done by caller. @@ -466,8 +466,8 @@ func upsertGuardian(ctx context.Context) error { uid } } - `, x.GuardiansId) - groupNQuads := acl.CreateGroupNQuads(x.GuardiansId) + `, x.SuperAdminId) + groupNQuads := acl.CreateGroupNQuads(x.SuperAdminId) req := &Request{ req: &api.Request{ CommitNow: true, @@ -494,7 +494,7 @@ func upsertGuardian(ctx context.Context) error { } if err != nil { - return errors.Wrapf(err, "while upserting group with id %s", x.GuardiansId) + return errors.Wrapf(err, "while upserting group with id %s", x.SuperAdminId) } var groupResp groupQryResp var guardiansUidStr string @@ -520,9 +520,9 @@ func upsertGuardian(ctx context.Context) error { } ns, err := x.ExtractNamespace(ctx) if err != nil { - return errors.Wrapf(err, "While upserting group with id %s", x.GuardiansId) + return errors.Wrapf(err, "While upserting group with id %s", x.SuperAdminId) } - x.GuardiansUid.Store(ns, uid) + x.SuperAdminUid.Store(ns, uid) glog.V(2).Infof("Successfully upserted the guardian of namespace: %d\n", ns) return nil } @@ -537,7 +537,7 @@ func upsertGroot(ctx context.Context, passwd string) error { } guid as var(func: eq(dgraph.xid, "%s")) @filter(type(dgraph.type.Group)) } - `, x.GrootId, x.GuardiansId) + `, x.GrootId, x.SuperAdminId) userNQuads := acl.CreateUserNQuads(x.GrootId, passwd) userNQuads = append(userNQuads, &api.NQuad{ Subject: "_:newuser", @@ -698,7 +698,7 @@ func authorizeAlter(ctx context.Context, op *api.Operation) error { userId = userData.userId groupIds = userData.groupIds - if x.IsGuardian(groupIds) { + if x.IsSuperAdmin(groupIds) { // Members of guardian group are allowed to alter anything. return nil } @@ -809,7 +809,7 @@ func authorizeMutation(ctx context.Context, gmu *dql.Mutation) error { userId = userData.userId groupIds = userData.groupIds - if x.IsGuardian(groupIds) { + if x.IsSuperAdmin(groupIds) { // Members of guardians group are allowed to mutate anything // (including delete) except the permission of the acl predicates. switch { @@ -948,7 +948,7 @@ func blockedPreds(preds []string) map[string]struct{} { // With shared instance enabled, we don't allow ACL operations from any of the non-galaxy namespace. func shouldAllowAcls(ns uint64) bool { - return !x.Config.SharedInstance || ns == x.GalaxyNamespace + return !x.Config.SharedInstance || ns == x.RootNamespace } // authorizeQuery authorizes the query using the aclCachePtr. It will silently drop all @@ -984,7 +984,7 @@ func authorizeQuery(ctx context.Context, parsedReq *dql.Result, graphql bool) er groupIds = userData.groupIds namespace = userData.namespace - if x.IsGuardian(groupIds) { + if x.IsSuperAdmin(groupIds) { if shouldAllowAcls(userData.namespace) { // Members of guardian groups are allowed to query anything. return nil, nil, nil @@ -1074,7 +1074,7 @@ func authorizeSchemaQuery(ctx context.Context, er *query.ExecutionResult) error } groupIds := userData.groupIds - if x.IsGuardian(groupIds) { + if x.IsSuperAdmin(groupIds) { if shouldAllowAcls(userData.namespace) { // Members of guardian groups are allowed to query anything. return nil, nil @@ -1115,11 +1115,11 @@ func authorizeSchemaQuery(ctx context.Context, er *query.ExecutionResult) error return nil } -// AuthGuardianOfTheGalaxy authorizes the operations for the users who belong to the guardians +// AuthSuperAdmin authorizes the operations for the users who belong to the guardians // group in the galaxy namespace. This authorization is used for admin usages like creation and // deletion of a namespace, resetting passwords across namespaces etc. // NOTE: The caller should not wrap the error returned. If needed, propagate the GRPC error code. -func AuthGuardianOfTheGalaxy(ctx context.Context) error { +func AuthSuperAdmin(ctx context.Context) error { if !x.WorkerConfig.AclEnabled { return nil } @@ -1129,14 +1129,14 @@ func AuthGuardianOfTheGalaxy(ctx context.Context) error { } if ns != 0 { return status.Error( - codes.PermissionDenied, "Only guardian of galaxy is allowed to do this operation") + codes.PermissionDenied, "Only superadmin is allowed to do this operation") } // AuthorizeGuardians will extract (user, []groups) from the JWT claims and will check if // any of the group to which the user belongs is "guardians" or not. if err := AuthorizeGuardians(ctx); err != nil { s := status.Convert(err) return status.Error( - s.Code(), "AuthGuardianOfTheGalaxy: failed to authorize guardians. "+s.Message()) + s.Code(), "AuthSuperAdmin: failed to authorize guardians. "+s.Message()) } glog.V(3).Info("Successfully authorised guardian of the galaxy") return nil @@ -1160,7 +1160,7 @@ func AuthorizeGuardians(ctx context.Context) error { userId := userData.userId groupIds := userData.groupIds - if !x.IsGuardian(groupIds) { + if !x.IsSuperAdmin(groupIds) { // Deny access for members of non-guardian groups return status.Error(codes.PermissionDenied, fmt.Sprintf("Only guardians are "+ "allowed access. User '%v' is not a member of guardians group.", userId)) diff --git a/edgraph/alter.go b/edgraph/alter.go index 13fbca3c332..6801549a01d 100644 --- a/edgraph/alter.go +++ b/edgraph/alter.go @@ -260,7 +260,7 @@ func (s *ServerV25) Alter(ctx context.Context, req *apiv25.AlterRequest) (*apiv2 defer glog.Infof("ALTER op: %+v done", req) // For now, we only allow guadian of galaxies to do this operation in v25 - if err := AuthGuardianOfTheGalaxy(ctx); err != nil { + if err := AuthSuperAdmin(ctx); err != nil { s := status.Convert(err) return nil, status.Error(s.Code(), "v25.Alter can only be called by the guardian of the galaxy. "+s.Message()) diff --git a/edgraph/multi_tenancy.go b/edgraph/multi_tenancy.go index dc200437b00..0936c3ed8d8 100644 --- a/edgraph/multi_tenancy.go +++ b/edgraph/multi_tenancy.go @@ -80,7 +80,7 @@ func (s *Server) ResetPassword(ctx context.Context, inp *ResetPasswordInput) err return nil } -// CreateNamespaceInternal creates a new namespace. Only guardian of galaxy is authorized to do so. +// CreateNamespaceInternal creates a new namespace. Only superadmin is authorized to do so. // Authorization is handled by middlewares. func (s *Server) CreateNamespaceInternal(ctx context.Context, passwd string) (uint64, error) { glog.V(2).Info("Got create namespace request.") @@ -126,7 +126,7 @@ func createGuardianAndGroot(ctx context.Context, namespace uint64, passwd string return nil } -// DeleteNamespace deletes a new namespace. Only guardian of galaxy is authorized to do so. +// DeleteNamespace deletes a new namespace. Only superadmin is authorized to do so. // Authorization is handled by middlewares. func (s *Server) DeleteNamespace(ctx context.Context, namespace uint64) error { glog.Info("Deleting namespace", namespace) diff --git a/edgraph/namespace.go b/edgraph/namespace.go index 0cd4e93e38a..2ee71d88ede 100644 --- a/edgraph/namespace.go +++ b/edgraph/namespace.go @@ -79,10 +79,10 @@ func (s *ServerV25) SignInUser(ctx context.Context, func (s *ServerV25) CreateNamespace(ctx context.Context, in *apiv25.CreateNamespaceRequest) ( *apiv25.CreateNamespaceResponse, error) { - if err := AuthGuardianOfTheGalaxy(ctx); err != nil { + if err := AuthSuperAdmin(ctx); err != nil { s := status.Convert(err) return nil, status.Error(s.Code(), - "Non guardian of galaxy user cannot create namespace. "+s.Message()) + "Non superadmin user cannot create namespace. "+s.Message()) } if err := isValidNamespaceName(in.NsName); err != nil { @@ -118,10 +118,10 @@ func (s *ServerV25) CreateNamespace(ctx context.Context, in *apiv25.CreateNamesp func (s *ServerV25) DropNamespace(ctx context.Context, in *apiv25.DropNamespaceRequest) ( *apiv25.DropNamespaceResponse, error) { - if err := AuthGuardianOfTheGalaxy(ctx); err != nil { + if err := AuthSuperAdmin(ctx); err != nil { s := status.Convert(err) return nil, status.Error(s.Code(), - "Non guardian of galaxy user cannot drop namespace. "+s.Message()) + "Non superadmin user cannot drop namespace. "+s.Message()) } if err := isValidNamespaceToDelete(in.NsName); err != nil { @@ -173,10 +173,10 @@ func (s *ServerV25) DropNamespace(ctx context.Context, in *apiv25.DropNamespaceR func (s *ServerV25) UpdateNamespace(ctx context.Context, in *apiv25.UpdateNamespaceRequest) ( *apiv25.UpdateNamespaceResponse, error) { - if err := AuthGuardianOfTheGalaxy(ctx); err != nil { + if err := AuthSuperAdmin(ctx); err != nil { s := status.Convert(err) return nil, status.Error(s.Code(), - "Non guardian of galaxy user cannot rename a namespace. "+s.Message()) + "Non superadmin user cannot rename a namespace. "+s.Message()) } if err := isValidNamespaceToDelete(in.NsName); err != nil { @@ -202,10 +202,10 @@ func (s *ServerV25) UpdateNamespace(ctx context.Context, in *apiv25.UpdateNamesp func (s *ServerV25) ListNamespaces(ctx context.Context, in *apiv25.ListNamespacesRequest) ( *apiv25.ListNamespacesResponse, error) { - if err := AuthGuardianOfTheGalaxy(ctx); err != nil { + if err := AuthSuperAdmin(ctx); err != nil { s := status.Convert(err) return nil, status.Error(s.Code(), - "Non guardian of galaxy user cannot list namespaces. "+s.Message()) + "Non superadmin user cannot list namespaces. "+s.Message()) } resp, err := (&Server{}).doQuery(x.AttachJWTNamespace(ctx), diff --git a/edgraph/namespace_test.go b/edgraph/namespace_test.go index c9b8b3142ba..146912d2caf 100644 --- a/edgraph/namespace_test.go +++ b/edgraph/namespace_test.go @@ -88,7 +88,7 @@ func TestNamespacesPreV25(t *testing.T) { hc, err := dc.HTTPClient() require.NoError(t, err) require.NoError(t, hc.LoginIntoNamespace(dgraphapi.DefaultUser, - dgraphapi.DefaultPassword, x.GalaxyNamespace)) + dgraphapi.DefaultPassword, x.RootNamespace)) // Drop all data require.NoError(t, client.Login(context.Background(), @@ -190,7 +190,7 @@ func TestCreateNamespaceErr(t *testing.T) { // require.NoError(t, client.LoginToNamespace(ctx, // "ns1", dgraphapi.DefaultUser, dgraphapi.DefaultPassword)) // require.ErrorContains(t, client.CreateNamespace(ctx, "ns2"), - // "Non guardian of galaxy user cannot create namespace") + // "Non superadmin user cannot create namespace") } func TestDropNamespaceErr(t *testing.T) { @@ -240,7 +240,7 @@ func TestDropNamespaceErr(t *testing.T) { // require.NoError(t, client.LoginToNamespace(ctx, // "ns1", dgraphapi.DefaultUser, dgraphapi.DefaultPassword)) // require.ErrorContains(t, client.DropNamespace(ctx, "ns1"), - // `Only guardian of galaxy is allowed to do this operation`) + // `Only superadmin is allowed to do this operation`) } func TestRenameNamespaceErr(t *testing.T) { @@ -306,5 +306,5 @@ func TestListNamespacesErr(t *testing.T) { // require.NoError(t, client.LoginToNamespace(ctx, // "ns1", dgraphapi.DefaultUser, dgraphapi.DefaultPassword)) // _, err = client.ListNamespaces(ctx) - // require.ErrorContains(t, err, "Only guardian of galaxy is allowed to do this operation") + // require.ErrorContains(t, err, "Only superadmin is allowed to do this operation") } diff --git a/edgraph/query.go b/edgraph/query.go index 91c4a2c97e7..069ea70f0cc 100644 --- a/edgraph/query.go +++ b/edgraph/query.go @@ -28,7 +28,7 @@ func (s *ServerV25) Ping(ctx context.Context, req *apiv25.PingRequest) (*apiv25. // Alter handles requests to change the schema or remove parts or all of the data. func (s *ServerV25) RunDQL(ctx context.Context, req *apiv25.RunDQLRequest) (*apiv25.RunDQLResponse, error) { // For now, we only allow guardian of galaxies to do this operation in v25 - if err := AuthGuardianOfTheGalaxy(ctx); err != nil { + if err := AuthSuperAdmin(ctx); err != nil { s := status.Convert(err) return nil, status.Error(s.Code(), "v25.RunDQL can only be called by the guardian of the galaxy. "+s.Message()) diff --git a/edgraph/server.go b/edgraph/server.go index bc6e3c691b5..ba9def927ee 100644 --- a/edgraph/server.go +++ b/edgraph/server.go @@ -167,7 +167,7 @@ func UpdateGQLSchema(ctx context.Context, gqlSchema, parsedDgraphSchema := &schema.ParsedSchema{} if !x.WorkerConfig.AclEnabled { - ctx = x.AttachNamespace(ctx, x.GalaxyNamespace) + ctx = x.AttachNamespace(ctx, x.RootNamespace) } // The schema could be empty if it only has custom types/queries/mutations. if dgraphSchema != "" { @@ -236,13 +236,13 @@ func parseSchemaFromAlterOperation(ctx context.Context, sch string) ( return nil, errors.Wrapf(err, "While parsing schema") } - if x.IsGalaxyOperation(ctx) { + if x.IsRootNsOperation(ctx) { // Only the guardian of the galaxy can do a galaxy wide query/mutation. This operation is // needed by live loader. - if err := AuthGuardianOfTheGalaxy(ctx); err != nil { + if err := AuthSuperAdmin(ctx); err != nil { s := status.Convert(err) return nil, status.Error(s.Code(), - "Non guardian of galaxy user cannot bypass namespaces. "+s.Message()) + "Non superadmin user cannot bypass namespaces. "+s.Message()) } var err error namespace, err = strconv.ParseUint(x.GetForceNamespace(ctx), 0, 64) @@ -365,7 +365,7 @@ func (s *Server) Alter(ctx context.Context, op *api.Operation) (*api.Payload, er glog.V(2).Info("Blocked drop-all because it is not permitted.") return empty, errors.New("Drop all operation is not permitted.") } - if err := AuthGuardianOfTheGalaxy(ctx); err != nil { + if err := AuthSuperAdmin(ctx); err != nil { s := status.Convert(err) return empty, status.Error(s.Code(), "Drop all can only be called by the guardian of the galaxy. "+s.Message()) @@ -1110,7 +1110,7 @@ func filterTablets(ctx context.Context, ms *pb.MembershipState) error { if err != nil { return errors.Errorf("Namespace not found in JWT.") } - if namespace == x.GalaxyNamespace { + if namespace == x.RootNamespace { // For galaxy namespace, we don't want to filter out the predicates. return nil } @@ -1300,13 +1300,13 @@ func (s *Server) doQuery(ctx context.Context, req *Request) (resp *api.Response, ostats.Record(ctx, x.NumMutations.M(1)) } - if req.doAuth == NeedAuthorize && x.IsGalaxyOperation(ctx) { + if req.doAuth == NeedAuthorize && x.IsRootNsOperation(ctx) { // Only the guardian of the galaxy can do a galaxy wide query/mutation. This operation is // needed by live loader. - if err := AuthGuardianOfTheGalaxy(ctx); err != nil { + if err := AuthSuperAdmin(ctx); err != nil { s := status.Convert(err) return nil, status.Error(s.Code(), - "Non guardian of galaxy user cannot bypass namespaces. "+s.Message()) + "Non superadmin user cannot bypass namespaces. "+s.Message()) } } @@ -1685,7 +1685,7 @@ func addQueryIfUnique(qctx context.Context, qc *queryContext) error { glog.Errorf("Error while extracting namespace, assuming default %s", err) namespace = 0 } - isGalaxyQuery := x.IsGalaxyOperation(ctx) + isGalaxyQuery := x.IsRootNsOperation(ctx) qc.uniqueVars = map[uint64]uniquePredMeta{} for gmuIndex, gmu := range qc.gmuList { diff --git a/graphql/admin/admin.go b/graphql/admin/admin.go index 6d3749eee3d..165b1d91be9 100644 --- a/graphql/admin/admin.go +++ b/graphql/admin/admin.go @@ -435,21 +435,21 @@ const ( var ( // gogQryMWs are the middlewares which should be applied to queries served by - // admin server for guardian of galaxy unless some exceptional behaviour is required + // admin server for superadmin unless some exceptional behaviour is required gogQryMWs = resolve.QueryMiddlewares{ resolve.IpWhitelistingMW4Query, resolve.GuardianOfTheGalaxyAuthMW4Query, resolve.LoggingMWQuery, } // gogMutMWs are the middlewares which should be applied to mutations - // served by admin server for guardian of galaxy unless some exceptional behaviour is required + // served by admin server for superadmin unless some exceptional behaviour is required gogMutMWs = resolve.MutationMiddlewares{ resolve.IpWhitelistingMW4Mutation, resolve.GuardianOfTheGalaxyAuthMW4Mutation, resolve.LoggingMWMutation, } // gogAclMutMWs are the middlewares which should be applied to mutations - // served by the admin server for guardian of galaxy with ACL enabled. + // served by the admin server for superadmin with ACL enabled. gogAclMutMWs = resolve.MutationMiddlewares{ resolve.IpWhitelistingMW4Mutation, resolve.AclOnlyMW4Mutation, @@ -500,7 +500,7 @@ var ( "backup": gogMutMWs, "config": gogMutMWs, "draining": gogMutMWs, - "export": stdAdminMutMWs, // dgraph handles the export for other namespaces by guardian of galaxy + "export": stdAdminMutMWs, // dgraph handles the export for other namespaces by superadmin "login": minimalAdminMutMWs, "restore": gogMutMWs, "shutdown": gogMutMWs, @@ -532,7 +532,7 @@ func SchemaValidate(sch string) error { return err } - _, err = schema.FromString(schHandler.GQLSchema(), x.GalaxyNamespace) + _, err = schema.FromString(schHandler.GQLSchema(), x.RootNamespace) return err } @@ -586,15 +586,15 @@ type adminServer struct { // main /graphql endpoint and an admin server. The result is mainServer, adminServer. func NewServers(withIntrospection bool, globalEpoch map[uint64]*uint64, closer *z.Closer) (IServeGraphQL, IServeGraphQL, *GraphQLHealthStore) { - gqlSchema, err := schema.FromString("", x.GalaxyNamespace) + gqlSchema, err := schema.FromString("", x.RootNamespace) if err != nil { x.Panic(err) } resolvers := resolve.New(gqlSchema, resolverFactoryWithErrorMsg(errNoGraphQLSchema)) - e := globalEpoch[x.GalaxyNamespace] + e := globalEpoch[x.RootNamespace] mainServer := NewServer() - mainServer.Set(x.GalaxyNamespace, e, resolvers) + mainServer.Set(x.RootNamespace, e, resolvers) fns := &resolve.ResolverFns{ Qrw: resolve.NewQueryRewriter(), @@ -604,9 +604,9 @@ func NewServers(withIntrospection bool, globalEpoch map[uint64]*uint64, Ex: resolve.NewDgraphExecutor(), } adminResolvers := newAdminResolver(mainServer, fns, withIntrospection, globalEpoch, closer) - e = globalEpoch[x.GalaxyNamespace] + e = globalEpoch[x.RootNamespace] adminServer := NewServer() - adminServer.Set(x.GalaxyNamespace, e, adminResolvers) + adminServer.Set(x.RootNamespace, e, adminResolvers) return mainServer, adminServer, mainHealthStore } @@ -619,7 +619,7 @@ func newAdminResolver( epoch map[uint64]*uint64, closer *z.Closer) *resolve.RequestResolver { - adminSchema, err := schema.FromString(graphqlAdminSchema, x.GalaxyNamespace) + adminSchema, err := schema.FromString(graphqlAdminSchema, x.RootNamespace) if err != nil { x.Panic(err) } @@ -637,7 +637,7 @@ func newAdminResolver( } adminServerVar = server // store the admin server in package variable - prefix := x.DataKey(x.GalaxyAttr(worker.GqlSchemaPred), 0) + prefix := x.DataKey(x.AttrInRootNamespace(worker.GqlSchemaPred), 0) // Remove uid from the key, to get the correct prefix prefix = prefix[:len(prefix)-8] // Listen for graphql schema changes in group 1. @@ -830,13 +830,13 @@ func (as *adminServer) initServer() { for { <-time.After(waitFor) - sch, err := getCurrentGraphQLSchema(x.GalaxyNamespace) + sch, err := getCurrentGraphQLSchema(x.RootNamespace) if err != nil { - glog.Errorf("namespace: %d. Error reading GraphQL schema: %s.", x.GalaxyNamespace, err) + glog.Errorf("namespace: %d. Error reading GraphQL schema: %s.", x.RootNamespace, err) continue } sch.Loaded = true - as.gqlSchemas.Set(x.GalaxyNamespace, sch) + as.gqlSchemas.Set(x.RootNamespace, sch) // adding the actual resolvers for updateGQLSchema and getGQLSchema only after server has // current GraphQL schema, if there was any. as.addConnectedAdminResolvers() @@ -844,21 +844,21 @@ func (as *adminServer) initServer() { if sch.Schema == "" { glog.Infof("namespace: %d. No GraphQL schema in Dgraph; serving empty GraphQL API", - x.GalaxyNamespace) + x.RootNamespace) break } - generatedSchema, err := generateGQLSchema(sch, x.GalaxyNamespace) + generatedSchema, err := generateGQLSchema(sch, x.RootNamespace) if err != nil { glog.Errorf("namespace: %d. Error processing GraphQL schema: %s.", - x.GalaxyNamespace, err) + x.RootNamespace, err) break } - as.incrementSchemaUpdateCounter(x.GalaxyNamespace) - as.resetSchema(x.GalaxyNamespace, generatedSchema) + as.incrementSchemaUpdateCounter(x.RootNamespace) + as.resetSchema(x.RootNamespace, generatedSchema) glog.Infof("namespace: %d. Successfully loaded GraphQL schema. Serving GraphQL API.", - x.GalaxyNamespace) + x.RootNamespace) break } diff --git a/graphql/admin/export.go b/graphql/admin/export.go index 687ec899e18..1ba25d5d120 100644 --- a/graphql/admin/export.go +++ b/graphql/admin/export.go @@ -55,7 +55,7 @@ func resolveExport(ctx context.Context, m schema.Mutation) (*resolve.Resolved, b return ns, nil } switch ns { - case x.GalaxyNamespace: + case x.RootNamespace: if input.Namespace < 0 { // export all namespaces. return math.MaxUint64, nil } diff --git a/graphql/admin/moveTablet.go b/graphql/admin/moveTablet.go index deacfd15aea..558ddbb322f 100644 --- a/graphql/admin/moveTablet.go +++ b/graphql/admin/moveTablet.go @@ -54,7 +54,7 @@ func getMoveTabletInput(m schema.Mutation) (*moveTabletInput, error) { inputRef := &moveTabletInput{} // namespace is an optional parameter if _, ok = inputArg["namespace"]; !ok { - inputRef.Namespace = x.GalaxyNamespace + inputRef.Namespace = x.RootNamespace } else { ns, err := parseAsUint64(inputArg["namespace"]) if err != nil { diff --git a/graphql/admin/namespace.go b/graphql/admin/namespace.go index 14c882056bf..8ca8dbcacde 100644 --- a/graphql/admin/namespace.go +++ b/graphql/admin/namespace.go @@ -55,7 +55,7 @@ func resolveDeleteNamespace(ctx context.Context, m schema.Mutation) (*resolve.Re return resolve.EmptyResult(m, err), false } // No one can delete the galaxy(default) namespace. - if uint64(req.NamespaceId) == x.GalaxyNamespace { + if uint64(req.NamespaceId) == x.RootNamespace { return resolve.EmptyResult(m, errors.New("Cannot delete default namespace")), false } if err = (&edgraph.Server{}).DeleteNamespace(ctx, uint64(req.NamespaceId)); err != nil { diff --git a/graphql/admin/schema.go b/graphql/admin/schema.go index b90c0140462..2243a0dbdc9 100644 --- a/graphql/admin/schema.go +++ b/graphql/admin/schema.go @@ -47,7 +47,7 @@ func (usr *updateSchemaResolver) Resolve(ctx context.Context, m schema.Mutation) } // we don't need the correct namespace for validation, so passing the Galaxy namespace - if _, err = schema.FromString(schHandler.GQLSchema(), x.GalaxyNamespace); err != nil { + if _, err = schema.FromString(schHandler.GQLSchema(), x.RootNamespace); err != nil { return resolve.EmptyResult(m, err), false } diff --git a/graphql/admin/state.go b/graphql/admin/state.go index 4cf849981ad..e93f197a4fc 100644 --- a/graphql/admin/state.go +++ b/graphql/admin/state.go @@ -48,14 +48,13 @@ func resolveState(ctx context.Context, q schema.Query) *resolve.Resolved { // unmarshal it back to MembershipState proto in order to map to graphql response var ms pb.MembershipState - err = protojson.Unmarshal(resp.GetJson(), &ms) - if err != nil { + if err := protojson.Unmarshal(resp.GetJson(), &ms); err != nil { return resolve.EmptyResult(q, err) } ns, _ := x.ExtractNamespace(ctx) - // map to graphql response structure. Only guardian of galaxy can list the namespaces. - state := convertToGraphQLResp(ms, ns == x.GalaxyNamespace) + // map to graphql response structure. Only superadmin can list the namespaces. + state := convertToGraphQLResp(&ms, ns == x.RootNamespace) b, err := json.Marshal(state) if err != nil { return resolve.EmptyResult(q, err) @@ -79,7 +78,7 @@ func resolveState(ctx context.Context, q schema.Query) *resolve.Resolved { // values and not the keys. For pb.MembershipState.Group, the keys are the group IDs // and pb.Group didn't contain this ID, so we are creating a custom clusterGroup type, // which is same as pb.Group and also contains the ID for the group. -func convertToGraphQLResp(ms pb.MembershipState, listNs bool) membershipState { +func convertToGraphQLResp(ms *pb.MembershipState, listNs bool) membershipState { var state membershipState // namespaces stores set of namespaces diff --git a/graphql/e2e/common/common.go b/graphql/e2e/common/common.go index e27ced236e0..5a355a715eb 100644 --- a/graphql/e2e/common/common.go +++ b/graphql/e2e/common/common.go @@ -360,7 +360,7 @@ func CreateNamespace(t *testing.T, headers http.Header, whichAlpha string) uint6 } } require.NoError(t, json.Unmarshal(gqlResponse.Data, &resp)) - require.Greater(t, resp.AddNamespace.NamespaceId, x.GalaxyNamespace) + require.Greater(t, resp.AddNamespace.NamespaceId, x.RootNamespace) return resp.AddNamespace.NamespaceId } diff --git a/graphql/e2e/common/error.go b/graphql/e2e/common/error.go index 9508c98e845..c96aea70947 100644 --- a/graphql/e2e/common/error.go +++ b/graphql/e2e/common/error.go @@ -280,7 +280,7 @@ func panicCatcher(t *testing.T) { schemaEpoch := uint64(0) resolvers := resolve.New(gqlSchema, resolverFactory) server := admin2.NewServer() - server.Set(x.GalaxyNamespace, &schemaEpoch, resolvers) + server.Set(x.RootNamespace, &schemaEpoch, resolvers) ts := httptest.NewServer(server.HTTPHandler()) defer ts.Close() @@ -342,7 +342,7 @@ func clientInfoLogin(t *testing.T) { schemaEpoch := uint64(0) resolvers := resolve.New(gqlSchema, resolverFactory) server := admin2.NewServer() - server.Set(x.GalaxyNamespace, &schemaEpoch, resolvers) + server.Set(x.RootNamespace, &schemaEpoch, resolvers) ts := httptest.NewServer(server.HTTPHandler()) defer ts.Close() diff --git a/graphql/e2e/multi_tenancy/multi_tenancy_test.go b/graphql/e2e/multi_tenancy/multi_tenancy_test.go index 6ecdf40b88f..4429d443a8d 100644 --- a/graphql/e2e/multi_tenancy/multi_tenancy_test.go +++ b/graphql/e2e/multi_tenancy/multi_tenancy_test.go @@ -451,7 +451,7 @@ func TestNamespacesQueryField(t *testing.T) { header1.Set(accessJwtHeader, testutil.GrootHttpLoginNamespace(groupOneAdminServer, ns1).AccessJwt) - // Test namespaces query shows no namespace in case user is not guardian of galaxy. + // Test namespaces query shows no namespace in case user is not superadmin. queryHelper(t, groupOneAdminServer, namespaceQuery, header1, `{ "state": { @@ -459,7 +459,7 @@ func TestNamespacesQueryField(t *testing.T) { } }`) - // Test namespaces query shows all 3 namespaces, 0,ns1,ns2 in case user is guardian of galaxy. + // Test namespaces query shows all 3 namespaces, 0,ns1,ns2 in case user is superadmin. queryHelper(t, groupOneAdminServer, namespaceQuery, header, `{ "state": { diff --git a/graphql/resolve/middlewares.go b/graphql/resolve/middlewares.go index 7e9d2b1efe9..adaa26f0d63 100644 --- a/graphql/resolve/middlewares.go +++ b/graphql/resolve/middlewares.go @@ -112,9 +112,9 @@ func (mws MutationMiddlewares) Then(resolver MutationResolver) MutationResolver } // resolveGuardianOfTheGalaxyAuth returns a Resolved with error if the context doesn't contain any -// Guardian of Galaxy auth, otherwise it returns nil +// superadmin auth, otherwise it returns nil func resolveGuardianOfTheGalaxyAuth(ctx context.Context, f schema.Field) *Resolved { - if err := edgraph.AuthGuardianOfTheGalaxy(ctx); err != nil { + if err := edgraph.AuthSuperAdmin(ctx); err != nil { return EmptyResult(f, err) } return nil diff --git a/graphql/schema/rules.go b/graphql/schema/rules.go index b30ac7e217d..1a4f71f2599 100644 --- a/graphql/schema/rules.go +++ b/graphql/schema/rules.go @@ -1419,7 +1419,7 @@ func lambdaDirectiveValidation(sch *ast.Schema, secrets map[string]x.Sensitive) gqlerror.List { // if the lambda url wasn't specified during alpha startup, // just return that error. Don't confuse the user with errors from @custom yet. - if x.LambdaUrl(x.GalaxyNamespace) == "" { + if x.LambdaUrl(x.RootNamespace) == "" { return []*gqlerror.Error{gqlerror.ErrorPosf(dir.Position, "Type %s; Field %s: has the @lambda directive, but the "+ `--graphql "lambda-url=...;" flag wasn't specified during alpha startup.`, @@ -1427,7 +1427,7 @@ func lambdaDirectiveValidation(sch *ast.Schema, } // reuse @custom directive validation errs := customDirectiveValidation(sch, typ, field, buildCustomDirectiveForLambda(typ, field, - dir, x.GalaxyNamespace, func(f *ast.FieldDefinition) bool { return false }), secrets) + dir, x.RootNamespace, func(f *ast.FieldDefinition) bool { return false }), secrets) for _, err := range errs { err.Message = "While building @custom for @lambda: " + err.Message } @@ -1531,7 +1531,7 @@ func lambdaOnMutateValidation(sch *ast.Schema, typ *ast.Definition) gqlerror.Lis var errs []*gqlerror.Error // lambda url must be specified during alpha startup - if x.LambdaUrl(x.GalaxyNamespace) == "" { + if x.LambdaUrl(x.RootNamespace) == "" { errs = append(errs, gqlerror.ErrorPosf(dir.Position, "Type %s: has the @lambdaOnMutate directive, but the "+ "`--graphql lambda-url` flag wasn't specified during alpha startup.", typ.Name)) diff --git a/graphql/schema/schemagen_test.go b/graphql/schema/schemagen_test.go index 76e98bb099b..e2172fcf151 100644 --- a/graphql/schema/schemagen_test.go +++ b/graphql/schema/schemagen_test.go @@ -78,7 +78,7 @@ func TestSchemaString(t *testing.T) { newSchemaStr := schHandler.GQLSchema() - _, err = FromString(newSchemaStr, x.GalaxyNamespace) + _, err = FromString(newSchemaStr, x.RootNamespace) require.NoError(t, err) outputFileName := outputDir + testFile.Name() str2, err := os.ReadFile(outputFileName) @@ -109,7 +109,7 @@ func TestApolloServiceQueryResult(t *testing.T) { apolloServiceResult := schHandler.GQLSchemaWithoutApolloExtras() - _, err = FromString(schHandler.GQLSchema(), x.GalaxyNamespace) + _, err = FromString(schHandler.GQLSchema(), x.RootNamespace) require.NoError(t, err) outputFileName := outputDir + testFile.Name() str2, err := os.ReadFile(outputFileName) @@ -138,7 +138,7 @@ func TestSchemas(t *testing.T) { newSchemaStr := schHandler.GQLSchema() - _, err = FromString(newSchemaStr, x.GalaxyNamespace) + _, err = FromString(newSchemaStr, x.RootNamespace) require.NoError(t, err) }) } @@ -149,7 +149,7 @@ func TestSchemas(t *testing.T) { t.Run(sch.Name, func(t *testing.T) { schHandler, errlist := NewHandler(sch.Input, false) if errlist == nil { - _, errlist = FromString(schHandler.GQLSchema(), x.GalaxyNamespace) + _, errlist = FromString(schHandler.GQLSchema(), x.RootNamespace) } if diff := cmp.Diff(sch.Errlist, errlist, cmpopts.IgnoreUnexported(gqlerror.Error{})); diff != "" { t.Errorf("error mismatch (-want +got):\n%s", diff) @@ -179,7 +179,7 @@ func TestAuthSchemas(t *testing.T) { schHandler, errlist := NewHandler(sch.Input, false) require.NoError(t, errlist, sch.Name) - _, authError := FromString(schHandler.GQLSchema(), x.GalaxyNamespace) + _, authError := FromString(schHandler.GQLSchema(), x.RootNamespace) require.NoError(t, authError, sch.Name) }) } @@ -191,7 +191,7 @@ func TestAuthSchemas(t *testing.T) { schHandler, errlist := NewHandler(sch.Input, false) require.NoError(t, errlist, sch.Name) - _, authError := FromString(schHandler.GQLSchema(), x.GalaxyNamespace) + _, authError := FromString(schHandler.GQLSchema(), x.RootNamespace) if diff := cmp.Diff(authError, sch.Errlist); diff != "" { t.Errorf("error mismatch (-want +got):\n%s", diff) diff --git a/graphql/schema/wrappers_test.go b/graphql/schema/wrappers_test.go index dcc759e4bda..4b0192831aa 100644 --- a/graphql/schema/wrappers_test.go +++ b/graphql/schema/wrappers_test.go @@ -77,7 +77,7 @@ type Starship { schHandler, errs := NewHandler(schemaStr, false) require.NoError(t, errs) - sch, err := FromString(schHandler.GQLSchema(), x.GalaxyNamespace) + sch, err := FromString(schHandler.GQLSchema(), x.RootNamespace) require.NoError(t, err) s, ok := sch.(*schema) @@ -262,7 +262,7 @@ func TestDgraphMapping_WithDirectives(t *testing.T) { schHandler, errs := NewHandler(schemaStr, false) require.NoError(t, errs) - sch, err := FromString(schHandler.GQLSchema(), x.GalaxyNamespace) + sch, err := FromString(schHandler.GQLSchema(), x.RootNamespace) require.NoError(t, err) s, ok := sch.(*schema) @@ -398,7 +398,7 @@ func TestCheckNonNulls(t *testing.T) { req: String! notReq: String alsoReq: String! - }`, x.GalaxyNamespace) + }`, x.RootNamespace) require.NoError(t, err) tcases := map[string]struct { @@ -908,7 +908,7 @@ func TestGraphQLQueryInCustomHTTPConfig(t *testing.T) { t.Run(tcase.Name, func(t *testing.T) { schHandler, errs := NewHandler(tcase.GQLSchema, false) require.NoError(t, errs) - sch, err := FromString(schHandler.GQLSchema(), x.GalaxyNamespace) + sch, err := FromString(schHandler.GQLSchema(), x.RootNamespace) require.NoError(t, err) var vars map[string]interface{} @@ -947,7 +947,7 @@ func TestGraphQLQueryInCustomHTTPConfig(t *testing.T) { remoteSchemaHandler, errs := NewHandler(tcase.RemoteSchema, false) require.NoError(t, errs) - remoteSchema, err := FromString(remoteSchemaHandler.GQLSchema(), x.GalaxyNamespace) + remoteSchema, err := FromString(remoteSchemaHandler.GQLSchema(), x.RootNamespace) require.NoError(t, err) // Validate the generated query against the remote schema. @@ -1007,7 +1007,7 @@ func TestAllowedHeadersList(t *testing.T) { t.Run(test.name, func(t *testing.T) { schHandler, errs := NewHandler(test.schemaStr, false) require.NoError(t, errs) - _, err := FromString(schHandler.GQLSchema(), x.GalaxyNamespace) + _, err := FromString(schHandler.GQLSchema(), x.RootNamespace) require.NoError(t, err) require.Equal(t, strings.Join([]string{x.AccessControlAllowedHeaders, test.expected}, ","), schHandler.MetaInfo().AllowedCorsHeaders()) diff --git a/graphql/test/test.go b/graphql/test/test.go index 21aad561259..737d57a0ee6 100644 --- a/graphql/test/test.go +++ b/graphql/test/test.go @@ -31,7 +31,7 @@ func LoadSchema(t *testing.T, gqlSchema string) schema.Schema { gql, gqlErr := validator.ValidateSchemaDocument(doc) requireNoGQLErrors(t, gqlErr) - schema, err := schema.AsSchema(gql, x.GalaxyNamespace) + schema, err := schema.AsSchema(gql, x.RootNamespace) requireNoGQLErrors(t, err) return schema } diff --git a/posting/index_test.go b/posting/index_test.go index 9e02f0888cc..7f02ed8e223 100644 --- a/posting/index_test.go +++ b/posting/index_test.go @@ -30,9 +30,9 @@ func uids(l *List, readTs uint64) []uint64 { // indexTokensForTest is just a wrapper around indexTokens used for convenience. func indexTokensForTest(attr, lang string, val types.Val) ([]string, error) { return indexTokens(context.Background(), &indexMutationInfo{ - tokenizers: schema.State().Tokenizer(context.Background(), x.GalaxyAttr(attr)), + tokenizers: schema.State().Tokenizer(context.Background(), x.AttrInRootNamespace(attr)), edge: &pb.DirectedEdge{ - Attr: x.GalaxyAttr(attr), + Attr: x.AttrInRootNamespace(attr), Lang: lang, }, val: val, @@ -170,7 +170,7 @@ friend:[uid] @reverse . func TestTokensTable(t *testing.T) { require.NoError(t, schema.ParseBytes([]byte(schemaVal), 1)) - attr := x.GalaxyAttr("name") + attr := x.AttrInRootNamespace("name") key := x.DataKey(attr, 1) l, err := getNew(key, ps, math.MaxUint64) require.NoError(t, err) @@ -264,7 +264,7 @@ func TestCountReverseIndexWithData(t *testing.T) { memoryLayer.clear() indexNameCountVal := "testcount: [uid] @count @reverse ." - attr := x.GalaxyAttr("testcount") + attr := x.AttrInRootNamespace("testcount") addEdgeToUID(t, attr, 1, 23, uint64(8), uint64(9)) addEdgeToUID(t, attr, 1, 23, uint64(10), uint64(11)) l, err := GetNoStore(x.DataKey(attr, 1), 12) @@ -299,7 +299,7 @@ func TestCountReverseIndexEmptyPosting(t *testing.T) { memoryLayer.clear() indexNameCountVal := "testcount: [uid] @count @reverse ." - attr := x.GalaxyAttr("testcount") + attr := x.AttrInRootNamespace("testcount") addDelEdgeToUID(t, attr, 1, 23, uint64(10), uint64(11)) l, err := GetNoStore(x.DataKey(attr, 1), 12) require.NoError(t, err) @@ -329,13 +329,13 @@ func TestCountReverseIndexEmptyPosting(t *testing.T) { } func TestRebuildTokIndex(t *testing.T) { - addEdgeToValue(t, x.GalaxyAttr("name2"), 91, "Michonne", uint64(1), uint64(2)) - addEdgeToValue(t, x.GalaxyAttr("name2"), 92, "David", uint64(3), uint64(4)) + addEdgeToValue(t, x.AttrInRootNamespace("name2"), 91, "Michonne", uint64(1), uint64(2)) + addEdgeToValue(t, x.AttrInRootNamespace("name2"), 92, "David", uint64(3), uint64(4)) require.NoError(t, schema.ParseBytes([]byte(schemaVal), 1)) - currentSchema, _ := schema.State().Get(context.Background(), x.GalaxyAttr("name2")) + currentSchema, _ := schema.State().Get(context.Background(), x.AttrInRootNamespace("name2")) rb := IndexRebuild{ - Attr: x.GalaxyAttr("name2"), + Attr: x.AttrInRootNamespace("name2"), StartTs: 5, OldSchema: nil, CurrentSchema: ¤tSchema, @@ -351,7 +351,7 @@ func TestRebuildTokIndex(t *testing.T) { defer txn.Discard() it := txn.NewIterator(badger.DefaultIteratorOptions) defer it.Close() - pk := x.ParsedKey{Attr: x.GalaxyAttr("name2")} + pk := x.ParsedKey{Attr: x.AttrInRootNamespace("name2")} prefix := pk.IndexPrefix() var idxKeys []string var idxVals []*List @@ -371,8 +371,8 @@ func TestRebuildTokIndex(t *testing.T) { } require.Len(t, idxKeys, 2) require.Len(t, idxVals, 2) - require.EqualValues(t, idxKeys[0], x.IndexKey(x.GalaxyAttr("name2"), "\x01david")) - require.EqualValues(t, idxKeys[1], x.IndexKey(x.GalaxyAttr("name2"), "\x01michonne")) + require.EqualValues(t, idxKeys[0], x.IndexKey(x.AttrInRootNamespace("name2"), "\x01david")) + require.EqualValues(t, idxKeys[1], x.IndexKey(x.AttrInRootNamespace("name2"), "\x01michonne")) uids1 := uids(idxVals[0], 6) uids2 := uids(idxVals[1], 6) @@ -383,13 +383,13 @@ func TestRebuildTokIndex(t *testing.T) { } func TestRebuildTokIndexWithDeletion(t *testing.T) { - addEdgeToValue(t, x.GalaxyAttr("name2"), 91, "Michonne", uint64(1), uint64(2)) - addEdgeToValue(t, x.GalaxyAttr("name2"), 92, "David", uint64(3), uint64(4)) + addEdgeToValue(t, x.AttrInRootNamespace("name2"), 91, "Michonne", uint64(1), uint64(2)) + addEdgeToValue(t, x.AttrInRootNamespace("name2"), 92, "David", uint64(3), uint64(4)) require.NoError(t, schema.ParseBytes([]byte(schemaVal), 1)) - currentSchema, _ := schema.State().Get(context.Background(), x.GalaxyAttr("name2")) + currentSchema, _ := schema.State().Get(context.Background(), x.AttrInRootNamespace("name2")) rb := IndexRebuild{ - Attr: x.GalaxyAttr("name2"), + Attr: x.AttrInRootNamespace("name2"), StartTs: 5, OldSchema: nil, CurrentSchema: ¤tSchema, @@ -402,9 +402,9 @@ func TestRebuildTokIndexWithDeletion(t *testing.T) { // Mutate the schema (the index in name2 is deleted) and rebuild the index. require.NoError(t, schema.ParseBytes([]byte(mutatedSchemaVal), 1)) - newSchema, _ := schema.State().Get(context.Background(), x.GalaxyAttr("name2")) + newSchema, _ := schema.State().Get(context.Background(), x.AttrInRootNamespace("name2")) rb = IndexRebuild{ - Attr: x.GalaxyAttr("name2"), + Attr: x.AttrInRootNamespace("name2"), StartTs: 6, OldSchema: ¤tSchema, CurrentSchema: &newSchema, @@ -420,7 +420,7 @@ func TestRebuildTokIndexWithDeletion(t *testing.T) { defer txn.Discard() it := txn.NewIterator(badger.DefaultIteratorOptions) defer it.Close() - pk := x.ParsedKey{Attr: x.GalaxyAttr("name2")} + pk := x.ParsedKey{Attr: x.AttrInRootNamespace("name2")} prefix := pk.IndexPrefix() var idxKeys []string var idxVals []*List @@ -445,7 +445,7 @@ func TestRebuildTokIndexWithDeletion(t *testing.T) { } func TestRebuildReverseEdges(t *testing.T) { - friendAttr := x.GalaxyAttr("friend") + friendAttr := x.AttrInRootNamespace("friend") addEdgeToUID(t, friendAttr, 1, 23, uint64(10), uint64(11)) addEdgeToUID(t, friendAttr, 1, 24, uint64(12), uint64(13)) addEdgeToUID(t, friendAttr, 2, 23, uint64(14), uint64(15)) @@ -608,7 +608,7 @@ func TestNeedsListTypeRebuild(t *testing.T) { rb.OldSchema = &pb.SchemaUpdate{ValueType: pb.Posting_UID, List: true} rb.CurrentSchema = &pb.SchemaUpdate{ValueType: pb.Posting_UID, List: false, - Predicate: x.GalaxyAttr("")} // This is added to prevent a crash in rebuilder. + Predicate: x.AttrInRootNamespace("")} // This is added to prevent a crash in rebuilder. // We don't expect rebuilder to have predicates without namespace. rebuild, err = rb.needsListTypeRebuild() require.False(t, rebuild) diff --git a/posting/list_test.go b/posting/list_test.go index 9c90277df21..356860049de 100644 --- a/posting/list_test.go +++ b/posting/list_test.go @@ -103,7 +103,7 @@ func (l *List) commitMutation(startTs, commitTs uint64) error { } func TestGetSinglePosting(t *testing.T) { - key := x.DataKey(x.GalaxyAttr("GetSinglePosting"), 123) + key := x.DataKey(x.AttrInRootNamespace("GetSinglePosting"), 123) txn := NewTxn(5) l, err := txn.Get(key) require.NoError(t, err) @@ -163,7 +163,7 @@ func TestGetSinglePosting(t *testing.T) { } func TestAddMutation(t *testing.T) { - key := x.DataKey(x.GalaxyAttr("name"), 2) + key := x.DataKey(x.AttrInRootNamespace("name"), 2) txn := NewTxn(1) l, err := txn.Get(key) @@ -229,7 +229,7 @@ func checkValue(t *testing.T, ol *List, val string, readTs uint64) { // TODO(txn): Add tests after lru eviction func TestAddMutation_Value(t *testing.T) { - key := x.DataKey(x.GalaxyAttr(x.GalaxyAttr("value")), 10) + key := x.DataKey(x.AttrInRootNamespace(x.AttrInRootNamespace("value")), 10) ol, err := readPostingListFromDisk(key, ps, math.MaxUint64) require.NoError(t, err) edge := &pb.DirectedEdge{ @@ -251,7 +251,7 @@ func TestAddMutation_Value(t *testing.T) { } func TestAddMutation_jchiu1(t *testing.T) { - key := x.DataKey(x.GalaxyAttr(x.GalaxyAttr("value")), 12) + key := x.DataKey(x.AttrInRootNamespace(x.AttrInRootNamespace("value")), 12) ol, err := GetNoStore(key, math.MaxUint64) require.NoError(t, err) @@ -294,7 +294,7 @@ func TestAddMutation_jchiu1(t *testing.T) { } func TestAddMutation_DelSet(t *testing.T) { - key := x.DataKey(x.GalaxyAttr(x.GalaxyAttr("value")), 1534) + key := x.DataKey(x.AttrInRootNamespace(x.AttrInRootNamespace("value")), 1534) ol, err := GetNoStore(key, math.MaxUint64) require.NoError(t, err) @@ -321,7 +321,7 @@ func TestAddMutation_DelSet(t *testing.T) { } func TestAddMutation_DelRead(t *testing.T) { - key := x.DataKey(x.GalaxyAttr(x.GalaxyAttr("value")), 1543) + key := x.DataKey(x.AttrInRootNamespace(x.AttrInRootNamespace("value")), 1543) ol, err := GetNoStore(key, math.MaxUint64) require.NoError(t, err) @@ -359,7 +359,7 @@ func TestAddMutation_DelRead(t *testing.T) { } func TestAddMutation_jchiu2(t *testing.T) { - key := x.DataKey(x.GalaxyAttr(x.GalaxyAttr("value")), 15) + key := x.DataKey(x.AttrInRootNamespace(x.AttrInRootNamespace("value")), 15) ol, err := GetNoStore(key, math.MaxUint64) require.NoError(t, err) @@ -381,7 +381,7 @@ func TestAddMutation_jchiu2(t *testing.T) { } func TestAddMutation_jchiu2_Commit(t *testing.T) { - key := x.DataKey(x.GalaxyAttr(x.GalaxyAttr("value")), 16) + key := x.DataKey(x.AttrInRootNamespace(x.AttrInRootNamespace("value")), 16) ol, err := GetNoStore(key, math.MaxUint64) require.NoError(t, err) @@ -406,7 +406,7 @@ func TestAddMutation_jchiu2_Commit(t *testing.T) { } func TestAddMutation_jchiu3(t *testing.T) { - key := x.DataKey(x.GalaxyAttr("value"), 29) + key := x.DataKey(x.AttrInRootNamespace("value"), 29) ol, err := GetNoStore(key, math.MaxUint64) require.NoError(t, err) @@ -446,7 +446,7 @@ func TestAddMutation_jchiu3(t *testing.T) { } func TestAddMutation_mrjn1(t *testing.T) { - key := x.DataKey(x.GalaxyAttr("value"), 21) + key := x.DataKey(x.AttrInRootNamespace("value"), 21) ol, err := GetNoStore(key, math.MaxUint64) require.NoError(t, err) @@ -499,7 +499,7 @@ func TestReadSingleValue(t *testing.T) { // single values. This test confirms that the two functions, getFirst from this file // and GetSingeValueForKey works without an issue. - key := x.DataKey(x.GalaxyAttr("value"), 1240) + key := x.DataKey(x.AttrInRootNamespace("value"), 1240) ol, err := getNew(key, ps, math.MaxUint64) require.NoError(t, err) N := uint64(10000) @@ -546,7 +546,7 @@ func TestRollupMaxTsIsSet(t *testing.T) { defer setMaxListSize(maxListSize) maxListSize = math.MaxInt32 - key := x.DataKey(x.GalaxyAttr("bal"), 1333) + key := x.DataKey(x.AttrInRootNamespace("bal"), 1333) ol, err := readPostingListFromDisk(key, ps, math.MaxUint64) require.NoError(t, err) var commits int @@ -580,7 +580,7 @@ func TestMillion(t *testing.T) { defer setMaxListSize(maxListSize) maxListSize = math.MaxInt32 - key := x.DataKey(x.GalaxyAttr("bal"), 1331) + key := x.DataKey(x.AttrInRootNamespace("bal"), 1331) ol, err := readPostingListFromDisk(key, ps, math.MaxUint64) require.NoError(t, err) var commits int @@ -619,7 +619,7 @@ func TestMillion(t *testing.T) { func TestAddMutation_mrjn2(t *testing.T) { t.Skip() ctx := context.Background() - key := x.DataKey(x.GalaxyAttr("bal"), 1001) + key := x.DataKey(x.AttrInRootNamespace("bal"), 1001) ol, err := readPostingListFromDisk(key, ps, math.MaxUint64) require.NoError(t, err) var readTs uint64 @@ -694,7 +694,7 @@ func TestAddMutation_mrjn2(t *testing.T) { } func TestAddMutation_gru(t *testing.T) { - key := x.DataKey(x.GalaxyAttr("question.tag"), 0x01) + key := x.DataKey(x.AttrInRootNamespace("question.tag"), 0x01) ol, err := readPostingListFromDisk(key, ps, math.MaxUint64) require.NoError(t, err) @@ -727,7 +727,7 @@ func TestAddMutation_gru(t *testing.T) { } func TestAddMutation_gru2(t *testing.T) { - key := x.DataKey(x.GalaxyAttr("question.tag"), 0x100) + key := x.DataKey(x.AttrInRootNamespace("question.tag"), 0x100) ol, err := readPostingListFromDisk(key, ps, math.MaxUint64) require.NoError(t, err) @@ -774,7 +774,7 @@ func TestAddMutation_gru2(t *testing.T) { func TestAddAndDelMutation(t *testing.T) { // Ensure each test uses unique key since we don't clear the postings // after each test - key := x.DataKey(x.GalaxyAttr("dummy_key"), 0x927) + key := x.DataKey(x.AttrInRootNamespace("dummy_key"), 0x927) ol, err := readPostingListFromDisk(key, ps, math.MaxUint64) require.NoError(t, err) @@ -802,7 +802,7 @@ func TestAddAndDelMutation(t *testing.T) { } func TestAfterUIDCount(t *testing.T) { - key := x.DataKey(x.GalaxyAttr("value"), 22) + key := x.DataKey(x.AttrInRootNamespace("value"), 22) ol, err := readPostingListFromDisk(key, ps, math.MaxUint64) require.NoError(t, err) // Set value to cars and merge to BadgerDB. @@ -873,7 +873,7 @@ func TestAfterUIDCount(t *testing.T) { } func TestAfterUIDCount2(t *testing.T) { - key := x.DataKey(x.GalaxyAttr("value"), 23) + key := x.DataKey(x.AttrInRootNamespace("value"), 23) ol, err := readPostingListFromDisk(key, ps, math.MaxUint64) require.NoError(t, err) @@ -900,7 +900,7 @@ func TestAfterUIDCount2(t *testing.T) { } func TestDelete(t *testing.T) { - key := x.DataKey(x.GalaxyAttr("value"), 25) + key := x.DataKey(x.AttrInRootNamespace("value"), 25) ol, err := readPostingListFromDisk(key, ps, math.MaxUint64) require.NoError(t, err) @@ -922,7 +922,7 @@ func TestDelete(t *testing.T) { } func TestAfterUIDCountWithCommit(t *testing.T) { - key := x.DataKey(x.GalaxyAttr("value"), 26) + key := x.DataKey(x.AttrInRootNamespace("value"), 26) ol, err := readPostingListFromDisk(key, ps, math.MaxUint64) require.NoError(t, err) @@ -1013,7 +1013,7 @@ func createMultiPartList(t *testing.T, size int, addFacet bool) (*List, int) { defer setMaxListSize(maxListSize) maxListSize = 5000 - key := x.DataKey(x.GalaxyAttr(uuid.New().String()), 1331) + key := x.DataKey(x.AttrInRootNamespace(uuid.New().String()), 1331) ol, err := readPostingListFromDisk(key, ps, math.MaxUint64) require.NoError(t, err) commits := 0 @@ -1061,7 +1061,7 @@ func createAndDeleteMultiPartList(t *testing.T, size int) (*List, int) { defer setMaxListSize(maxListSize) maxListSize = 10000 - key := x.DataKey(x.GalaxyAttr(uuid.New().String()), 1331) + key := x.DataKey(x.AttrInRootNamespace(uuid.New().String()), 1331) ol, err := readPostingListFromDisk(key, ps, math.MaxUint64) require.NoError(t, err) commits := 0 @@ -1220,7 +1220,7 @@ func TestBinSplit(t *testing.T) { defer func() { maxListSize = originalListSize }() - key := x.DataKey(x.GalaxyAttr(uuid.New().String()), 1331) + key := x.DataKey(x.AttrInRootNamespace(uuid.New().String()), 1331) ol, err := readPostingListFromDisk(key, ps, math.MaxUint64) require.NoError(t, err) for i := 1; i <= size; i++ { @@ -1401,7 +1401,7 @@ func TestMultiPartListDeleteAndAdd(t *testing.T) { maxListSize = 5000 // Add entries to the maps. - key := x.DataKey(x.GalaxyAttr(uuid.New().String()), 1331) + key := x.DataKey(x.AttrInRootNamespace(uuid.New().String()), 1331) ol, err := readPostingListFromDisk(key, ps, math.MaxUint64) require.NoError(t, err) for i := 1; i <= size; i++ { @@ -1674,7 +1674,7 @@ func TestListDeleteMarker(t *testing.T) { defer setMaxListSize(maxListSize) maxListSize = mb / 2 - key := x.DataKey(x.GalaxyAttr(uuid.New().String()), 13345) + key := x.DataKey(x.AttrInRootNamespace(uuid.New().String()), 13345) ol, err := readPostingListFromDisk(key, ps, math.MaxUint64) require.NoError(t, err) @@ -1702,7 +1702,7 @@ func TestSplitLength(t *testing.T) { // Create a list that should be split recursively. size := uint64(1e5) - key := x.DataKey(x.GalaxyAttr(uuid.New().String()), 1333) + key := x.DataKey(x.AttrInRootNamespace(uuid.New().String()), 1333) ol, err := readPostingListFromDisk(key, ps, math.MaxUint64) require.NoError(t, err) commits := 0 @@ -1742,7 +1742,7 @@ func TestRecursiveSplits(t *testing.T) { // Create a list that should be split recursively. size := int(1e5) - key := x.DataKey(x.GalaxyAttr(uuid.New().String()), 1331) + key := x.DataKey(x.AttrInRootNamespace(uuid.New().String()), 1331) ol, err := readPostingListFromDisk(key, ps, math.MaxUint64) require.NoError(t, err) commits := 0 @@ -1803,7 +1803,7 @@ func TestMain(m *testing.M) { } func BenchmarkAddMutations(b *testing.B) { - key := x.DataKey(x.GalaxyAttr("name"), 1) + key := x.DataKey(x.AttrInRootNamespace("name"), 1) l, err := readPostingListFromDisk(key, ps, math.MaxUint64) if err != nil { b.Error(err) diff --git a/posting/mvcc_test.go b/posting/mvcc_test.go index 6b92f1f4cc9..570d10ec966 100644 --- a/posting/mvcc_test.go +++ b/posting/mvcc_test.go @@ -24,7 +24,7 @@ import ( ) func TestIncrRollupGetsCancelledQuickly(t *testing.T) { - attr := x.GalaxyAttr("rollup") + attr := x.AttrInRootNamespace("rollup") key := x.DataKey(attr, 1) closer = z.NewCloser(1) @@ -56,7 +56,7 @@ func TestIncrRollupGetsCancelledQuickly(t *testing.T) { } func TestCacheAfterDeltaUpdateRecieved(t *testing.T) { - attr := x.GalaxyAttr("cache") + attr := x.AttrInRootNamespace("cache") key := x.IndexKey(attr, "temp") // Create a delta from 5->15. Mimick how a follower recieves a delta. @@ -101,7 +101,7 @@ func BenchmarkTestCache(b *testing.B) { Init(ps, 10000000, true) schema.Init(ps) - attr := x.GalaxyAttr("cache") + attr := x.AttrInRootNamespace("cache") keys := make([][]byte, 0) N := uint64(10000) NInt := 10000 @@ -144,7 +144,7 @@ func BenchmarkTestCache(b *testing.B) { } func TestRollupTimestamp(t *testing.T) { - attr := x.GalaxyAttr("rollup") + attr := x.AttrInRootNamespace("rollup") key := x.DataKey(attr, 1) // 3 Delta commits. addEdgeToUID(t, attr, 1, 2, 1, 2) @@ -183,7 +183,7 @@ func TestRollupTimestamp(t *testing.T) { } func TestPostingListRead(t *testing.T) { - attr := x.GalaxyAttr("emptypl") + attr := x.AttrInRootNamespace("emptypl") key := x.DataKey(attr, 1) assertLength := func(readTs, sz int) { diff --git a/query/cloud_test.go b/query/cloud_test.go index 480d7030028..a313b8691ed 100644 --- a/query/cloud_test.go +++ b/query/cloud_test.go @@ -27,7 +27,7 @@ func TestMain(m *testing.M) { ctx, cancel := context.WithTimeout(context.Background(), time.Minute) defer cancel() - x.Panic(dg.LoginIntoNamespace(ctx, dgraphapi.DefaultUser, dgraphapi.DefaultPassword, x.GalaxyNamespace)) + x.Panic(dg.LoginIntoNamespace(ctx, dgraphapi.DefaultUser, dgraphapi.DefaultPassword, x.RootNamespace)) dc = c client.Dgraph = dg diff --git a/query/integration_test.go b/query/integration_test.go index 665128d8583..7c4664ca425 100644 --- a/query/integration_test.go +++ b/query/integration_test.go @@ -25,7 +25,7 @@ func TestMain(m *testing.M) { x.Panic(err) defer cleanup() x.Panic(client.LoginIntoNamespace(context.Background(), dgraphapi.DefaultUser, - dgraphapi.DefaultPassword, x.GalaxyNamespace)) + dgraphapi.DefaultPassword, x.RootNamespace)) populateCluster(dc) m.Run() diff --git a/query/mutation.go b/query/mutation.go index de20569ff5d..b9b12061ca3 100644 --- a/query/mutation.go +++ b/query/mutation.go @@ -54,7 +54,7 @@ func ExpandEdges(ctx context.Context, m *pb.Mutations) ([]*pb.DirectedEdge, erro if err != nil { return nil, errors.Wrapf(err, "While expanding edges") } - isGalaxyQuery := x.IsGalaxyOperation(ctx) + isGalaxyQuery := x.IsRootNsOperation(ctx) // Reset the namespace to the original. defer func(ns uint64) { @@ -273,7 +273,7 @@ func checkIfDeletingAclOperation(ctx context.Context, edges []*pb.DirectedEdge) // If the guardian or groot node is not present, then the request cannot be a delete operation // on guardian or groot node. - guardianUid, ok := x.GuardiansUid.Load(namespace) + guardianUid, ok := x.SuperAdminUid.Load(namespace) if !ok { return nil } diff --git a/query/query.go b/query/query.go index 46422cbaa92..cae31382bf9 100644 --- a/query/query.go +++ b/query/query.go @@ -2978,7 +2978,7 @@ func (req *Request) Process(ctx context.Context) (er ExecutionResult, err error) } } - if !x.IsGalaxyOperation(ctx) { + if !x.IsRootNsOperation(ctx) { // Filter the schema nodes for the given namespace. er.SchemaNode = filterSchemaNodeForNamespace(namespace, er.SchemaNode) // Filter the types for the given namespace. diff --git a/query/upgrade_test.go b/query/upgrade_test.go index 10538f01cb2..cbdfbf2b72e 100644 --- a/query/upgrade_test.go +++ b/query/upgrade_test.go @@ -25,7 +25,7 @@ func TestMain(m *testing.M) { x.Panic(err) defer cleanup() x.Panic(dg.LoginIntoNamespace(context.Background(), dgraphapi.DefaultUser, - dgraphapi.DefaultPassword, x.GalaxyNamespace)) + dgraphapi.DefaultPassword, x.RootNamespace)) client = dg dc = c @@ -37,7 +37,7 @@ func TestMain(m *testing.M) { x.Panic(err) defer cleanup() x.Panic(dg.LoginIntoNamespace(context.Background(), dgraphapi.DefaultUser, - dgraphapi.DefaultPassword, x.GalaxyNamespace)) + dgraphapi.DefaultPassword, x.RootNamespace)) client = dg dc = c @@ -55,7 +55,7 @@ func TestMain(m *testing.M) { hc, err := c.HTTPClient() x.Panic(err) - x.Panic(hc.LoginIntoNamespace(dgraphapi.DefaultUser, dgraphapi.DefaultPassword, x.GalaxyNamespace)) + x.Panic(hc.LoginIntoNamespace(dgraphapi.DefaultUser, dgraphapi.DefaultPassword, x.RootNamespace)) mutate(c) x.Panic(c.Upgrade(uc.After, uc.Strategy)) diff --git a/query/vector/integration_test.go b/query/vector/integration_test.go index 7fb5b782da5..8b2aed35833 100644 --- a/query/vector/integration_test.go +++ b/query/vector/integration_test.go @@ -25,7 +25,7 @@ func TestMain(m *testing.M) { x.Panic(err) defer cleanup() x.Panic(client.LoginIntoNamespace(context.Background(), dgraphapi.DefaultUser, - dgraphapi.DefaultPassword, x.GalaxyNamespace)) + dgraphapi.DefaultPassword, x.RootNamespace)) m.Run() } diff --git a/query/vector/vector_test.go b/query/vector/vector_test.go index 6c38ed836bc..bbafd0b2e89 100644 --- a/query/vector/vector_test.go +++ b/query/vector/vector_test.go @@ -471,7 +471,7 @@ func TestVectorDeadlockwithTimeout(t *testing.T) { ctx, cancel2 := context.WithTimeout(context.Background(), 5*time.Second) defer cancel2() err = client.LoginIntoNamespace(ctx, dgraphapi.DefaultUser, - dgraphapi.DefaultPassword, x.GalaxyNamespace) + dgraphapi.DefaultPassword, x.RootNamespace) require.NoError(t, err) err = client.Alter(context.Background(), &api.Operation{ diff --git a/schema/parse.go b/schema/parse.go index d8b7b799c07..776596d292b 100644 --- a/schema/parse.go +++ b/schema/parse.go @@ -676,7 +676,7 @@ func parse(s string, namespace uint64) (*ParsedSchema, error) { case itemText: // For schema which does not contain the namespace information, use the default // namespace, if namespace has to be preserved. Else, use the passed namespace. - ns := x.GalaxyNamespace + ns := x.RootNamespace if namespace != math.MaxUint64 { ns = namespace } diff --git a/schema/parse_test.go b/schema/parse_test.go index 1043a682046..f201d753537 100644 --- a/schema/parse_test.go +++ b/schema/parse_test.go @@ -49,32 +49,32 @@ indexvector: float32vector @index(hnsw(metric:"euclidean")) . func TestSchema(t *testing.T) { require.NoError(t, ParseBytes([]byte(schemaVal), 1)) checkSchema(t, State().predicate, []nameType{ - {x.GalaxyAttr("name"), &pb.SchemaUpdate{ - Predicate: x.GalaxyAttr("name"), + {x.AttrInRootNamespace("name"), &pb.SchemaUpdate{ + Predicate: x.AttrInRootNamespace("name"), ValueType: pb.Posting_STRING, }}, - {x.GalaxyAttr("address"), &pb.SchemaUpdate{ - Predicate: x.GalaxyAttr("address"), + {x.AttrInRootNamespace("address"), &pb.SchemaUpdate{ + Predicate: x.AttrInRootNamespace("address"), ValueType: pb.Posting_STRING, }}, - {x.GalaxyAttr("http://scalar.com/helloworld/"), &pb.SchemaUpdate{ - Predicate: x.GalaxyAttr("http://scalar.com/helloworld/"), + {x.AttrInRootNamespace("http://scalar.com/helloworld/"), &pb.SchemaUpdate{ + Predicate: x.AttrInRootNamespace("http://scalar.com/helloworld/"), ValueType: pb.Posting_STRING, }}, - {x.GalaxyAttr("age"), &pb.SchemaUpdate{ - Predicate: x.GalaxyAttr("age"), + {x.AttrInRootNamespace("age"), &pb.SchemaUpdate{ + Predicate: x.AttrInRootNamespace("age"), ValueType: pb.Posting_INT, }}, - {x.GalaxyAttr("amount"), &pb.SchemaUpdate{ - Predicate: x.GalaxyAttr("amount"), + {x.AttrInRootNamespace("amount"), &pb.SchemaUpdate{ + Predicate: x.AttrInRootNamespace("amount"), ValueType: pb.Posting_BIGFLOAT, }}, - {x.GalaxyAttr("coordinates"), &pb.SchemaUpdate{ - Predicate: x.GalaxyAttr("coordinates"), + {x.AttrInRootNamespace("coordinates"), &pb.SchemaUpdate{ + Predicate: x.AttrInRootNamespace("coordinates"), ValueType: pb.Posting_VFLOAT, }}, - {x.GalaxyAttr("indexvector"), &pb.SchemaUpdate{ - Predicate: x.GalaxyAttr("indexvector"), + {x.AttrInRootNamespace("indexvector"), &pb.SchemaUpdate{ + Predicate: x.AttrInRootNamespace("indexvector"), ValueType: pb.Posting_VFLOAT, Tokenizer: []string{}, Directive: pb.SchemaUpdate_INDEX, @@ -92,19 +92,19 @@ func TestSchema(t *testing.T) { }}, }) - typ, err := State().TypeOf(x.GalaxyAttr("age")) + typ, err := State().TypeOf(x.AttrInRootNamespace("age")) require.NoError(t, err) require.Equal(t, types.IntID, typ) - typ, err = State().TypeOf(x.GalaxyAttr("amount")) + typ, err = State().TypeOf(x.AttrInRootNamespace("amount")) require.NoError(t, err) require.Equal(t, types.BigFloatID, typ) - typ, err = State().TypeOf(x.GalaxyAttr("coordinates")) + typ, err = State().TypeOf(x.AttrInRootNamespace("coordinates")) require.NoError(t, err) require.Equal(t, types.VFloatID, typ) - _, err = State().TypeOf(x.GalaxyAttr("agea")) + _, err = State().TypeOf(x.AttrInRootNamespace("agea")) require.Error(t, err) } @@ -186,36 +186,36 @@ friend : [uid] @reverse @count . func TestSchemaIndexCustom(t *testing.T) { require.NoError(t, ParseBytes([]byte(schemaIndexVal5), 1)) checkSchema(t, State().predicate, []nameType{ - {x.GalaxyAttr("name"), &pb.SchemaUpdate{ - Predicate: x.GalaxyAttr("name"), + {x.AttrInRootNamespace("name"), &pb.SchemaUpdate{ + Predicate: x.AttrInRootNamespace("name"), ValueType: pb.Posting_STRING, Tokenizer: []string{"exact"}, Directive: pb.SchemaUpdate_INDEX, Count: true, }}, - {x.GalaxyAttr("address"), &pb.SchemaUpdate{ - Predicate: x.GalaxyAttr("address"), + {x.AttrInRootNamespace("address"), &pb.SchemaUpdate{ + Predicate: x.AttrInRootNamespace("address"), ValueType: pb.Posting_STRING, Tokenizer: []string{"term"}, Directive: pb.SchemaUpdate_INDEX, }}, - {x.GalaxyAttr("age"), &pb.SchemaUpdate{ - Predicate: x.GalaxyAttr("age"), + {x.AttrInRootNamespace("age"), &pb.SchemaUpdate{ + Predicate: x.AttrInRootNamespace("age"), ValueType: pb.Posting_INT, Tokenizer: []string{"int"}, Directive: pb.SchemaUpdate_INDEX, }}, - {x.GalaxyAttr("friend"), &pb.SchemaUpdate{ + {x.AttrInRootNamespace("friend"), &pb.SchemaUpdate{ ValueType: pb.Posting_UID, - Predicate: x.GalaxyAttr("friend"), + Predicate: x.AttrInRootNamespace("friend"), Directive: pb.SchemaUpdate_REVERSE, Count: true, List: true, }}, }) - require.True(t, State().IsIndexed(context.Background(), x.GalaxyAttr("name"))) - require.False(t, State().IsReversed(context.Background(), x.GalaxyAttr("name"))) - require.Equal(t, "int", State().Tokenizer(context.Background(), x.GalaxyAttr("age"))[0].Name()) + require.True(t, State().IsIndexed(context.Background(), x.AttrInRootNamespace("name"))) + require.False(t, State().IsReversed(context.Background(), x.AttrInRootNamespace("name"))) + require.Equal(t, "int", State().Tokenizer(context.Background(), x.AttrInRootNamespace("age"))[0].Name()) } func TestParse(t *testing.T) { @@ -298,7 +298,7 @@ func TestParseScalarList(t *testing.T) { require.NoError(t, err) require.Equal(t, 3, len(result.Preds)) require.EqualValues(t, &pb.SchemaUpdate{ - Predicate: x.GalaxyAttr("jobs"), + Predicate: x.AttrInRootNamespace("jobs"), ValueType: 9, Directive: pb.SchemaUpdate_INDEX, Tokenizer: []string{"term"}, @@ -306,13 +306,13 @@ func TestParseScalarList(t *testing.T) { }, result.Preds[0]) require.EqualValues(t, &pb.SchemaUpdate{ - Predicate: x.GalaxyAttr("occupations"), + Predicate: x.AttrInRootNamespace("occupations"), ValueType: 9, List: true, }, result.Preds[1]) require.EqualValues(t, &pb.SchemaUpdate{ - Predicate: x.GalaxyAttr("graduation"), + Predicate: x.AttrInRootNamespace("graduation"), ValueType: 5, List: true, }, result.Preds[2]) @@ -355,7 +355,7 @@ func TestParseUidList(t *testing.T) { require.NoError(t, err) require.Equal(t, 1, len(result.Preds)) require.EqualValues(t, &pb.SchemaUpdate{ - Predicate: x.GalaxyAttr("friend"), + Predicate: x.AttrInRootNamespace("friend"), ValueType: 7, List: true, }, result.Preds[0]) @@ -369,7 +369,7 @@ func TestParseUidSingleValue(t *testing.T) { require.NoError(t, err) require.Equal(t, 1, len(result.Preds)) require.EqualValues(t, &pb.SchemaUpdate{ - Predicate: x.GalaxyAttr("friend"), + Predicate: x.AttrInRootNamespace("friend"), ValueType: 7, List: false, }, result.Preds[0]) @@ -399,7 +399,7 @@ func TestParseEmptyType(t *testing.T) { require.NoError(t, err) require.Equal(t, 1, len(result.Types)) require.Equal(t, &pb.TypeUpdate{ - TypeName: x.GalaxyAttr("Person"), + TypeName: x.AttrInRootNamespace("Person"), }, result.Types[0]) } @@ -412,7 +412,7 @@ func TestParseTypeEOF(t *testing.T) { require.NoError(t, err) require.Equal(t, 1, len(result.Types)) require.Equal(t, &pb.TypeUpdate{ - TypeName: x.GalaxyAttr("Person"), + TypeName: x.AttrInRootNamespace("Person"), }, result.Types[0]) } @@ -427,10 +427,10 @@ func TestParseSingleType(t *testing.T) { require.NoError(t, err) require.Equal(t, 1, len(result.Types)) require.Equal(t, &pb.TypeUpdate{ - TypeName: x.GalaxyAttr("Person"), + TypeName: x.AttrInRootNamespace("Person"), Fields: []*pb.SchemaUpdate{ { - Predicate: x.GalaxyAttr("name"), + Predicate: x.AttrInRootNamespace("name"), }, }, }, result.Types[0]) @@ -447,15 +447,15 @@ func TestParseCombinedSchemasAndTypes(t *testing.T) { require.NoError(t, err) require.Equal(t, 1, len(result.Preds)) require.Equal(t, &pb.SchemaUpdate{ - Predicate: x.GalaxyAttr("name"), + Predicate: x.AttrInRootNamespace("name"), ValueType: 9, }, result.Preds[0]) require.Equal(t, 1, len(result.Types)) require.Equal(t, &pb.TypeUpdate{ - TypeName: x.GalaxyAttr("Person"), + TypeName: x.AttrInRootNamespace("Person"), Fields: []*pb.SchemaUpdate{ { - Predicate: x.GalaxyAttr("name"), + Predicate: x.AttrInRootNamespace("name"), }, }, }, result.Types[0]) @@ -474,18 +474,18 @@ func TestParseMultipleTypes(t *testing.T) { require.NoError(t, err) require.Equal(t, 2, len(result.Types)) require.Equal(t, &pb.TypeUpdate{ - TypeName: x.GalaxyAttr("Person"), + TypeName: x.AttrInRootNamespace("Person"), Fields: []*pb.SchemaUpdate{ { - Predicate: x.GalaxyAttr("name"), + Predicate: x.AttrInRootNamespace("name"), }, }, }, result.Types[0]) require.Equal(t, &pb.TypeUpdate{ - TypeName: x.GalaxyAttr("Animal"), + TypeName: x.AttrInRootNamespace("Animal"), Fields: []*pb.SchemaUpdate{ { - Predicate: x.GalaxyAttr("name"), + Predicate: x.AttrInRootNamespace("name"), }, }, }, result.Types[1]) @@ -515,16 +515,16 @@ func TestOldTypeFormat(t *testing.T) { require.NoError(t, err) require.Equal(t, 1, len(result.Types)) require.Equal(t, &pb.TypeUpdate{ - TypeName: x.GalaxyAttr("Person"), + TypeName: x.AttrInRootNamespace("Person"), Fields: []*pb.SchemaUpdate{ { - Predicate: x.GalaxyAttr("name"), + Predicate: x.AttrInRootNamespace("name"), }, { - Predicate: x.GalaxyAttr("address"), + Predicate: x.AttrInRootNamespace("address"), }, { - Predicate: x.GalaxyAttr("children"), + Predicate: x.AttrInRootNamespace("children"), }, }, }, result.Types[0]) @@ -541,13 +541,13 @@ func TestOldAndNewTypeFormat(t *testing.T) { require.NoError(t, err) require.Equal(t, 1, len(result.Types)) require.Equal(t, &pb.TypeUpdate{ - TypeName: x.GalaxyAttr("Person"), + TypeName: x.AttrInRootNamespace("Person"), Fields: []*pb.SchemaUpdate{ { - Predicate: x.GalaxyAttr("name"), + Predicate: x.AttrInRootNamespace("name"), }, { - Predicate: x.GalaxyAttr("address"), + Predicate: x.AttrInRootNamespace("address"), }, }, }, result.Types[0]) diff --git a/schema/schema.go b/schema/schema.go index 1205fb9d797..0069f728c2a 100644 --- a/schema/schema.go +++ b/schema/schema.go @@ -675,7 +675,7 @@ func initialTypesInternal(namespace uint64, all bool) []*pb.TypeUpdate { }, }) - if namespace == x.GalaxyNamespace { + if namespace == x.RootNamespace { initialTypes = append(initialTypes, &pb.TypeUpdate{ TypeName: "dgraph.namespace", @@ -800,7 +800,7 @@ func initialSchemaInternal(namespace uint64, all bool) []*pb.SchemaUpdate { }, }...) - if namespace == x.GalaxyNamespace { + if namespace == x.RootNamespace { initialSchema = append(initialSchema, []*pb.SchemaUpdate{ { Predicate: "dgraph.namespace.name", diff --git a/systest/backup/advanced-scenarios/127-Namespace/backup_test.go b/systest/backup/advanced-scenarios/127-Namespace/backup_test.go index 47e10398c4d..c24b3a70d97 100755 --- a/systest/backup/advanced-scenarios/127-Namespace/backup_test.go +++ b/systest/backup/advanced-scenarios/127-Namespace/backup_test.go @@ -35,7 +35,7 @@ func Test127PlusNamespaces(t *testing.T) { utilsCommon.CheckItemExists(t, 30, jwtTokenAlpha1Np0, "alpha1") utilsCommon.TakeBackup(t, jwtTokenAlpha1Np0, backupDst, "alpha1") utilsCommon.RunRestore(t, jwtTokenAlpha2Np0, restoreLocation, "alpha2") - dg1 := testutil.DgClientWithLogin(t, "groot", "password", x.GalaxyNamespace) + dg1 := testutil.DgClientWithLogin(t, "groot", "password", x.RootNamespace) testutil.WaitForRestore(t, dg1, alpha2Addr) e2eCommon.AssertGetGQLSchema(t, alpha2Addr, headerAlpha2Np0) utilsCommon.CheckItemExists(t, 30, jwtTokenAlpha2Np0, "alpha2") @@ -47,7 +47,7 @@ func Test127PlusNamespaces(t *testing.T) { utilsCommon.CheckItemExists(t, 70, jwtTokenAlpha1Np51, "alpha1") utilsCommon.TakeBackup(t, jwtTokenAlpha1Np0, backupDst, "alpha1") utilsCommon.RunRestore(t, jwtTokenAlpha2Np0, restoreLocation, "alpha2") - dg2 := testutil.DgClientWithLogin(t, "groot", "password", x.GalaxyNamespace) + dg2 := testutil.DgClientWithLogin(t, "groot", "password", x.RootNamespace) testutil.WaitForRestore(t, dg2, alpha2Addr) e2eCommon.AssertGetGQLSchema(t, alpha2Addr, headerAlpha2Np0) utilsCommon.CheckItemExists(t, 30, jwtTokenAlpha2Np0, "alpha2") @@ -62,7 +62,7 @@ func Test127PlusNamespaces(t *testing.T) { utilsCommon.CheckItemExists(t, 110, jwtTokenAlpha1Np130, "alpha1") utilsCommon.TakeBackup(t, jwtTokenAlpha1Np0, backupDst, "alpha1") utilsCommon.RunRestore(t, jwtTokenAlpha2Np0, restoreLocation, "alpha2") - dg3 := testutil.DgClientWithLogin(t, "groot", "password", x.GalaxyNamespace) + dg3 := testutil.DgClientWithLogin(t, "groot", "password", x.RootNamespace) testutil.WaitForRestore(t, dg3, alpha2Addr) e2eCommon.AssertGetGQLSchema(t, alpha2Addr, headerAlpha2Np0) utilsCommon.CheckItemExists(t, 30, jwtTokenAlpha2Np0, "alpha2") diff --git a/systest/backup/advanced-scenarios/acl-nonAcl/backup_test.go b/systest/backup/advanced-scenarios/acl-nonAcl/backup_test.go index b833ea85686..63a259674b2 100755 --- a/systest/backup/advanced-scenarios/acl-nonAcl/backup_test.go +++ b/systest/backup/advanced-scenarios/acl-nonAcl/backup_test.go @@ -43,7 +43,7 @@ func BackupRestore(t *testing.T, jwtTokenBackupAlpha string, jwtTokenRestoreAlph utilsCommon.CheckItemExists(t, 5, jwtTokenBackupAlpha, backupAlpha) utilsCommon.TakeBackup(t, jwtTokenBackupAlpha, backupDst, backupAlpha) utilsCommon.RunRestore(t, jwtTokenRestoreAlpha, restoreLocation, restoreAlpha) - dg := testutil.DgClientWithLogin(t, "groot", "password", x.GalaxyNamespace) + dg := testutil.DgClientWithLogin(t, "groot", "password", x.RootNamespace) testutil.WaitForRestore(t, dg, testutil.ContainerAddr(restoreAlpha, 8080)) utilsCommon.CheckItemExists(t, 5, jwtTokenRestoreAlpha, restoreAlpha) } diff --git a/systest/backup/advanced-scenarios/deleted-namespace/backup_test.go b/systest/backup/advanced-scenarios/deleted-namespace/backup_test.go index 46f4c4a16a2..b242281c7fa 100755 --- a/systest/backup/advanced-scenarios/deleted-namespace/backup_test.go +++ b/systest/backup/advanced-scenarios/deleted-namespace/backup_test.go @@ -10,11 +10,12 @@ package main import ( "testing" + "github.com/stretchr/testify/require" + e2eCommon "github.com/hypermodeinc/dgraph/v25/graphql/e2e/common" utilsCommon "github.com/hypermodeinc/dgraph/v25/systest/backup/common" "github.com/hypermodeinc/dgraph/v25/testutil" "github.com/hypermodeinc/dgraph/v25/x" - "github.com/stretchr/testify/require" ) const ( @@ -42,7 +43,7 @@ func TestDeletedNamespaceID(t *testing.T) { e2eCommon.DeleteNamespace(t, ns1[2], headerAlpha1Np0, "alpha1") utilsCommon.TakeBackup(t, jwtTokenAlpha1Np0, backupDst, "alpha1") utilsCommon.RunRestore(t, jwtTokenAlpha2Np0, restoreLocation, "alpha2") - dg1 := testutil.DgClientWithLogin(t, "groot", "password", x.GalaxyNamespace) + dg1 := testutil.DgClientWithLogin(t, "groot", "password", x.RootNamespace) testutil.WaitForRestore(t, dg1, testutil.ContainerAddr("alpha2", 8080)) lastAddedNamespaceId := e2eCommon.CreateNamespace(t, headerAlpha2Np0, "alpha2") require.Equal(t, lastAddedNamespaceId > ns1[3], true) diff --git a/systest/backup/encryption/backup_test.go b/systest/backup/encryption/backup_test.go index ff1b6fead51..05e9a499377 100644 --- a/systest/backup/encryption/backup_test.go +++ b/systest/backup/encryption/backup_test.go @@ -85,7 +85,7 @@ func TestBackupMinioE(t *testing.T) { t.Logf("--- Original uid mapping: %+v\n", original.Uids) client := testutil.GetHttpsClient(t) - tabletName := x.NamespaceAttr(x.GalaxyNamespace, "movie") + tabletName := x.NamespaceAttr(x.RootNamespace, "movie") // Move tablet to group 1 to avoid messes later. _, err = client.Get("https://" + testutil.SockAddrZeroHttp + "/moveTablet?tablet=movie&group=1") require.NoError(t, err) @@ -320,7 +320,7 @@ func runRestore(t *testing.T, lastDir string, commitTs uint64) map[string]string require.Equal(t, uint32(i+1), groupId) } pdir := "./data/restore/p1" - restored, err := testutil.GetPredicateValues(pdir, x.GalaxyAttr("movie"), commitTs) + restored, err := testutil.GetPredicateValues(pdir, x.AttrInRootNamespace("movie"), commitTs) require.NoError(t, err) restoredPreds, err := testutil.GetPredicateNames(pdir) diff --git a/systest/backup/filesystem/backup_test.go b/systest/backup/filesystem/backup_test.go index be1488e3b7c..b647d7608e4 100644 --- a/systest/backup/filesystem/backup_test.go +++ b/systest/backup/filesystem/backup_test.go @@ -199,7 +199,7 @@ func TestBackupFilesystem(t *testing.T) { for retry := 5; retry > 0; retry-- { state, err := testutil.GetStateHttps(testutil.GetAlphaClientConfig(t)) require.NoError(t, err) - if _, ok := state.Groups["1"].Tablets[x.NamespaceAttr(x.GalaxyNamespace, "movie")]; ok { + if _, ok := state.Groups["1"].Tablets[x.NamespaceAttr(x.RootNamespace, "movie")]; ok { moveOk = true break } @@ -467,7 +467,7 @@ func runRestore(t *testing.T, backupLocation, lastDir string, commitTs uint64) m } pdir := "./data/restore/p1" - restored, err := testutil.GetPredicateValues(pdir, x.GalaxyAttr("movie"), commitTs) + restored, err := testutil.GetPredicateValues(pdir, x.AttrInRootNamespace("movie"), commitTs) require.NoError(t, err) t.Logf("--- Restored values: %+v\n", restored) return restored diff --git a/systest/backup/minio-large/backup_test.go b/systest/backup/minio-large/backup_test.go index d909b5b44e0..91923ee1d9e 100644 --- a/systest/backup/minio-large/backup_test.go +++ b/systest/backup/minio-large/backup_test.go @@ -104,9 +104,9 @@ func setupTablets(t *testing.T, dg *dgo.Dgraph) { for retry := 5; retry > 0; retry-- { state, err := testutil.GetStateHttps(testutil.GetAlphaClientConfig(t)) require.NoError(t, err) - _, ok1 := state.Groups["1"].Tablets[x.GalaxyAttr("name1")] - _, ok2 := state.Groups["2"].Tablets[x.GalaxyAttr("name2")] - _, ok3 := state.Groups["3"].Tablets[x.GalaxyAttr("name3")] + _, ok1 := state.Groups["1"].Tablets[x.AttrInRootNamespace("name1")] + _, ok2 := state.Groups["2"].Tablets[x.AttrInRootNamespace("name2")] + _, ok3 := state.Groups["3"].Tablets[x.AttrInRootNamespace("name3")] if ok1 && ok2 && ok3 { moveOk = true break @@ -182,11 +182,11 @@ func runRestore(t *testing.T, backupLocation, lastDir string, commitTs uint64) m lastDir, "", nil, options.Snappy, 0) require.NoError(t, result.Err) - restored1, err := testutil.GetPredicateValues("./data/restore/p1", x.GalaxyAttr("name1"), commitTs) + restored1, err := testutil.GetPredicateValues("./data/restore/p1", x.AttrInRootNamespace("name1"), commitTs) require.NoError(t, err) - restored2, err := testutil.GetPredicateValues("./data/restore/p2", x.GalaxyAttr("name2"), commitTs) + restored2, err := testutil.GetPredicateValues("./data/restore/p2", x.AttrInRootNamespace("name2"), commitTs) require.NoError(t, err) - restored3, err := testutil.GetPredicateValues("./data/restore/p3", x.GalaxyAttr("name3"), commitTs) + restored3, err := testutil.GetPredicateValues("./data/restore/p3", x.AttrInRootNamespace("name3"), commitTs) require.NoError(t, err) restored := make(map[string]string) diff --git a/systest/backup/minio/backup_test.go b/systest/backup/minio/backup_test.go index 0fdef18f757..04b8a79199a 100644 --- a/systest/backup/minio/backup_test.go +++ b/systest/backup/minio/backup_test.go @@ -92,7 +92,7 @@ func TestBackupMinio(t *testing.T) { for retry := 5; retry > 0; retry-- { state, err := testutil.GetStateHttps(testutil.GetAlphaClientConfig(t)) require.NoError(t, err) - if _, ok := state.Groups["1"].Tablets[x.NamespaceAttr(x.GalaxyNamespace, "movie")]; ok { + if _, ok := state.Groups["1"].Tablets[x.NamespaceAttr(x.RootNamespace, "movie")]; ok { moveOk = true break } @@ -347,7 +347,7 @@ func runRestore(t *testing.T, lastDir string, commitTs uint64) map[string]string require.Equal(t, uint32(i+1), groupId) } pdir := "./data/restore/p1" - restored, err := testutil.GetPredicateValues(pdir, x.GalaxyAttr("movie"), commitTs) + restored, err := testutil.GetPredicateValues(pdir, x.AttrInRootNamespace("movie"), commitTs) require.NoError(t, err) t.Logf("--- Restored values: %+v\n", restored) return restored diff --git a/systest/backup/multi-tenancy/backup_test.go b/systest/backup/multi-tenancy/backup_test.go index c4330aa4906..70ca6725620 100644 --- a/systest/backup/multi-tenancy/backup_test.go +++ b/systest/backup/multi-tenancy/backup_test.go @@ -31,10 +31,10 @@ var ( func TestBackupMultiTenancy(t *testing.T) { ctx := context.Background() - dg := testutil.DgClientWithLogin(t, "groot", "password", x.GalaxyNamespace) + dg := testutil.DgClientWithLogin(t, "groot", "password", x.RootNamespace) testutil.DropAll(t, dg) - galaxyCreds := &testutil.LoginParams{UserID: "groot", Passwd: "password", Namespace: x.GalaxyNamespace} + galaxyCreds := &testutil.LoginParams{UserID: "groot", Passwd: "password", Namespace: x.RootNamespace} galaxyToken, err := testutil.Login(t, galaxyCreds) require.NoError(t, err, "login failed") @@ -84,7 +84,7 @@ func TestBackupMultiTenancy(t *testing.T) { } original := make(map[uint64]*api.Response) - original[x.GalaxyNamespace] = addData(dg, "galaxy") + original[x.RootNamespace] = addData(dg, "galaxy") original[ns1] = addData(dg1, "ns1") original[ns2] = addData(dg2, "ns2") diff --git a/systest/backup/nfs-backup/backup_test.go b/systest/backup/nfs-backup/backup_test.go index ff15bc4e533..aad520de74f 100644 --- a/systest/backup/nfs-backup/backup_test.go +++ b/systest/backup/nfs-backup/backup_test.go @@ -87,7 +87,7 @@ func backupRestoreTest(t *testing.T, backupAlphaSocketAddr string, restoreAlphaA for !moveOk { state, err := testutil.GetState() require.NoError(t, err) - if _, ok := state.Groups["1"].Tablets[x.NamespaceAttr(x.GalaxyNamespace, "movie")]; ok { + if _, ok := state.Groups["1"].Tablets[x.NamespaceAttr(x.RootNamespace, "movie")]; ok { moveOk = true break } diff --git a/systest/cloud/cloud_test.go b/systest/cloud/cloud_test.go index b49bfcf3cbf..f1ce75dd43a 100644 --- a/systest/cloud/cloud_test.go +++ b/systest/cloud/cloud_test.go @@ -23,7 +23,7 @@ import ( ) func setup(t *testing.T) { - dc := testutil.DgClientWithLogin(t, "groot", "password", x.GalaxyNamespace) + dc := testutil.DgClientWithLogin(t, "groot", "password", x.RootNamespace) require.NoError(t, dc.Alter(context.Background(), &api.Operation{DropAll: true})) } @@ -63,7 +63,7 @@ func graphqlHelper(t *testing.T, query string, headers http.Header, func TestDisallowNonGalaxy(t *testing.T) { setup(t) - galaxyToken := getHttpToken(t, "groot", "password", x.GalaxyNamespace) + galaxyToken := getHttpToken(t, "groot", "password", x.RootNamespace) // Create a new namespace ns, err := testutil.CreateNamespaceWithRetry(t, galaxyToken) require.NoError(t, err) @@ -123,12 +123,12 @@ func TestDisallowNonGalaxy(t *testing.T) { require.Error(t, err) require.Contains(t, err.Error(), "operation is not allowed in shared cloud mode") - // Ns guardian should not be able to create user. + // Ns superadmin should not be able to create user. resp := testutil.CreateUser(t, nsToken, "alice", "newpassword") require.Greater(t, len(resp.Errors), 0) require.Contains(t, resp.Errors.Error(), "unauthorized to mutate acl predicates") - // Galaxy guardian should be able to create user. + // root superadmin should be able to create user. resp = testutil.CreateUser(t, galaxyToken, "alice", "newpassword") require.Equal(t, 0, len(resp.Errors)) } @@ -136,7 +136,7 @@ func TestDisallowNonGalaxy(t *testing.T) { func TestEnvironmentAccess(t *testing.T) { setup(t) - galaxyToken := getHttpToken(t, "groot", "password", x.GalaxyNamespace) + galaxyToken := getHttpToken(t, "groot", "password", x.RootNamespace) // Create a new namespace ns, err := testutil.CreateNamespaceWithRetry(t, galaxyToken) require.NoError(t, err) diff --git a/systest/integration2/acl_test.go b/systest/integration2/acl_test.go index 91c2d969d31..55a0f27a72e 100644 --- a/systest/integration2/acl_test.go +++ b/systest/integration2/acl_test.go @@ -45,12 +45,12 @@ func testDuplicateUserUpgradeStrat(t *testing.T, strat dgraphtest.UpgradeStrateg require.NoError(t, err) defer cleanup() require.NoError(t, gc.LoginIntoNamespace(context.Background(), - dgraphapi.DefaultUser, dgraphapi.DefaultPassword, x.GalaxyNamespace)) + dgraphapi.DefaultUser, dgraphapi.DefaultPassword, x.RootNamespace)) hc, err := c.HTTPClient() require.NoError(t, err) require.NoError(t, hc.LoginIntoNamespace(dgraphapi.DefaultUser, - dgraphapi.DefaultPassword, x.GalaxyNamespace)) + dgraphapi.DefaultPassword, x.RootNamespace)) require.NoError(t, gc.SetupSchema(`name: string .`)) rdfs := ` @@ -64,12 +64,12 @@ func testDuplicateUserUpgradeStrat(t *testing.T, strat dgraphtest.UpgradeStrateg require.NoError(t, err) defer cleanup() require.NoError(t, gc.LoginIntoNamespace(context.Background(), - dgraphapi.DefaultUser, dgraphapi.DefaultPassword, x.GalaxyNamespace)) + dgraphapi.DefaultUser, dgraphapi.DefaultPassword, x.RootNamespace)) hc, err = c.HTTPClient() require.NoError(t, err) require.NoError(t, hc.LoginIntoNamespace(dgraphapi.DefaultUser, - dgraphapi.DefaultPassword, x.GalaxyNamespace)) + dgraphapi.DefaultPassword, x.RootNamespace)) query := "schema {}" resp, err := gc.Query(query) diff --git a/systest/integration2/bulk_loader_test.go b/systest/integration2/bulk_loader_test.go index a691857b0a6..b6e8b855eed 100644 --- a/systest/integration2/bulk_loader_test.go +++ b/systest/integration2/bulk_loader_test.go @@ -15,8 +15,8 @@ import ( "github.com/hypermodeinc/dgraph/v25/dgraphapi" "github.com/hypermodeinc/dgraph/v25/dgraphtest" - "github.com/hypermodeinc/dgraph/v25/x" + "github.com/stretchr/testify/require" ) @@ -92,7 +92,7 @@ func TestBulkLoaderNoDqlSchema(t *testing.T) { hc, err := c.HTTPClient() require.NoError(t, err) require.NoError(t, hc.LoginIntoNamespace(dgraphapi.DefaultUser, - dgraphapi.DefaultPassword, x.GalaxyNamespace)) + dgraphapi.DefaultPassword, x.RootNamespace)) params := dgraphapi.GraphQLParams{ Query: `query { diff --git a/systest/integration2/graphql_schema_auth_test.go b/systest/integration2/graphql_schema_auth_test.go index 7c8d444b012..b6544cec8c6 100644 --- a/systest/integration2/graphql_schema_auth_test.go +++ b/systest/integration2/graphql_schema_auth_test.go @@ -29,7 +29,7 @@ func TestGraphqlSchema(t *testing.T) { hc, err := c.HTTPClient() require.NoError(t, err) require.NoError(t, hc.LoginIntoNamespace(dgraphapi.DefaultUser, - dgraphapi.DefaultPassword, x.GalaxyNamespace)) + dgraphapi.DefaultPassword, x.RootNamespace)) // DGRAPHCORE-329 //nolint:lll diff --git a/systest/integration2/incremental_restore_test.go b/systest/integration2/incremental_restore_test.go index 26f3518fbc6..c914ee23c2d 100644 --- a/systest/integration2/incremental_restore_test.go +++ b/systest/integration2/incremental_restore_test.go @@ -34,12 +34,12 @@ func TestIncrementalRestore(t *testing.T) { require.NoError(t, err) defer cleanup() require.NoError(t, gc.LoginIntoNamespace(context.Background(), - dgraphapi.DefaultUser, dgraphapi.DefaultPassword, x.GalaxyNamespace)) + dgraphapi.DefaultUser, dgraphapi.DefaultPassword, x.RootNamespace)) hc, err := c.HTTPClient() require.NoError(t, err) require.NoError(t, hc.LoginIntoNamespace(dgraphapi.DefaultUser, - dgraphapi.DefaultPassword, x.GalaxyNamespace)) + dgraphapi.DefaultPassword, x.RootNamespace)) uids := []int{1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20} c.AssignUids(gc.Dgraph, uint64(len(uids))) diff --git a/systest/integration2/snapshot_test.go b/systest/integration2/snapshot_test.go index 6dad16e490c..0295eec0f0d 100644 --- a/systest/integration2/snapshot_test.go +++ b/systest/integration2/snapshot_test.go @@ -33,13 +33,13 @@ func TestSnapshotTranferAfterNewNodeJoins(t *testing.T) { hc, err := c.HTTPClient() require.NoError(t, err) - hc.LoginIntoNamespace(dgraphapi.DefaultUser, dgraphapi.DefaultPassword, x.GalaxyNamespace) + require.NoError(t, hc.LoginIntoNamespace(dgraphapi.DefaultUser, dgraphapi.DefaultPassword, x.RootNamespace)) gc, cleanup, err := c.Client() require.NoError(t, err) defer cleanup() require.NoError(t, gc.LoginIntoNamespace(context.Background(), - dgraphapi.DefaultUser, dgraphapi.DefaultPassword, x.GalaxyNamespace)) + dgraphapi.DefaultUser, dgraphapi.DefaultPassword, x.RootNamespace)) prevSnapshotTs, err := hc.GetCurrentSnapshotTs(1) require.NoError(t, err) diff --git a/systest/multi-tenancy/basic_test.go b/systest/multi-tenancy/basic_test.go index cfbca1e651e..8d57ae65971 100644 --- a/systest/multi-tenancy/basic_test.go +++ b/systest/multi-tenancy/basic_test.go @@ -29,11 +29,11 @@ const ( func (msuite *MultitenancyTestSuite) TestAclBasic() { t := msuite.T() - // Galaxy Login + // Root Namespace Login hcli, err := msuite.dc.HTTPClient() require.NoError(t, err) - err = hcli.LoginIntoNamespace(dgraphapi.DefaultUser, dgraphapi.DefaultPassword, x.GalaxyNamespace) - require.NotNil(t, hcli.AccessJwt, "galaxy token is nil") + err = hcli.LoginIntoNamespace(dgraphapi.DefaultUser, dgraphapi.DefaultPassword, x.RootNamespace) + require.NotNil(t, hcli.AccessJwt, "root ns token is nil") require.NoError(t, err, "login with namespace failed") // Create a new namespace @@ -74,7 +74,7 @@ func (msuite *MultitenancyTestSuite) TestAclBasic() { defer cleanup() require.NoError(t, err) require.NoError(t, gcli.LoginIntoNamespace(context.Background(), - dgraphapi.DefaultUser, dgraphapi.DefaultPassword, x.GalaxyNamespace)) + dgraphapi.DefaultUser, dgraphapi.DefaultPassword, x.RootNamespace)) resp, err = gcli.Query(query) require.NoError(t, err) require.NoError(t, dgraphapi.CompareJSON(`{"me": []}`, string(resp.Json))) @@ -115,12 +115,12 @@ func (msuite *MultitenancyTestSuite) TestAclBasic() { func (msuite *MultitenancyTestSuite) TestNameSpaceLimitFlag() { t := msuite.T() - // Galaxy login + // Root Namespace login hcli, err := msuite.dc.HTTPClient() require.NoError(t, err) - err = hcli.LoginIntoNamespace(dgraphapi.DefaultUser, dgraphapi.DefaultPassword, x.GalaxyNamespace) - require.NotNil(t, hcli.AccessJwt, "galaxy token is nil") - require.NoErrorf(t, err, "login as groot into namespace %d failed", x.GalaxyNamespace) + err = hcli.LoginIntoNamespace(dgraphapi.DefaultUser, dgraphapi.DefaultPassword, x.RootNamespace) + require.NotNil(t, hcli.AccessJwt, "root ns token is nil") + require.NoErrorf(t, err, "login as groot into namespace %d failed", x.RootNamespace) // Create a new namespace ns, err := hcli.AddNamespace() @@ -154,12 +154,12 @@ func (msuite *MultitenancyTestSuite) TestNameSpaceLimitFlag() { func (msuite *MultitenancyTestSuite) TestPersistentQuery() { t := msuite.T() - // Galaxy Login + // Root Namespace Login hcli1, err := msuite.dc.HTTPClient() require.NoError(t, err) - err = hcli1.LoginIntoNamespace(dgraphapi.DefaultUser, dgraphapi.DefaultPassword, x.GalaxyNamespace) - require.NotNil(t, hcli1.AccessJwt, "galaxy token is nil") - require.NoErrorf(t, err, "login as groot into namespace %d failed", x.GalaxyNamespace) + err = hcli1.LoginIntoNamespace(dgraphapi.DefaultUser, dgraphapi.DefaultPassword, x.RootNamespace) + require.NotNil(t, hcli1.AccessJwt, "root ns token is nil") + require.NoErrorf(t, err, "login as groot into namespace %d failed", x.RootNamespace) // Create a new namespace ns, err := hcli1.AddNamespace() @@ -168,12 +168,12 @@ func (msuite *MultitenancyTestSuite) TestPersistentQuery() { // Upgrade msuite.Upgrade() - // Galaxy Login + // Root Namespace Login hcli1, err = msuite.dc.HTTPClient() require.NoError(t, err) - err = hcli1.LoginIntoNamespace(dgraphapi.DefaultUser, dgraphapi.DefaultPassword, x.GalaxyNamespace) - require.NotNil(t, hcli1.AccessJwt, "galaxy token is nil") - require.NoErrorf(t, err, "login as groot into namespace %d failed", x.GalaxyNamespace) + err = hcli1.LoginIntoNamespace(dgraphapi.DefaultUser, dgraphapi.DefaultPassword, x.RootNamespace) + require.NotNil(t, hcli1.AccessJwt, "root ns token is nil") + require.NoErrorf(t, err, "login as groot into namespace %d failed", x.RootNamespace) // Log into ns hcli2, err := msuite.dc.HTTPClient() @@ -217,12 +217,12 @@ func (msuite *MultitenancyTestSuite) TestPersistentQuery() { func (msuite *MultitenancyTestSuite) TestTokenExpired() { t := msuite.T() - // Galaxy Login + // Root Namespace Login hcli, err := msuite.dc.HTTPClient() require.NoError(t, err) - err = hcli.LoginIntoNamespace(dgraphapi.DefaultUser, dgraphapi.DefaultPassword, x.GalaxyNamespace) - require.NotNil(t, hcli.HttpToken, "galaxy token is nil") - require.NoErrorf(t, err, "login as groot into namespace %d failed", x.GalaxyNamespace) + err = hcli.LoginIntoNamespace(dgraphapi.DefaultUser, dgraphapi.DefaultPassword, x.RootNamespace) + require.NotNil(t, hcli.HttpToken, "root ns token is nil") + require.NoErrorf(t, err, "login as groot into namespace %d failed", x.RootNamespace) // Create a new namespace ns, err := hcli.AddNamespace() @@ -247,18 +247,18 @@ func (msuite *MultitenancyTestSuite) TestTokenExpired() { // Create another namespace _, err = hcli.AddNamespace() require.Error(t, err) - require.Contains(t, err.Error(), "Only guardian of galaxy is allowed to do this operation") + require.Contains(t, err.Error(), "Only superadmin is allowed to do this operation") } func (msuite *MultitenancyTestSuite) TestTwoPermissionSetsInNameSpacesWithAcl() { t := msuite.T() - // Galaxy Login + // Root Namespace Login ghcli, err := msuite.dc.HTTPClient() require.NoError(t, err) - err = ghcli.LoginIntoNamespace(dgraphapi.DefaultUser, dgraphapi.DefaultPassword, x.GalaxyNamespace) - require.NotNil(t, ghcli, "galaxy token is nil") - require.NoErrorf(t, err, "login as groot into namespace %d failed", x.GalaxyNamespace) + err = ghcli.LoginIntoNamespace(dgraphapi.DefaultUser, dgraphapi.DefaultPassword, x.RootNamespace) + require.NotNil(t, ghcli, "root ns token is nil") + require.NoErrorf(t, err, "login as groot into namespace %d failed", x.RootNamespace) query := `{ me(func: has(name)) { @@ -368,11 +368,11 @@ func (msuite *MultitenancyTestSuite) TestTwoPermissionSetsInNameSpacesWithAcl() func (msuite *MultitenancyTestSuite) TestCreateNamespace() { t := msuite.T() - // Galaxy Login + // Root Namespace Login hcli, err := msuite.dc.HTTPClient() require.NoError(t, err) - err = hcli.LoginIntoNamespace(dgraphapi.DefaultUser, dgraphapi.DefaultPassword, x.GalaxyNamespace) - require.NotNil(t, hcli.AccessJwt, "Galaxy token is nil") + err = hcli.LoginIntoNamespace(dgraphapi.DefaultUser, dgraphapi.DefaultPassword, x.RootNamespace) + require.NotNil(t, hcli.AccessJwt, "root ns token is nil") require.NoErrorf(t, err, "login failed") // Create a new namespace @@ -392,17 +392,17 @@ func (msuite *MultitenancyTestSuite) TestCreateNamespace() { // Create a new namespace using guardian of other namespace. _, err = hcli.AddNamespace() require.Error(t, err) - require.Contains(t, err.Error(), "Only guardian of galaxy is allowed to do this operation") + require.Contains(t, err.Error(), "Only superadmin is allowed to do this operation") } func (msuite *MultitenancyTestSuite) TestResetPassword() { t := msuite.T() - // Galaxy Login + // Root Namespace Login hcli1, err := msuite.dc.HTTPClient() require.NoError(t, err) - err = hcli1.LoginIntoNamespace(dgraphapi.DefaultUser, dgraphapi.DefaultPassword, x.GalaxyNamespace) - require.NotNil(t, hcli1.HttpToken, "Galaxy token is nil") + err = hcli1.LoginIntoNamespace(dgraphapi.DefaultUser, dgraphapi.DefaultPassword, x.RootNamespace) + require.NotNil(t, hcli1.HttpToken, "root ns token is nil") require.NoErrorf(t, err, "login failed") // Create a new namespace @@ -434,10 +434,10 @@ func (msuite *MultitenancyTestSuite) TestResetPassword() { func (msuite *MultitenancyTestSuite) TestDeleteNamespace() { t := msuite.T() - // Galaxy Login + // Root Namespace Login hcli, err := msuite.dc.HTTPClient() require.NoError(t, err) - err = hcli.LoginIntoNamespace(dgraphapi.DefaultUser, dgraphapi.DefaultPassword, x.GalaxyNamespace) + err = hcli.LoginIntoNamespace(dgraphapi.DefaultUser, dgraphapi.DefaultPassword, x.RootNamespace) require.NoErrorf(t, err, "login failed") dg := make(map[uint64]*dgraphapi.GrpcClient) @@ -445,8 +445,8 @@ func (msuite *MultitenancyTestSuite) TestDeleteNamespace() { defer cleanup() require.NoError(t, e) require.NoError(t, gcli.LoginIntoNamespace(context.Background(), - dgraphapi.DefaultUser, dgraphapi.DefaultPassword, x.GalaxyNamespace)) - dg[x.GalaxyNamespace] = gcli + dgraphapi.DefaultUser, dgraphapi.DefaultPassword, x.RootNamespace)) + dg[x.RootNamespace] = gcli // Create a new namespace ns, err := hcli.AddNamespace() @@ -483,8 +483,8 @@ func (msuite *MultitenancyTestSuite) TestDeleteNamespace() { require.NoError(t, dgraphapi.CompareJSON(expected, string(resp.Json))) } - require.NoError(t, addData(x.GalaxyNamespace)) - check(x.GalaxyNamespace, `{"me": [{"name":"0"}]}`) + require.NoError(t, addData(x.RootNamespace)) + check(x.RootNamespace, `{"me": [{"name":"0"}]}`) require.NoError(t, addData(ns)) check(ns, fmt.Sprintf(`{"me": [{"name":"%d"}]}`, ns)) @@ -497,8 +497,8 @@ func (msuite *MultitenancyTestSuite) TestDeleteNamespace() { defer cleanup() require.NoError(t, err) require.NoError(t, gcli.LoginIntoNamespace(context.Background(), - dgraphapi.DefaultUser, dgraphapi.DefaultPassword, x.GalaxyNamespace)) - dg[x.GalaxyNamespace] = gcli + dgraphapi.DefaultUser, dgraphapi.DefaultPassword, x.RootNamespace)) + dg[x.RootNamespace] = gcli // Log into namespace as groot gcli, cleanup, err = msuite.dc.Client() @@ -508,24 +508,24 @@ func (msuite *MultitenancyTestSuite) TestDeleteNamespace() { dgraphapi.DefaultUser, dgraphapi.DefaultPassword, ns)) dg[ns] = gcli - // Galaxy Login + // Root Namespace Login hcli, err = msuite.dc.HTTPClient() require.NoError(t, err) - err = hcli.LoginIntoNamespace(dgraphapi.DefaultUser, dgraphapi.DefaultPassword, x.GalaxyNamespace) + err = hcli.LoginIntoNamespace(dgraphapi.DefaultUser, dgraphapi.DefaultPassword, x.RootNamespace) require.NoError(t, err, "login failed") // Delete namespace nid, err := hcli.DeleteNamespace(ns) require.NoError(t, err) require.Equal(t, ns, nid) - require.NoError(t, addData(x.GalaxyNamespace)) - check(x.GalaxyNamespace, `{"me": [{"name":"0"}, {"name":"0"}]}`) + require.NoError(t, addData(x.RootNamespace)) + check(x.RootNamespace, `{"me": [{"name":"0"}, {"name":"0"}]}`) err = addData(ns) require.Contains(t, err.Error(), "Key is using the banned prefix") check(ns, `{"me": []}`) - // No one should be able to delete the default namespace. Not even guardian of galaxy. - _, err = hcli.DeleteNamespace(x.GalaxyNamespace) + // No one should be able to delete the default namespace. Not even superadmin. + _, err = hcli.DeleteNamespace(x.RootNamespace) require.Error(t, err) require.Contains(t, err.Error(), "Cannot delete default namespace") diff --git a/systest/multi-tenancy/integration_basic_helper_test.go b/systest/multi-tenancy/integration_basic_helper_test.go index 2593d554405..e14f1f19f71 100644 --- a/systest/multi-tenancy/integration_basic_helper_test.go +++ b/systest/multi-tenancy/integration_basic_helper_test.go @@ -56,11 +56,11 @@ func (msuite *MultitenancyTestSuite) TestLiveLoadMulti() { defer cleanup() require.NoError(t, err) require.NoError(t, gcli0.LoginIntoNamespace(context.Background(), - dgraphapi.DefaultUser, dgraphapi.DefaultPassword, x.GalaxyNamespace)) + dgraphapi.DefaultUser, dgraphapi.DefaultPassword, x.RootNamespace)) hcli, err := msuite.dc.HTTPClient() require.NoError(t, err) - err = hcli.LoginIntoNamespace(dgraphapi.DefaultUser, dgraphapi.DefaultPassword, x.GalaxyNamespace) + err = hcli.LoginIntoNamespace(dgraphapi.DefaultUser, dgraphapi.DefaultPassword, x.RootNamespace) require.NoError(t, err, "login failed") // Create a new namespace @@ -73,8 +73,8 @@ func (msuite *MultitenancyTestSuite) TestLiveLoadMulti() { dgraphapi.DefaultUser, dgraphapi.DefaultPassword, ns)) // Load data. - galaxyCreds := &testutil.LoginParams{UserID: dgraphapi.DefaultUser, - Passwd: dgraphapi.DefaultPassword, Namespace: x.GalaxyNamespace} + rootNsCreds := &testutil.LoginParams{UserID: dgraphapi.DefaultUser, + Passwd: dgraphapi.DefaultPassword, Namespace: x.RootNamespace} require.NoError(t, msuite.liveLoadData(&liveOpts{ rdfs: fmt.Sprintf(` _:a "galaxy alice" . @@ -86,7 +86,7 @@ func (msuite *MultitenancyTestSuite) TestLiveLoadMulti() { name: string @index(term) . [%#x] name: string . `, ns), - creds: galaxyCreds, + creds: rootNsCreds, forceNs: -1, })) @@ -121,7 +121,7 @@ func (msuite *MultitenancyTestSuite) TestLiveLoadMulti() { require.Error(t, err) require.Contains(t, err.Error(), "Attribute name is not indexed") - // live load data into namespace ns using the guardian of galaxy. + // live load data into namespace ns using the superadmin in root namespace. require.NoError(t, msuite.liveLoadData(&liveOpts{ rdfs: fmt.Sprintf(` _:a "ns chew" . @@ -131,7 +131,7 @@ func (msuite *MultitenancyTestSuite) TestLiveLoadMulti() { schema: ` name: string @index(term) . `, - creds: galaxyCreds, + creds: rootNsCreds, forceNs: int64(ns), })) @@ -144,7 +144,7 @@ func (msuite *MultitenancyTestSuite) TestLiveLoadMulti() { err = msuite.liveLoadData(&liveOpts{ rdfs: fmt.Sprintf(`_:c "ns eon" <%#x> .`, ns), schema: `name: string @index(term) .`, - creds: galaxyCreds, + creds: rootNsCreds, forceNs: int64(0x123456), // Assuming this namespace does not exist. }) require.Error(t, err) @@ -154,7 +154,7 @@ func (msuite *MultitenancyTestSuite) TestLiveLoadMulti() { err = msuite.liveLoadData(&liveOpts{ rdfs: fmt.Sprintf(`_:c "ns eon" <%#x> .`, ns), schema: `[0x123456] name: string @index(term) .`, - creds: galaxyCreds, + creds: rootNsCreds, forceNs: -1, }) require.Error(t, err) @@ -163,7 +163,7 @@ func (msuite *MultitenancyTestSuite) TestLiveLoadMulti() { err = msuite.liveLoadData(&liveOpts{ rdfs: `_:c "ns eon" <0x123456> .`, schema: `name: string @index(term) .`, - creds: galaxyCreds, + creds: rootNsCreds, forceNs: -1, }) require.Error(t, err) diff --git a/systest/multi-tenancy/integration_test.go b/systest/multi-tenancy/integration_test.go index f97c8f56611..b19f3df0609 100644 --- a/systest/multi-tenancy/integration_test.go +++ b/systest/multi-tenancy/integration_test.go @@ -35,7 +35,7 @@ func (msuite *MultitenancyTestSuite) TearDownTest() { defer cleanup() require.NoError(t, err) require.NoError(t, gcli.LoginIntoNamespace(context.Background(), - dgraphapi.DefaultUser, dgraphapi.DefaultPassword, x.GalaxyNamespace)) + dgraphapi.DefaultUser, dgraphapi.DefaultPassword, x.RootNamespace)) require.NoError(t, gcli.Alter(context.Background(), &api.Operation{DropAll: true})) } diff --git a/systest/multi-tenancy/login_test.go b/systest/multi-tenancy/login_test.go index 3ae148a962b..ec4767bffb8 100644 --- a/systest/multi-tenancy/login_test.go +++ b/systest/multi-tenancy/login_test.go @@ -41,10 +41,10 @@ func (msuite *MultitenancyTestSuite) TestLoggingIntoTheNSAfterDropDataFromTheNS( require.NoError(t, err) require.NoError(t, gc.LoginIntoNamespace(context.Background(), - dgraphapi.DefaultUser, dgraphapi.DefaultPassword, x.GalaxyNamespace)) + dgraphapi.DefaultUser, dgraphapi.DefaultPassword, x.RootNamespace)) require.NoError(t, gc.DropAll()) - require.NoError(t, hc.LoginIntoNamespace(dgraphapi.DefaultUser, dgraphapi.DefaultPassword, x.GalaxyNamespace)) + require.NoError(t, hc.LoginIntoNamespace(dgraphapi.DefaultUser, dgraphapi.DefaultPassword, x.RootNamespace)) for i := 1; i < 5; i++ { ns, err := hc.AddNamespace() require.NoError(t, err) @@ -71,10 +71,10 @@ func (msuite *MultitenancyTestSuite) TestLoggingIntoAllNamespacesAfterDropDataOp require.NoError(t, err) require.NoError(t, gc.LoginIntoNamespace(context.Background(), - dgraphapi.DefaultUser, dgraphapi.DefaultPassword, x.GalaxyNamespace)) + dgraphapi.DefaultUser, dgraphapi.DefaultPassword, x.RootNamespace)) require.NoError(t, gc.DropAll()) - require.NoError(t, hc.LoginIntoNamespace(dgraphapi.DefaultUser, dgraphapi.DefaultPassword, x.GalaxyNamespace)) + require.NoError(t, hc.LoginIntoNamespace(dgraphapi.DefaultUser, dgraphapi.DefaultPassword, x.RootNamespace)) nss := []uint64{} for i := 1; i <= 2; i++ { @@ -89,13 +89,13 @@ func (msuite *MultitenancyTestSuite) TestLoggingIntoAllNamespacesAfterDropDataOp // Drop data from default namespace require.NoError(t, gc.LoginIntoNamespace(context.Background(), - dgraphapi.DefaultUser, dgraphapi.DefaultPassword, x.GalaxyNamespace)) + dgraphapi.DefaultUser, dgraphapi.DefaultPassword, x.RootNamespace)) require.NoError(t, gc.Alter(context.Background(), &api.Operation{DropOp: api.Operation_DATA})) // verify here that login into the namespace should not fail require.NoError(t, gc.LoginIntoNamespace(context.Background(), - dgraphapi.DefaultUser, dgraphapi.DefaultPassword, x.GalaxyNamespace)) + dgraphapi.DefaultUser, dgraphapi.DefaultPassword, x.RootNamespace)) for _, ns := range nss { require.NoError(t, gc.LoginIntoNamespace(context.Background(), diff --git a/systest/mutations-and-queries/queries_test.go b/systest/mutations-and-queries/queries_test.go index 4b0d405f4fc..c1675c5b3e5 100644 --- a/systest/mutations-and-queries/queries_test.go +++ b/systest/mutations-and-queries/queries_test.go @@ -545,7 +545,7 @@ func (ssuite *SystestTestSuite) TestSchemaQueryHTTP() { hcli, err := ssuite.dc.HTTPClient() require.NoError(t, err) - err = hcli.LoginIntoNamespace(dgraphapi.DefaultUser, dgraphapi.DefaultPassword, x.GalaxyNamespace) + err = hcli.LoginIntoNamespace(dgraphapi.DefaultUser, dgraphapi.DefaultPassword, x.RootNamespace) require.NotNil(t, hcli.AccessJwt, "token is nil") require.NoError(t, err) @@ -1501,7 +1501,7 @@ func doGrpcLogin(ssuite *SystestTestSuite) (*dgraphapi.GrpcClient, func(), error return nil, nil, errors.Wrap(err, "error creating grpc client") } err = gcli.LoginIntoNamespace(context.Background(), - dgraphapi.DefaultUser, dgraphapi.DefaultPassword, x.GalaxyNamespace) + dgraphapi.DefaultUser, dgraphapi.DefaultPassword, x.RootNamespace) if err != nil { return nil, nil, errors.Wrap(err, "groot login into galaxy namespace failed") } diff --git a/systest/online-restore/namespace-aware/restore_test.go b/systest/online-restore/namespace-aware/restore_test.go index 9ff9837f4ad..7c0ae1eb329 100644 --- a/systest/online-restore/namespace-aware/restore_test.go +++ b/systest/online-restore/namespace-aware/restore_test.go @@ -36,7 +36,7 @@ import ( func commonTest(t *testing.T, existingCluster, freshCluster *dgraphtest.LocalCluster) { hc, err := existingCluster.HTTPClient() require.NoError(t, err) - require.NoError(t, hc.LoginIntoNamespace(dgraphapi.DefaultUser, dgraphapi.DefaultPassword, x.GalaxyNamespace)) + require.NoError(t, hc.LoginIntoNamespace(dgraphapi.DefaultUser, dgraphapi.DefaultPassword, x.RootNamespace)) gc, cleanup, err := existingCluster.Client() defer cleanup() @@ -54,13 +54,13 @@ func commonTest(t *testing.T, existingCluster, freshCluster *dgraphtest.LocalClu require.NoError(t, dgraphtest.AddData(gc, "pred", 1, 100+int(ns))) } - require.NoError(t, hc.LoginIntoNamespace(dgraphapi.DefaultUser, dgraphapi.DefaultPassword, x.GalaxyNamespace)) + require.NoError(t, hc.LoginIntoNamespace(dgraphapi.DefaultUser, dgraphapi.DefaultPassword, x.RootNamespace)) require.NoError(t, hc.Backup(existingCluster, false, dgraphtest.DefaultBackupDir)) restoreNamespaces := func(c *dgraphtest.LocalCluster) { hc, err := c.HTTPClient() require.NoError(t, err) - require.NoError(t, hc.LoginIntoNamespace(dgraphapi.DefaultUser, dgraphapi.DefaultPassword, x.GalaxyNamespace)) + require.NoError(t, hc.LoginIntoNamespace(dgraphapi.DefaultUser, dgraphapi.DefaultPassword, x.RootNamespace)) for _, ns := range namespaces { require.NoError(t, hc.RestoreTenant(c, dgraphtest.DefaultBackupDir, "", 0, 0, ns)) @@ -72,7 +72,7 @@ func commonTest(t *testing.T, existingCluster, freshCluster *dgraphtest.LocalClu // Only the namespace '0' should have data require.NoError(t, gc.LoginIntoNamespace(context.Background(), - dgraphapi.DefaultUser, dgraphapi.DefaultPassword, x.GalaxyNamespace)) + dgraphapi.DefaultUser, dgraphapi.DefaultPassword, x.RootNamespace)) const query = `{ all(func: has(pred)) { count(uid) @@ -100,7 +100,7 @@ func commonTest(t *testing.T, existingCluster, freshCluster *dgraphtest.LocalClu func commonIncRestoreTest(t *testing.T, existingCluster, freshCluster *dgraphtest.LocalCluster) { hc, err := existingCluster.HTTPClient() require.NoError(t, err) - require.NoError(t, hc.LoginIntoNamespace(dgraphapi.DefaultUser, dgraphapi.DefaultPassword, x.GalaxyNamespace)) + require.NoError(t, hc.LoginIntoNamespace(dgraphapi.DefaultUser, dgraphapi.DefaultPassword, x.RootNamespace)) gc, cleanup, err := existingCluster.Client() defer cleanup() @@ -126,14 +126,14 @@ func commonIncRestoreTest(t *testing.T, existingCluster, freshCluster *dgraphtes require.NoError(t, dgraphtest.AddData(gc, "pred", start, end)) } - require.NoError(t, hc.LoginIntoNamespace(dgraphapi.DefaultUser, dgraphapi.DefaultPassword, x.GalaxyNamespace)) + require.NoError(t, hc.LoginIntoNamespace(dgraphapi.DefaultUser, dgraphapi.DefaultPassword, x.RootNamespace)) require.NoError(t, hc.Backup(existingCluster, j == 0, dgraphtest.DefaultBackupDir)) } restoreNamespaces := func(c *dgraphtest.LocalCluster) { hc, err := c.HTTPClient() require.NoError(t, err) - require.NoError(t, hc.LoginIntoNamespace(dgraphapi.DefaultUser, dgraphapi.DefaultPassword, x.GalaxyNamespace)) + require.NoError(t, hc.LoginIntoNamespace(dgraphapi.DefaultUser, dgraphapi.DefaultPassword, x.RootNamespace)) for _, ns := range namespaces { for j := 0; j < 5; j++ { incrFrom := j + 1 diff --git a/systest/shortest-path/shortest_test.go b/systest/shortest-path/shortest_test.go index c1a50de72e9..92872fa86e2 100644 --- a/systest/shortest-path/shortest_test.go +++ b/systest/shortest-path/shortest_test.go @@ -37,7 +37,7 @@ func TestShortestPath(t *testing.T) { require.NoError(t, err) defer cleanup() require.NoError(t, gc.LoginIntoNamespace(context.Background(), - dgraphapi.DefaultUser, dgraphapi.DefaultPassword, x.GalaxyNamespace)) + dgraphapi.DefaultUser, dgraphapi.DefaultPassword, x.RootNamespace)) _, err = gc.Query(` { diff --git a/systest/vector/backup_test.go b/systest/vector/backup_test.go index 2c099a4e9c5..2effaa171be 100644 --- a/systest/vector/backup_test.go +++ b/systest/vector/backup_test.go @@ -15,11 +15,12 @@ import ( "testing" "time" + "github.com/stretchr/testify/require" + "github.com/dgraph-io/dgo/v250/protos/api" "github.com/hypermodeinc/dgraph/v25/dgraphapi" "github.com/hypermodeinc/dgraph/v25/dgraphtest" "github.com/hypermodeinc/dgraph/v25/x" - "github.com/stretchr/testify/require" ) func TestVectorIncrBackupRestore(t *testing.T) { @@ -33,12 +34,12 @@ func TestVectorIncrBackupRestore(t *testing.T) { require.NoError(t, err) defer cleanup() require.NoError(t, gc.LoginIntoNamespace(context.Background(), - dgraphapi.DefaultUser, dgraphapi.DefaultPassword, x.GalaxyNamespace)) + dgraphapi.DefaultUser, dgraphapi.DefaultPassword, x.RootNamespace)) hc, err := c.HTTPClient() require.NoError(t, err) require.NoError(t, hc.LoginIntoNamespace(dgraphapi.DefaultUser, - dgraphapi.DefaultPassword, x.GalaxyNamespace)) + dgraphapi.DefaultPassword, x.RootNamespace)) require.NoError(t, gc.SetupSchema(testSchema)) @@ -110,12 +111,12 @@ func TestVectorBackupRestore(t *testing.T) { require.NoError(t, err) defer cleanup() require.NoError(t, gc.LoginIntoNamespace(context.Background(), - dgraphapi.DefaultUser, dgraphapi.DefaultPassword, x.GalaxyNamespace)) + dgraphapi.DefaultUser, dgraphapi.DefaultPassword, x.RootNamespace)) hc, err := c.HTTPClient() require.NoError(t, err) require.NoError(t, hc.LoginIntoNamespace(dgraphapi.DefaultUser, - dgraphapi.DefaultPassword, x.GalaxyNamespace)) + dgraphapi.DefaultPassword, x.RootNamespace)) require.NoError(t, gc.SetupSchema(testSchema)) @@ -149,12 +150,12 @@ func TestVectorBackupRestoreDropIndex(t *testing.T) { require.NoError(t, err) defer cleanup() require.NoError(t, gc.LoginIntoNamespace(context.Background(), - dgraphapi.DefaultUser, dgraphapi.DefaultPassword, x.GalaxyNamespace)) + dgraphapi.DefaultUser, dgraphapi.DefaultPassword, x.RootNamespace)) hc, err := c.HTTPClient() require.NoError(t, err) require.NoError(t, hc.LoginIntoNamespace(dgraphapi.DefaultUser, - dgraphapi.DefaultPassword, x.GalaxyNamespace)) + dgraphapi.DefaultPassword, x.RootNamespace)) // add vector predicate + index require.NoError(t, gc.SetupSchema(testSchema)) @@ -237,12 +238,12 @@ func TestVectorBackupRestoreReIndexing(t *testing.T) { require.NoError(t, err) defer cleanup() require.NoError(t, gc.LoginIntoNamespace(context.Background(), - dgraphapi.DefaultUser, dgraphapi.DefaultPassword, x.GalaxyNamespace)) + dgraphapi.DefaultUser, dgraphapi.DefaultPassword, x.RootNamespace)) hc, err := c.HTTPClient() require.NoError(t, err) require.NoError(t, hc.LoginIntoNamespace(dgraphapi.DefaultUser, - dgraphapi.DefaultPassword, x.GalaxyNamespace)) + dgraphapi.DefaultPassword, x.RootNamespace)) require.NoError(t, gc.SetupSchema(testSchema)) diff --git a/systest/vector/load_test.go b/systest/vector/load_test.go index 11a956a341c..8bb83e9ecb4 100644 --- a/systest/vector/load_test.go +++ b/systest/vector/load_test.go @@ -13,11 +13,12 @@ import ( "testing" "time" + "github.com/stretchr/testify/require" + "github.com/dgraph-io/dgo/v250/protos/api" "github.com/hypermodeinc/dgraph/v25/dgraphapi" "github.com/hypermodeinc/dgraph/v25/dgraphtest" "github.com/hypermodeinc/dgraph/v25/x" - "github.com/stretchr/testify/require" ) type Node struct { @@ -41,12 +42,12 @@ func testExportAndLiveLoad(t *testing.T, c *dgraphtest.LocalCluster, exportForma require.NoError(t, err) defer cleanup() require.NoError(t, gc.LoginIntoNamespace(context.Background(), - dgraphapi.DefaultUser, dgraphapi.DefaultPassword, x.GalaxyNamespace)) + dgraphapi.DefaultUser, dgraphapi.DefaultPassword, x.RootNamespace)) hc, err := c.HTTPClient() require.NoError(t, err) require.NoError(t, hc.LoginIntoNamespace(dgraphapi.DefaultUser, - dgraphapi.DefaultPassword, x.GalaxyNamespace)) + dgraphapi.DefaultPassword, x.RootNamespace)) require.NoError(t, gc.SetupSchema(testSchema)) @@ -77,7 +78,7 @@ func testExportAndLiveLoad(t *testing.T, c *dgraphtest.LocalCluster, exportForma require.NoError(t, c.LiveLoadFromExport(dgraphtest.DefaultExportDir)) require.NoError(t, gc.LoginIntoNamespace(context.Background(), - dgraphapi.DefaultUser, dgraphapi.DefaultPassword, x.GalaxyNamespace)) + dgraphapi.DefaultUser, dgraphapi.DefaultPassword, x.RootNamespace)) result, err = gc.Query(query) require.NoError(t, err) diff --git a/systest/vector/vector_test.go b/systest/vector/vector_test.go index 95814d83823..5fd0b991d68 100644 --- a/systest/vector/vector_test.go +++ b/systest/vector/vector_test.go @@ -14,11 +14,12 @@ import ( "testing" "time" + "github.com/stretchr/testify/require" + "github.com/dgraph-io/dgo/v250/protos/api" "github.com/hypermodeinc/dgraph/v25/dgraphapi" "github.com/hypermodeinc/dgraph/v25/dgraphtest" "github.com/hypermodeinc/dgraph/v25/x" - "github.com/stretchr/testify/require" ) const ( @@ -54,12 +55,12 @@ func TestVectorDropAll(t *testing.T) { require.NoError(t, err) defer cleanup() require.NoError(t, gc.LoginIntoNamespace(context.Background(), - dgraphapi.DefaultUser, dgraphapi.DefaultPassword, x.GalaxyNamespace)) + dgraphapi.DefaultUser, dgraphapi.DefaultPassword, x.RootNamespace)) hc, err := c.HTTPClient() require.NoError(t, err) require.NoError(t, hc.LoginIntoNamespace(dgraphapi.DefaultUser, - dgraphapi.DefaultPassword, x.GalaxyNamespace)) + dgraphapi.DefaultPassword, x.RootNamespace)) numVectors := 100 @@ -110,25 +111,25 @@ func TestVectorSnapshot(t *testing.T) { require.NoError(t, err) defer cleanup() require.NoError(t, gc.LoginIntoNamespace(context.Background(), - dgraphapi.DefaultUser, dgraphapi.DefaultPassword, x.GalaxyNamespace)) + dgraphapi.DefaultUser, dgraphapi.DefaultPassword, x.RootNamespace)) hc, err := c.HTTPClient() require.NoError(t, err) require.NoError(t, hc.LoginIntoNamespace(dgraphapi.DefaultUser, - dgraphapi.DefaultPassword, x.GalaxyNamespace)) + dgraphapi.DefaultPassword, x.RootNamespace)) require.NoError(t, c.KillAlpha(1)) hc, err = c.HTTPClient() require.NoError(t, err) require.NoError(t, hc.LoginIntoNamespace(dgraphapi.DefaultUser, - dgraphapi.DefaultPassword, x.GalaxyNamespace)) + dgraphapi.DefaultPassword, x.RootNamespace)) gc, cleanup, err = c.AlphaClient(0) require.NoError(t, err) defer cleanup() require.NoError(t, gc.LoginIntoNamespace(context.Background(), - dgraphapi.DefaultUser, dgraphapi.DefaultPassword, x.GalaxyNamespace)) + dgraphapi.DefaultUser, dgraphapi.DefaultPassword, x.RootNamespace)) require.NoError(t, gc.SetupSchema(testSchema)) @@ -183,12 +184,12 @@ func TestVectorDropNamespace(t *testing.T) { require.NoError(t, err) defer cleanup() require.NoError(t, gc.LoginIntoNamespace(context.Background(), - dgraphapi.DefaultUser, dgraphapi.DefaultPassword, x.GalaxyNamespace)) + dgraphapi.DefaultUser, dgraphapi.DefaultPassword, x.RootNamespace)) hc, err := c.HTTPClient() require.NoError(t, err) require.NoError(t, hc.LoginIntoNamespace(dgraphapi.DefaultUser, - dgraphapi.DefaultPassword, x.GalaxyNamespace)) + dgraphapi.DefaultPassword, x.RootNamespace)) numVectors := 500 for i := 0; i < 6; i++ { @@ -233,12 +234,12 @@ func TestVectorIndexRebuilding(t *testing.T) { require.NoError(t, err) defer cleanup() require.NoError(t, gc.LoginIntoNamespace(context.Background(), - dgraphapi.DefaultUser, dgraphapi.DefaultPassword, x.GalaxyNamespace)) + dgraphapi.DefaultUser, dgraphapi.DefaultPassword, x.RootNamespace)) hc, err := c.HTTPClient() require.NoError(t, err) require.NoError(t, hc.LoginIntoNamespace(dgraphapi.DefaultUser, - dgraphapi.DefaultPassword, x.GalaxyNamespace)) + dgraphapi.DefaultPassword, x.RootNamespace)) require.NoError(t, gc.SetupSchema(testSchema)) @@ -285,12 +286,12 @@ func TestVectorIndexOnVectorPredWithoutData(t *testing.T) { require.NoError(t, err) defer cleanup() require.NoError(t, gc.LoginIntoNamespace(context.Background(), - dgraphapi.DefaultUser, dgraphapi.DefaultPassword, x.GalaxyNamespace)) + dgraphapi.DefaultUser, dgraphapi.DefaultPassword, x.RootNamespace)) hc, err := c.HTTPClient() require.NoError(t, err) require.NoError(t, hc.LoginIntoNamespace(dgraphapi.DefaultUser, - dgraphapi.DefaultPassword, x.GalaxyNamespace)) + dgraphapi.DefaultPassword, x.RootNamespace)) require.NoError(t, gc.SetupSchema(testSchema)) @@ -312,12 +313,12 @@ func TestVectorIndexDropPredicate(t *testing.T) { require.NoError(t, err) require.NoError(t, gc.LoginIntoNamespace(context.Background(), - dgraphapi.DefaultUser, dgraphapi.DefaultPassword, x.GalaxyNamespace)) + dgraphapi.DefaultUser, dgraphapi.DefaultPassword, x.RootNamespace)) hc, err := c.HTTPClient() require.NoError(t, err) require.NoError(t, hc.LoginIntoNamespace(dgraphapi.DefaultUser, - dgraphapi.DefaultPassword, x.GalaxyNamespace)) + dgraphapi.DefaultPassword, x.RootNamespace)) require.NoError(t, gc.SetupSchema(testSchema)) numVectors := 1000 @@ -388,7 +389,7 @@ func TestVectorIndexWithoutSchema(t *testing.T) { require.NoError(t, err) require.NoError(t, gc.LoginIntoNamespace(context.Background(), - dgraphapi.DefaultUser, dgraphapi.DefaultPassword, x.GalaxyNamespace)) + dgraphapi.DefaultUser, dgraphapi.DefaultPassword, x.RootNamespace)) numVectors := 1000 @@ -430,7 +431,7 @@ func TestVectorIndexWithoutSchemaWithoutIndex(t *testing.T) { require.NoError(t, err) require.NoError(t, gc.LoginIntoNamespace(context.Background(), - dgraphapi.DefaultUser, dgraphapi.DefaultPassword, x.GalaxyNamespace)) + dgraphapi.DefaultUser, dgraphapi.DefaultPassword, x.RootNamespace)) numVectors := 1000 diff --git a/testutil/bulk.go b/testutil/bulk.go index 20d0acce3c0..03f1fa6b719 100644 --- a/testutil/bulk.go +++ b/testutil/bulk.go @@ -45,7 +45,7 @@ func LiveLoad(opts LiveOpts) error { "--zero", opts.Zero, } if opts.Creds != nil { - if opts.Creds.Namespace == x.GalaxyNamespace || opts.ForceNs != 0 { + if opts.Creds.Namespace == x.RootNamespace || opts.ForceNs != 0 { args = append(args, "--force-namespace", strconv.FormatInt(opts.ForceNs, 10)) } args = append(args, "--creds") diff --git a/testutil/client.go b/testutil/client.go index 0ba7b320448..92a135bb678 100644 --- a/testutil/client.go +++ b/testutil/client.go @@ -156,7 +156,7 @@ func DgraphClientWithGroot(serviceAddr string) (*dgo.Dgraph, error) { ctx := context.Background() for { // keep retrying until we succeed or receive a non-retriable error - err = dg.LoginIntoNamespace(ctx, x.GrootId, "password", x.GalaxyNamespace) + err = dg.LoginIntoNamespace(ctx, x.GrootId, "password", x.RootNamespace) if err == nil || !(strings.Contains(err.Error(), "Please retry") || strings.Contains(err.Error(), "user not found")) { diff --git a/testutil/utils.go b/testutil/utils.go index 5c2e7471729..e7946a30c8b 100644 --- a/testutil/utils.go +++ b/testutil/utils.go @@ -21,33 +21,33 @@ import ( "github.com/hypermodeinc/dgraph/v25/x" ) -func GalaxySchemaKey(attr string) []byte { - attr = x.GalaxyAttr(attr) +func RootNsSchemaKey(attr string) []byte { + attr = x.AttrInRootNamespace(attr) return x.SchemaKey(attr) } -func GalaxyTypeKey(attr string) []byte { - attr = x.GalaxyAttr(attr) +func RootNsTypeKey(attr string) []byte { + attr = x.AttrInRootNamespace(attr) return x.TypeKey(attr) } -func GalaxyDataKey(attr string, uid uint64) []byte { - attr = x.GalaxyAttr(attr) +func RootNsDataKey(attr string, uid uint64) []byte { + attr = x.AttrInRootNamespace(attr) return x.DataKey(attr, uid) } -func GalaxyReverseKey(attr string, uid uint64) []byte { - attr = x.GalaxyAttr(attr) +func RootNsReverseKey(attr string, uid uint64) []byte { + attr = x.AttrInRootNamespace(attr) return x.ReverseKey(attr, uid) } -func GalaxyIndexKey(attr, term string) []byte { - attr = x.GalaxyAttr(attr) +func RootNsIndexKey(attr, term string) []byte { + attr = x.AttrInRootNamespace(attr) return x.IndexKey(attr, term) } -func GalaxyCountKey(attr string, count uint32, reverse bool) []byte { - attr = x.GalaxyAttr(attr) +func RootNsCountKey(attr string, count uint32, reverse bool) []byte { + attr = x.AttrInRootNamespace(attr) return x.CountKey(attr, count, reverse) } diff --git a/tlstest/acl/acl_over_tls_test.go b/tlstest/acl/acl_over_tls_test.go index 845236ff66c..1d7a29d650a 100644 --- a/tlstest/acl/acl_over_tls_test.go +++ b/tlstest/acl/acl_over_tls_test.go @@ -31,7 +31,7 @@ func TestLoginOverTLS(t *testing.T) { dg, err := testutil.DgraphClientWithCerts(testutil.SockAddr, conf) require.NoError(t, err) for i := 0; i < 30; i++ { - err = dg.LoginIntoNamespace(context.Background(), "groot", "password", x.GalaxyNamespace) + err = dg.LoginIntoNamespace(context.Background(), "groot", "password", x.RootNamespace) if err == nil { return } diff --git a/upgrade/change_v21.03.0.go b/upgrade/change_v21.03.0.go index d624a7984b9..4de995bd13f 100644 --- a/upgrade/change_v21.03.0.go +++ b/upgrade/change_v21.03.0.go @@ -262,7 +262,7 @@ func upgradeCORS() error { func getData(db *badger.DB, attr string, fn func(item *badger.Item) error) error { return db.View(func(txn *badger.Txn) error { - attr = x.GalaxyAttr(attr) + attr = x.AttrInRootNamespace(attr) initKey := x.ParsedKey{ Attr: attr, } @@ -359,11 +359,11 @@ func getCors(db *badger.DB) ([][]byte, error) { func dropDepreciated(db *badger.DB) error { var prefixes [][]byte for pred := range deprecatedPreds { - pred = x.GalaxyAttr(pred) + pred = x.AttrInRootNamespace(pred) prefixes = append(prefixes, x.SchemaKey(pred), x.PredicatePrefix(pred)) } for typ := range deprecatedTypes { - prefixes = append(prefixes, x.TypeKey(x.GalaxyAttr(typ))) + prefixes = append(prefixes, x.TypeKey(x.AttrInRootNamespace(typ))) } return db.DropPrefix(prefixes...) } @@ -398,7 +398,7 @@ func fixPersistedQuery(db *badger.DB) error { // Update the tokenizer in the schema. su := pb.SchemaUpdate{ - Predicate: x.GalaxyAttr("dgraph.graphql.p_query"), + Predicate: x.AttrInRootNamespace("dgraph.graphql.p_query"), ValueType: pb.Posting_STRING, Directive: pb.SchemaUpdate_INDEX, Tokenizer: []string{"sha256"}, @@ -408,7 +408,7 @@ func fixPersistedQuery(db *badger.DB) error { return err } entry := &badger.Entry{} - entry.Key = x.SchemaKey(x.GalaxyAttr("dgraph.graphql.p_query")) + entry.Key = x.SchemaKey(x.AttrInRootNamespace("dgraph.graphql.p_query")) entry.Value = data entry.UserMeta = posting.BitSchemaPosting if err := update(entry); err != nil { @@ -417,7 +417,7 @@ func fixPersistedQuery(db *badger.DB) error { // Update the type. tu := pb.TypeUpdate{ - TypeName: x.GalaxyAttr("dgraph.graphql.persisted_query"), + TypeName: x.AttrInRootNamespace("dgraph.graphql.persisted_query"), Fields: []*pb.SchemaUpdate{&su}, } data, err = proto.Marshal(&tu) @@ -425,7 +425,7 @@ func fixPersistedQuery(db *badger.DB) error { return err } entry = &badger.Entry{} - entry.Key = x.TypeKey(x.GalaxyAttr("dgraph.graphql.persisted_query")) + entry.Key = x.TypeKey(x.AttrInRootNamespace("dgraph.graphql.persisted_query")) entry.Value = data entry.UserMeta = posting.BitSchemaPosting if err := update(entry); err != nil { diff --git a/upgrade/upgrade.go b/upgrade/upgrade.go index 5ef8396fcbf..d9bf2af059e 100644 --- a/upgrade/upgrade.go +++ b/upgrade/upgrade.go @@ -172,7 +172,7 @@ func run() { // Login using dgo client fetches the information from creds flag. Upgrade.Conf.Set("creds", fmt.Sprintf("user=%s; password=%s; namespace=%d", - Upgrade.Conf.GetString(user), Upgrade.Conf.GetString(password), x.GalaxyNamespace)) + Upgrade.Conf.GetString(user), Upgrade.Conf.GetString(password), x.RootNamespace)) applyChangeList(cmdInput, allChanges) } diff --git a/upgrade/utils.go b/upgrade/utils.go index 136736f0962..ac408d5aaad 100644 --- a/upgrade/utils.go +++ b/upgrade/utils.go @@ -46,7 +46,7 @@ func getAccessJwt() (*api.Jwt, error) { } }`, Variables: map[string]interface{}{"userId": user, "password": password, - "namespace": x.GalaxyNamespace}, + "namespace": x.RootNamespace}, Headers: header, } diff --git a/worker/acl_cache.go b/worker/acl_cache.go index ef7396e8d47..d1c7b50ee69 100644 --- a/worker/acl_cache.go +++ b/worker/acl_cache.go @@ -175,7 +175,7 @@ func (cache *AclCache) AuthorizePredicate(groups []string, predicate string, } -// accessAllPredicate is a wildcard to allow access to all non-ACL predicates to non-guardian group. +// accessAllPredicate is a wildcard to allow access to all non-ACL predicates to non-superadmin group. const accessAllPredicate = "dgraph.all" func HasAccessToAllPreds(ns uint64, groups []string, operation *acl.Operation) bool { diff --git a/worker/acl_cache_test.go b/worker/acl_cache_test.go index a3e6581d59a..cb651dd5d50 100644 --- a/worker/acl_cache_test.go +++ b/worker/acl_cache_test.go @@ -21,7 +21,7 @@ func TestAclCache(t *testing.T) { var emptyGroups []string group := "dev" - predicate := x.GalaxyAttr("friend") + predicate := x.AttrInRootNamespace("friend") require.Error(t, AclCachePtr.AuthorizePredicate(emptyGroups, predicate, acl.Read), "the anonymous user should not have access when the acl cache is empty") @@ -38,7 +38,7 @@ func TestAclCache(t *testing.T) { Rules: acls, }, } - AclCachePtr.Update(x.GalaxyNamespace, groups) + AclCachePtr.Update(x.RootNamespace, groups) // after a rule is defined, the anonymous user should no longer have access require.Error(t, AclCachePtr.AuthorizePredicate(emptyGroups, predicate, acl.Read), "the anonymous user should not have access when the predicate has acl defined") @@ -46,7 +46,7 @@ func TestAclCache(t *testing.T) { "the user with group authorized should have access") // update the cache with empty acl list in order to clear the cache - AclCachePtr.Update(x.GalaxyNamespace, []acl.Group{}) + AclCachePtr.Update(x.RootNamespace, []acl.Group{}) // the anonymous user should have access again require.Error(t, AclCachePtr.AuthorizePredicate(emptyGroups, predicate, acl.Read), "the anonymous user should not have access when the acl cache is empty") diff --git a/worker/backup_manifest.go b/worker/backup_manifest.go index 08a2629180d..c20da059f58 100644 --- a/worker/backup_manifest.go +++ b/worker/backup_manifest.go @@ -165,16 +165,16 @@ func upgradeManifest(m *Manifest) error { for gid, preds := range m.Groups { parsedPreds := preds[:0] for _, pred := range preds { - parsedPreds = append(parsedPreds, x.GalaxyAttr(pred)) + parsedPreds = append(parsedPreds, x.AttrInRootNamespace(pred)) } m.Groups[gid] = parsedPreds } for _, op := range m.DropOperations { switch op.DropOp { case pb.DropOperation_DATA: - op.DropValue = fmt.Sprintf("%#x", x.GalaxyNamespace) + op.DropValue = fmt.Sprintf("%#x", x.RootNamespace) case pb.DropOperation_ATTR: - op.DropValue = x.GalaxyAttr(op.DropValue) + op.DropValue = x.AttrInRootNamespace(op.DropValue) default: // do nothing for drop all and drop namespace. } diff --git a/worker/cdc.go b/worker/cdc.go index 202c3eac017..e7143078e22 100644 --- a/worker/cdc.go +++ b/worker/cdc.go @@ -405,7 +405,7 @@ func toCDCEvent(index uint64, mutation *pb.Mutations) []CDCEvent { switch mutation.DropOp { case pb.Mutations_ALL: // Drop all is cluster wide. - binary.BigEndian.PutUint64(namespace, x.GalaxyNamespace) + binary.BigEndian.PutUint64(namespace, x.RootNamespace) case pb.Mutations_DATA: ns, err := strconv.ParseUint(mutation.DropValue, 0, 64) if err != nil { diff --git a/worker/draft.go b/worker/draft.go index df9134631ca..aabeb5b1674 100644 --- a/worker/draft.go +++ b/worker/draft.go @@ -401,7 +401,7 @@ func (n *node) applyMutations(ctx context.Context, proposal *pb.Proposal) (rerr // It should be okay to set the schema at timestamp 1 after drop all operation. if groups().groupId() == 1 { - initialSchema := schema.InitialSchema(x.GalaxyNamespace) + initialSchema := schema.InitialSchema(x.RootNamespace) for _, s := range initialSchema { if err := applySchema(s, 1); err != nil { return err @@ -410,7 +410,7 @@ func (n *node) applyMutations(ctx context.Context, proposal *pb.Proposal) (rerr } // Propose initial types as well after a drop all as they would have been cleared. - initialTypes := schema.InitialTypes(x.GalaxyNamespace) + initialTypes := schema.InitialTypes(x.RootNamespace) for _, t := range initialTypes { if err := updateType(t.GetTypeName(), t, 1); err != nil { return err @@ -753,7 +753,7 @@ func (n *node) applyCommitted(proposal *pb.Proposal, key uint64) error { }) case proposal.DeleteNs != nil: - x.AssertTrue(proposal.DeleteNs.Namespace != x.GalaxyNamespace) + x.AssertTrue(proposal.DeleteNs.Namespace != x.RootNamespace) span.AddEvent("Deleting namespace: %d", trace.WithAttributes( attribute.Int64("namespace", int64(proposal.DeleteNs.Namespace)))) return posting.DeleteNamespace(proposal.DeleteNs.Namespace) diff --git a/worker/export_test.go b/worker/export_test.go index 3ded31b6f2c..e347f62e8e0 100644 --- a/worker/export_test.go +++ b/worker/export_test.go @@ -44,19 +44,19 @@ const ( ) var personType = &pb.TypeUpdate{ - TypeName: x.GalaxyAttr("Person"), + TypeName: x.AttrInRootNamespace("Person"), Fields: []*pb.SchemaUpdate{ { - Predicate: x.GalaxyAttr("name"), + Predicate: x.AttrInRootNamespace("name"), }, { - Predicate: x.GalaxyAttr("friend"), + Predicate: x.AttrInRootNamespace("friend"), }, { - Predicate: x.GalaxyAttr("~friend"), + Predicate: x.AttrInRootNamespace("~friend"), }, { - Predicate: x.GalaxyAttr("friend_not_served"), + Predicate: x.AttrInRootNamespace("friend_not_served"), }, }, } @@ -128,7 +128,7 @@ func initTestExport(t *testing.T, schemaStr string) { require.NoError(t, err) txn := pstore.NewTransactionAt(math.MaxUint64, true) - require.NoError(t, txn.Set(testutil.GalaxySchemaKey("friend"), val)) + require.NoError(t, txn.Set(testutil.RootNsSchemaKey("friend"), val)) // Schema is always written at timestamp 1 require.NoError(t, txn.CommitAt(1, nil)) @@ -137,16 +137,16 @@ func initTestExport(t *testing.T, schemaStr string) { require.NoError(t, err) txn = pstore.NewTransactionAt(math.MaxUint64, true) - require.NoError(t, txn.Set(testutil.GalaxySchemaKey("http://www.w3.org/2000/01/rdf-schema#range"), val)) - require.NoError(t, txn.Set(testutil.GalaxySchemaKey("friend_not_served"), val)) - require.NoError(t, txn.Set(testutil.GalaxySchemaKey("age"), val)) + require.NoError(t, txn.Set(testutil.RootNsSchemaKey("http://www.w3.org/2000/01/rdf-schema#range"), val)) + require.NoError(t, txn.Set(testutil.RootNsSchemaKey("friend_not_served"), val)) + require.NoError(t, txn.Set(testutil.RootNsSchemaKey("age"), val)) require.NoError(t, txn.CommitAt(1, nil)) val, err = proto.Marshal(personType) require.NoError(t, err) txn = pstore.NewTransactionAt(math.MaxUint64, true) - require.NoError(t, txn.Set(testutil.GalaxyTypeKey("Person"), val)) + require.NoError(t, txn.Set(testutil.RootNsTypeKey("Person"), val)) require.NoError(t, txn.CommitAt(1, nil)) populateGraphExport(t) @@ -154,7 +154,7 @@ func initTestExport(t *testing.T, schemaStr string) { // Drop age predicate after populating DB. // age should not exist in the exported schema. txn = pstore.NewTransactionAt(math.MaxUint64, true) - require.NoError(t, txn.Delete(testutil.GalaxySchemaKey("age"))) + require.NoError(t, txn.Delete(testutil.RootNsSchemaKey("age"))) require.NoError(t, txn.CommitAt(1, nil)) } @@ -199,7 +199,7 @@ func checkExportSchema(t *testing.T, schemaFileList []string) { require.Equal(t, 2, len(result.Preds)) require.Equal(t, "uid", types.TypeID(result.Preds[0].ValueType).Name()) - require.Equal(t, x.GalaxyAttr("http://www.w3.org/2000/01/rdf-schema#range"), + require.Equal(t, x.AttrInRootNamespace("http://www.w3.org/2000/01/rdf-schema#range"), result.Preds[1].Predicate) require.Equal(t, "uid", types.TypeID(result.Preds[1].ValueType).Name()) @@ -218,7 +218,7 @@ func checkExportGqlSchema(t *testing.T, gqlSchemaFiles []string) { var buf bytes.Buffer _, err = buf.ReadFrom(r) require.NoError(t, err) - expected := []x.ExportedGQLSchema{{Namespace: x.GalaxyNamespace, Schema: gqlSchema}} + expected := []x.ExportedGQLSchema{{Namespace: x.RootNamespace, Schema: gqlSchema}} b, err := json.Marshal(expected) require.NoError(t, err) require.JSONEq(t, string(b), buf.String()) @@ -444,9 +444,9 @@ func TestToSchema(t *testing.T) { }{ { skv: &skv{ - attr: x.GalaxyAttr("Alice"), + attr: x.AttrInRootNamespace("Alice"), schema: pb.SchemaUpdate{ - Predicate: x.GalaxyAttr("mother"), + Predicate: x.AttrInRootNamespace("mother"), ValueType: pb.Posting_STRING, Directive: pb.SchemaUpdate_REVERSE, List: false, @@ -474,9 +474,9 @@ func TestToSchema(t *testing.T) { }, { skv: &skv{ - attr: x.GalaxyAttr("username/password"), + attr: x.AttrInRootNamespace("username/password"), schema: pb.SchemaUpdate{ - Predicate: x.GalaxyAttr(""), + Predicate: x.AttrInRootNamespace(""), ValueType: pb.Posting_STRING, Directive: pb.SchemaUpdate_NONE, List: false, @@ -489,9 +489,9 @@ func TestToSchema(t *testing.T) { }, { skv: &skv{ - attr: x.GalaxyAttr("B*-tree"), + attr: x.AttrInRootNamespace("B*-tree"), schema: pb.SchemaUpdate{ - Predicate: x.GalaxyAttr(""), + Predicate: x.AttrInRootNamespace(""), ValueType: pb.Posting_UID, Directive: pb.SchemaUpdate_REVERSE, List: true, @@ -504,9 +504,9 @@ func TestToSchema(t *testing.T) { }, { skv: &skv{ - attr: x.GalaxyAttr("base_de_donnĂ©es"), + attr: x.AttrInRootNamespace("base_de_donnĂ©es"), schema: pb.SchemaUpdate{ - Predicate: x.GalaxyAttr(""), + Predicate: x.AttrInRootNamespace(""), ValueType: pb.Posting_STRING, Directive: pb.SchemaUpdate_NONE, List: false, @@ -519,9 +519,9 @@ func TestToSchema(t *testing.T) { }, { skv: &skv{ - attr: x.GalaxyAttr("data_base"), + attr: x.AttrInRootNamespace("data_base"), schema: pb.SchemaUpdate{ - Predicate: x.GalaxyAttr(""), + Predicate: x.AttrInRootNamespace(""), ValueType: pb.Posting_STRING, Directive: pb.SchemaUpdate_NONE, List: false, @@ -534,9 +534,9 @@ func TestToSchema(t *testing.T) { }, { skv: &skv{ - attr: x.GalaxyAttr("data.base"), + attr: x.AttrInRootNamespace("data.base"), schema: pb.SchemaUpdate{ - Predicate: x.GalaxyAttr(""), + Predicate: x.AttrInRootNamespace(""), ValueType: pb.Posting_STRING, Directive: pb.SchemaUpdate_NONE, List: false, diff --git a/worker/groups.go b/worker/groups.go index c99a38347ba..93667e3106d 100644 --- a/worker/groups.go +++ b/worker/groups.go @@ -187,7 +187,7 @@ func (g *groupi) informZeroAboutTablets() { } func (g *groupi) applyInitialTypes() { - initialTypes := schema.InitialTypes(x.GalaxyNamespace) + initialTypes := schema.InitialTypes(x.RootNamespace) for _, t := range initialTypes { if _, ok := schema.State().GetType(t.TypeName); ok { continue @@ -203,7 +203,7 @@ func (g *groupi) applyInitialSchema() { if g.groupId() != 1 { return } - initialSchema := schema.InitialSchema(x.GalaxyNamespace) + initialSchema := schema.InitialSchema(x.RootNamespace) ctx := g.Ctx() apply := func(s *pb.SchemaUpdate) { diff --git a/worker/mutation_integration_test.go b/worker/mutation_integration_test.go index 300dc029915..4bbd4906b7c 100644 --- a/worker/mutation_integration_test.go +++ b/worker/mutation_integration_test.go @@ -21,10 +21,10 @@ import ( func TestPopulateMutationMap(t *testing.T) { edges := []*pb.DirectedEdge{{ Value: []byte("set edge"), - Attr: x.GalaxyAttr(""), + Attr: x.AttrInRootNamespace(""), }} schema := []*pb.SchemaUpdate{{ - Predicate: x.GalaxyAttr("name"), + Predicate: x.AttrInRootNamespace("name"), }} m := &pb.Mutations{Edges: edges, Schema: schema} @@ -40,53 +40,53 @@ func TestCheckSchema(t *testing.T) { require.NoError(t, posting.DeleteAll()) initTest(t, "name:string @index(term) .") // non uid to uid - s1 := &pb.SchemaUpdate{Predicate: x.GalaxyAttr("name"), ValueType: pb.Posting_UID} + s1 := &pb.SchemaUpdate{Predicate: x.AttrInRootNamespace("name"), ValueType: pb.Posting_UID} require.NoError(t, checkSchema(s1)) // uid to non uid require.NoError(t, schema.ParseBytes([]byte("name:uid ."), 1)) - s1 = &pb.SchemaUpdate{Predicate: x.GalaxyAttr("name"), ValueType: pb.Posting_STRING} + s1 = &pb.SchemaUpdate{Predicate: x.AttrInRootNamespace("name"), ValueType: pb.Posting_STRING} require.NoError(t, checkSchema(s1)) // string to password require.NoError(t, schema.ParseBytes([]byte("name:string ."), 1)) - s1 = &pb.SchemaUpdate{Predicate: x.GalaxyAttr("name"), ValueType: pb.Posting_PASSWORD} + s1 = &pb.SchemaUpdate{Predicate: x.AttrInRootNamespace("name"), ValueType: pb.Posting_PASSWORD} require.Error(t, checkSchema(s1)) // password to string require.NoError(t, schema.ParseBytes([]byte("name:password ."), 1)) - s1 = &pb.SchemaUpdate{Predicate: x.GalaxyAttr("name"), ValueType: pb.Posting_STRING} + s1 = &pb.SchemaUpdate{Predicate: x.AttrInRootNamespace("name"), ValueType: pb.Posting_STRING} require.Error(t, checkSchema(s1)) // int to password require.NoError(t, schema.ParseBytes([]byte("name:int ."), 1)) - s1 = &pb.SchemaUpdate{Predicate: x.GalaxyAttr("name"), ValueType: pb.Posting_PASSWORD} + s1 = &pb.SchemaUpdate{Predicate: x.AttrInRootNamespace("name"), ValueType: pb.Posting_PASSWORD} require.Error(t, checkSchema(s1)) // password to password require.NoError(t, schema.ParseBytes([]byte("name:password ."), 1)) - s1 = &pb.SchemaUpdate{Predicate: x.GalaxyAttr("name"), ValueType: pb.Posting_PASSWORD} + s1 = &pb.SchemaUpdate{Predicate: x.AttrInRootNamespace("name"), ValueType: pb.Posting_PASSWORD} require.NoError(t, checkSchema(s1)) // string to int require.NoError(t, schema.ParseBytes([]byte("name:string ."), 1)) - s1 = &pb.SchemaUpdate{Predicate: x.GalaxyAttr("name"), ValueType: pb.Posting_FLOAT} + s1 = &pb.SchemaUpdate{Predicate: x.AttrInRootNamespace("name"), ValueType: pb.Posting_FLOAT} require.NoError(t, checkSchema(s1)) // index on uid type - s1 = &pb.SchemaUpdate{Predicate: x.GalaxyAttr("name"), ValueType: pb.Posting_UID, Directive: pb.SchemaUpdate_INDEX} + s1 = &pb.SchemaUpdate{Predicate: x.AttrInRootNamespace("name"), ValueType: pb.Posting_UID, Directive: pb.SchemaUpdate_INDEX} require.Error(t, checkSchema(s1)) // reverse on non-uid type s1 = &pb.SchemaUpdate{ - Predicate: x.GalaxyAttr("name"), + Predicate: x.AttrInRootNamespace("name"), ValueType: pb.Posting_STRING, Directive: pb.SchemaUpdate_REVERSE, } require.Error(t, checkSchema(s1)) s1 = &pb.SchemaUpdate{ - Predicate: x.GalaxyAttr("name"), + Predicate: x.AttrInRootNamespace("name"), ValueType: pb.Posting_FLOAT, Directive: pb.SchemaUpdate_INDEX, Tokenizer: []string{"term"}, @@ -94,14 +94,14 @@ func TestCheckSchema(t *testing.T) { require.NoError(t, checkSchema(s1)) s1 = &pb.SchemaUpdate{ - Predicate: x.GalaxyAttr("friend"), + Predicate: x.AttrInRootNamespace("friend"), ValueType: pb.Posting_UID, Directive: pb.SchemaUpdate_REVERSE, } require.NoError(t, checkSchema(s1)) // Schema with internal predicate. - s1 = &pb.SchemaUpdate{Predicate: x.GalaxyAttr("uid"), ValueType: pb.Posting_STRING} + s1 = &pb.SchemaUpdate{Predicate: x.AttrInRootNamespace("uid"), ValueType: pb.Posting_STRING} require.Error(t, checkSchema(s1)) s := `jobs: string @upsert .` diff --git a/worker/mutation_unit_test.go b/worker/mutation_unit_test.go index 98a804c7625..5d66ae042b2 100644 --- a/worker/mutation_unit_test.go +++ b/worker/mutation_unit_test.go @@ -38,7 +38,7 @@ func TestReverseEdge(t *testing.T) { ctx := context.Background() txn := posting.Oracle().RegisterStartTs(5) - attr := x.GalaxyAttr("revc") + attr := x.AttrInRootNamespace("revc") edge := &pb.DirectedEdge{ ValueId: 2, @@ -68,13 +68,13 @@ func TestConvertEdgeType(t *testing.T) { { input: &pb.DirectedEdge{ Value: []byte("set edge"), - Attr: x.GalaxyAttr("name"), + Attr: x.AttrInRootNamespace("name"), }, to: types.StringID, expectErr: false, output: &pb.DirectedEdge{ Value: []byte("set edge"), - Attr: x.GalaxyAttr("name"), + Attr: x.AttrInRootNamespace("name"), ValueType: 9, }, }, @@ -96,7 +96,7 @@ func TestConvertEdgeType(t *testing.T) { { input: &pb.DirectedEdge{ ValueId: 123, - Attr: x.GalaxyAttr("name"), + Attr: x.AttrInRootNamespace("name"), }, to: types.StringID, expectErr: true, @@ -104,7 +104,7 @@ func TestConvertEdgeType(t *testing.T) { { input: &pb.DirectedEdge{ Value: []byte("set edge"), - Attr: x.GalaxyAttr("name"), + Attr: x.AttrInRootNamespace("name"), }, to: types.UidID, expectErr: true, @@ -129,7 +129,7 @@ func TestConvertEdgeType(t *testing.T) { func TestValidateEdgeTypeError(t *testing.T) { edge := &pb.DirectedEdge{ Value: []byte("set edge"), - Attr: x.GalaxyAttr("name"), + Attr: x.AttrInRootNamespace("name"), } err := ValidateAndConvert(edge, @@ -144,7 +144,7 @@ func TestTypeSanityCheck(t *testing.T) { typeDef := &pb.TypeUpdate{ Fields: []*pb.SchemaUpdate{ { - Predicate: x.GalaxyAttr(""), + Predicate: x.AttrInRootNamespace(""), }, }, } @@ -156,7 +156,7 @@ func TestTypeSanityCheck(t *testing.T) { typeDef = &pb.TypeUpdate{ Fields: []*pb.SchemaUpdate{ { - Predicate: x.GalaxyAttr("name"), + Predicate: x.AttrInRootNamespace("name"), ValueType: pb.Posting_OBJECT, }, }, @@ -169,7 +169,7 @@ func TestTypeSanityCheck(t *testing.T) { typeDef = &pb.TypeUpdate{ Fields: []*pb.SchemaUpdate{ { - Predicate: x.GalaxyAttr("name"), + Predicate: x.AttrInRootNamespace("name"), Directive: pb.SchemaUpdate_REVERSE, }, }, @@ -182,7 +182,7 @@ func TestTypeSanityCheck(t *testing.T) { typeDef = &pb.TypeUpdate{ Fields: []*pb.SchemaUpdate{ { - Predicate: x.GalaxyAttr("name"), + Predicate: x.AttrInRootNamespace("name"), Tokenizer: []string{"int"}, }, }, diff --git a/worker/restore_map.go b/worker/restore_map.go index fed5e4de669..585d5fd998a 100644 --- a/worker/restore_map.go +++ b/worker/restore_map.go @@ -424,9 +424,9 @@ func (m *mapper) processReqCh(ctx context.Context) error { if err := proto.Unmarshal(kv.Value, &update); err != nil { return err } - update.TypeName = x.GalaxyAttr(update.TypeName) + update.TypeName = x.AttrInRootNamespace(update.TypeName) for _, sch := range update.Fields { - sch.Predicate = x.GalaxyAttr(sch.Predicate) + sch.Predicate = x.AttrInRootNamespace(sch.Predicate) } kv.Value, err = proto.Marshal(&update) return err diff --git a/worker/sort_test.go b/worker/sort_test.go index 418e0155b7a..860c13ea900 100644 --- a/worker/sort_test.go +++ b/worker/sort_test.go @@ -116,7 +116,7 @@ func TestGetScalarList(t *testing.T) { txn.UpdateCachedKeys(commitTs) } - attr := x.GalaxyAttr("scalarPredicateCount4") + attr := x.AttrInRootNamespace("scalarPredicateCount4") runM(5, 7, []*pb.DirectedEdge{{ ValueId: 3, @@ -160,7 +160,7 @@ func TestMultipleTxnListCount(t *testing.T) { require.NoError(t, err) ctx := context.Background() - attr := x.GalaxyAttr("scalarPredicateCount3") + attr := x.AttrInRootNamespace("scalarPredicateCount3") runM := func(startTs, commitTs uint64, edges []*pb.DirectedEdge) { txn := posting.Oracle().RegisterStartTs(startTs) @@ -219,7 +219,7 @@ func TestScalarPredicateRevCount(t *testing.T) { require.NoError(t, err) ctx := context.Background() - attr := x.GalaxyAttr("scalarPredicateCount2") + attr := x.AttrInRootNamespace("scalarPredicateCount2") runM := func(startTs, commitTs uint64, edges []*pb.DirectedEdge) { txn := posting.Oracle().RegisterStartTs(startTs) @@ -301,7 +301,7 @@ func TestScalarPredicateIntCount(t *testing.T) { require.NoError(t, err) ctx := context.Background() - attr := x.GalaxyAttr("scalarPredicateCount1") + attr := x.AttrInRootNamespace("scalarPredicateCount1") runM := func(startTs, commitTs uint64, edge *pb.DirectedEdge) { txn := posting.Oracle().RegisterStartTs(startTs) @@ -355,7 +355,7 @@ func TestScalarPredicateCount(t *testing.T) { require.NoError(t, err) ctx := context.Background() - attr := x.GalaxyAttr("scalarPredicateCount") + attr := x.AttrInRootNamespace("scalarPredicateCount") runM := func(startTs, commitTs uint64, edge *pb.DirectedEdge) { txn := posting.Oracle().RegisterStartTs(startTs) @@ -410,7 +410,7 @@ func TestSingleUidReplacement(t *testing.T) { ctx := context.Background() txn := posting.Oracle().RegisterStartTs(5) - attr := x.GalaxyAttr("singleUidReplaceTest") + attr := x.AttrInRootNamespace("singleUidReplaceTest") // Txn 1. Set 1 -> 2 x.Check(runMutation(ctx, &pb.DirectedEdge{ @@ -470,7 +470,7 @@ func TestSingleString(t *testing.T) { ctx := context.Background() txn := posting.Oracle().RegisterStartTs(5) - attr := x.GalaxyAttr("singleUidTest") + attr := x.AttrInRootNamespace("singleUidTest") // Txn 1. Set 1 -> david 2 -> blush x.Check(runMutation(ctx, &pb.DirectedEdge{ @@ -565,7 +565,7 @@ func TestLangExact(t *testing.T) { ctx := context.Background() txn := posting.Oracle().RegisterStartTs(5) - attr := x.GalaxyAttr("testLang") + attr := x.AttrInRootNamespace("testLang") edge := &pb.DirectedEdge{ Value: []byte("english"), @@ -633,7 +633,7 @@ func BenchmarkAddMutationWithIndex(b *testing.B) { } ctx := context.Background() txn := posting.Oracle().RegisterStartTs(5) - attr := x.GalaxyAttr("benchmarkadd") + attr := x.AttrInRootNamespace("benchmarkadd") n := uint64(1000) values := make([]string, 0) diff --git a/worker/upgrade_test.go b/worker/upgrade_test.go index 9d6f6398105..f7b1545565e 100644 --- a/worker/upgrade_test.go +++ b/worker/upgrade_test.go @@ -13,12 +13,13 @@ import ( "testing" "time" + "github.com/stretchr/testify/require" + "github.com/dgraph-io/dgo/v250/protos/api" "github.com/hypermodeinc/dgraph/v25/dgraphapi" "github.com/hypermodeinc/dgraph/v25/dgraphtest" "github.com/hypermodeinc/dgraph/v25/testutil" "github.com/hypermodeinc/dgraph/v25/x" - "github.com/stretchr/testify/require" ) var client *dgraphapi.GrpcClient @@ -81,7 +82,7 @@ func TestCountReverseIndex(t *testing.T) { x.Panic(err) defer cleanup() x.Panic(dg.LoginIntoNamespace(context.Background(), dgraphapi.DefaultUser, - dgraphapi.DefaultPassword, x.GalaxyNamespace)) + dgraphapi.DefaultPassword, x.RootNamespace)) populateCluster(t, c) @@ -95,7 +96,7 @@ func TestCountReverseIndex(t *testing.T) { x.Panic(err) defer cleanup() x.Panic(dg.LoginIntoNamespace(context.Background(), dgraphapi.DefaultUser, - dgraphapi.DefaultPassword, x.GalaxyNamespace)) + dgraphapi.DefaultPassword, x.RootNamespace)) setSchema(schemaNonIndexed) setSchema(schemaIndexed) diff --git a/worker/worker_test.go b/worker/worker_test.go index 74f50493111..1f1519e51dd 100644 --- a/worker/worker_test.go +++ b/worker/worker_test.go @@ -88,7 +88,7 @@ func getOrCreate(key []byte) *posting.List { func populateGraph(t *testing.T) { // Add uid edges : predicate neightbour. - neighbour := x.GalaxyAttr("neighbour") + neighbour := x.AttrInRootNamespace("neighbour") edge := &pb.DirectedEdge{ ValueId: 23, Attr: neighbour, @@ -116,7 +116,7 @@ func populateGraph(t *testing.T) { addEdge(t, edge, getOrCreate(x.DataKey(neighbour, 12))) // add value edges: friend : with name - friend := x.GalaxyAttr("friend") + friend := x.AttrInRootNamespace("friend") edge.Attr = neighbour edge.Entity = 12 edge.Value = []byte("photon") @@ -513,8 +513,8 @@ func TestMain(m *testing.M) { addTablets([]string{"name", "name2", "age", "http://www.w3.org/2000/01/rdf-schema#range", "", "friend", "dgraph.type", "dgraph.graphql.xid", "dgraph.graphql.schema"}, - 1, x.GalaxyNamespace) - addTablets([]string{"friend_not_served"}, 2, x.GalaxyNamespace) + 1, x.RootNamespace) + addTablets([]string{"friend_not_served"}, 2, x.RootNamespace) addTablets([]string{"name"}, 1, 0x2) dir, err := os.MkdirTemp("", "storetest_") diff --git a/x/keys.go b/x/keys.go index 8cbe40a2ced..706c136b419 100644 --- a/x/keys.go +++ b/x/keys.go @@ -41,8 +41,8 @@ const ( ByteSplit = byte(0x04) // ByteUnused is a constant to specify keys which need to be discarded. ByteUnused = byte(0xff) - // GalaxyNamespace is the default namespace name. - GalaxyNamespace = uint64(0) + // RootNamespace is the default namespace name. + RootNamespace = uint64(0) // IgnoreBytes is the byte range which will be ignored while prefix match in subscription. IgnoreBytes = "1-8" // NamespaceOffset is the offset in badger key from which the next 8 bytes contain namespace. @@ -87,8 +87,8 @@ func NamespaceAttrList(ns uint64, preds []string) []string { return resp } -func GalaxyAttr(attr string) string { - return NamespaceAttr(GalaxyNamespace, attr) +func AttrInRootNamespace(attr string) string { + return NamespaceAttr(RootNamespace, attr) } // ParseNamespaceAttr returns the namespace and attr from the given value. diff --git a/x/keys_test.go b/x/keys_test.go index 707f77415c1..bf57b1e7467 100644 --- a/x/keys_test.go +++ b/x/keys_test.go @@ -29,7 +29,7 @@ func TestDataKey(t *testing.T) { // key with uid = 0 is invalid uid = 0 - key := DataKey(GalaxyAttr("bad uid"), uid) + key := DataKey(AttrInRootNamespace("bad uid"), uid) _, err := Parse(key) require.Error(t, err) @@ -37,7 +37,7 @@ func TestDataKey(t *testing.T) { // Use the uid to derive the attribute so it has variable length and the test // can verify that multiple sizes of attr work correctly. sattr := fmt.Sprintf("attr:%d", uid) - key := DataKey(GalaxyAttr(sattr), uid) + key := DataKey(AttrInRootNamespace(sattr), uid) pk, err := Parse(key) require.NoError(t, err) @@ -49,14 +49,14 @@ func TestDataKey(t *testing.T) { keys := make([]string, 0, 1024) for uid = 1024; uid >= 1; uid-- { - key := DataKey(GalaxyAttr("testing.key"), uid) + key := DataKey(AttrInRootNamespace("testing.key"), uid) keys = append(keys, string(key)) } // Test that sorting is as expected. sort.Strings(keys) require.True(t, sort.StringsAreSorted(keys)) for i, key := range keys { - exp := DataKey(GalaxyAttr("testing.key"), uint64(i+1)) + exp := DataKey(AttrInRootNamespace("testing.key"), uint64(i+1)) require.Equal(t, string(exp), key) } } @@ -66,7 +66,7 @@ func TestParseDataKeyWithStartUid(t *testing.T) { startUid := uint64(math.MaxUint64) for uid = 1; uid < 1001; uid++ { sattr := fmt.Sprintf("attr:%d", uid) - key := DataKey(GalaxyAttr(sattr), uid) + key := DataKey(AttrInRootNamespace(sattr), uid) key, err := SplitKey(key, startUid) require.NoError(t, err) pk, err := Parse(key) @@ -85,7 +85,7 @@ func TestIndexKey(t *testing.T) { sattr := fmt.Sprintf("attr:%d", uid) sterm := fmt.Sprintf("term:%d", uid) - key := IndexKey(GalaxyAttr(sattr), sterm) + key := IndexKey(AttrInRootNamespace(sattr), sterm) pk, err := Parse(key) require.NoError(t, err) @@ -101,7 +101,7 @@ func TestIndexKeyWithStartUid(t *testing.T) { sattr := fmt.Sprintf("attr:%d", uid) sterm := fmt.Sprintf("term:%d", uid) - key := IndexKey(GalaxyAttr(sattr), sterm) + key := IndexKey(AttrInRootNamespace(sattr), sterm) key, err := SplitKey(key, startUid) require.NoError(t, err) pk, err := Parse(key) @@ -120,7 +120,7 @@ func TestReverseKey(t *testing.T) { for uid = 1; uid < 1001; uid++ { sattr := fmt.Sprintf("attr:%d", uid) - key := ReverseKey(GalaxyAttr(sattr), uid) + key := ReverseKey(AttrInRootNamespace(sattr), uid) pk, err := Parse(key) require.NoError(t, err) @@ -136,7 +136,7 @@ func TestReverseKeyWithStartUid(t *testing.T) { for uid = 1; uid < 1001; uid++ { sattr := fmt.Sprintf("attr:%d", uid) - key := ReverseKey(GalaxyAttr(sattr), uid) + key := ReverseKey(AttrInRootNamespace(sattr), uid) key, err := SplitKey(key, startUid) require.NoError(t, err) pk, err := Parse(key) @@ -155,7 +155,7 @@ func TestCountKey(t *testing.T) { for count := range uint32(1001) { sattr := fmt.Sprintf("attr:%d", count) - key := CountKey(GalaxyAttr(sattr), count, true) + key := CountKey(AttrInRootNamespace(sattr), count, true) pk, err := Parse(key) require.NoError(t, err) @@ -170,7 +170,7 @@ func TestCountKeyWithStartUid(t *testing.T) { for count := range uint32(1001) { sattr := fmt.Sprintf("attr:%d", count) - key := CountKey(GalaxyAttr(sattr), count, true) + key := CountKey(AttrInRootNamespace(sattr), count, true) key, err := SplitKey(key, startUid) require.NoError(t, err) pk, err := Parse(key) @@ -188,7 +188,7 @@ func TestSchemaKey(t *testing.T) { for uid := range 1001 { sattr := fmt.Sprintf("attr:%d", uid) - key := SchemaKey(GalaxyAttr(sattr)) + key := SchemaKey(AttrInRootNamespace(sattr)) pk, err := Parse(key) require.NoError(t, err) @@ -201,7 +201,7 @@ func TestTypeKey(t *testing.T) { for uid := range 1001 { sattr := fmt.Sprintf("attr:%d", uid) - key := TypeKey(GalaxyAttr(sattr)) + key := TypeKey(AttrInRootNamespace(sattr)) pk, err := Parse(key) require.NoError(t, err) @@ -221,16 +221,16 @@ func TestBadStartUid(t *testing.T) { require.Error(t, err) } - key := DataKey(GalaxyAttr("aa"), 1) + key := DataKey(AttrInRootNamespace("aa"), 1) testKey(key) - key = ReverseKey(GalaxyAttr("aa"), 1) + key = ReverseKey(AttrInRootNamespace("aa"), 1) testKey(key) - key = CountKey(GalaxyAttr("aa"), 0, false) + key = CountKey(AttrInRootNamespace("aa"), 0, false) testKey(key) - key = CountKey(GalaxyAttr("aa"), 0, true) + key = CountKey(AttrInRootNamespace("aa"), 0, true) testKey(key) } @@ -256,7 +256,7 @@ func TestBadKeys(t *testing.T) { // key with uid = 0 is invalid uid := 0 - key = DataKey(GalaxyAttr("bad uid"), uint64(uid)) + key = DataKey(AttrInRootNamespace("bad uid"), uint64(uid)) _, err = Parse(key) require.Error(t, err) } @@ -280,11 +280,11 @@ func TestJsonMarshal(t *testing.T) { func TestNsSeparator(t *testing.T) { uid := uint64(10) pred := "name" + NsSeparator + "surname" - key := DataKey(GalaxyAttr(pred), uid) + key := DataKey(AttrInRootNamespace(pred), uid) pk, err := Parse(key) require.NoError(t, err) require.Equal(t, uid, pk.Uid) ns, attr := ParseNamespaceAttr(pk.Attr) - require.Equal(t, GalaxyNamespace, ns) + require.Equal(t, RootNamespace, ns) require.Equal(t, pred, attr) } diff --git a/x/x.go b/x/x.go index 2132f70ad93..db2053f0706 100644 --- a/x/x.go +++ b/x/x.go @@ -112,8 +112,8 @@ const ( // GrootId is the ID of the admin user for ACLs. GrootId = "groot" - // GuardiansId is the ID of the admin group for ACLs. - GuardiansId = "guardians" + // SuperAdminId is the ID of the admin group for ACLs. + SuperAdminId = "guardians" // GroupIdFileName is the name of the file storing the ID of the group to which // the data in a postings directory belongs. This ID is used to join the proper @@ -137,15 +137,15 @@ var ( regExpHostName = regexp.MustCompile(ValidHostnameRegex) // Nilbyte is a nil byte slice. Used Nilbyte []byte - // GuardiansUid is a map from namespace to the Uid of guardians group node. - GuardiansUid = &sync.Map{} + // SuperAdminUid is a map from namespace to the Uid of superadmin group node. + SuperAdminUid = &sync.Map{} // GrootUid is a map from namespace to the Uid of groot user node. GrootUid = &sync.Map{} ) func init() { - GuardiansUid.Store(GalaxyNamespace, 0) - GrootUid.Store(GalaxyNamespace, 0) + SuperAdminUid.Store(RootNamespace, 0) + GrootUid.Store(RootNamespace, 0) } // ShouldCrash returns true if the error should cause the process to crash. @@ -268,7 +268,7 @@ func ExtractNamespace(ctx context.Context) (uint64, error) { return namespace, nil } -func IsGalaxyOperation(ctx context.Context) bool { +func IsRootNsOperation(ctx context.Context) bool { md, ok := metadata.FromIncomingContext(ctx) if !ok { return false @@ -429,7 +429,7 @@ func ParseRequest(w http.ResponseWriter, r *http.Request, data interface{}) bool // it attaches the galaxy namespace. func AttachJWTNamespace(ctx context.Context) context.Context { if !WorkerConfig.AclEnabled { - return AttachNamespace(ctx, GalaxyNamespace) + return AttachNamespace(ctx, RootNamespace) } ns, err := ExtractNamespaceFrom(ctx) @@ -458,7 +458,7 @@ func AttachNamespace(ctx context.Context, namespace uint64) context.Context { // the context. func AttachJWTNamespaceOutgoing(ctx context.Context) (context.Context, error) { if !WorkerConfig.AclEnabled { - return AttachNamespaceOutgoing(ctx, GalaxyNamespace), nil + return AttachNamespaceOutgoing(ctx, RootNamespace), nil } ns, err := ExtractNamespaceFrom(ctx) if err != nil { @@ -478,8 +478,8 @@ func AttachNamespaceOutgoing(ctx context.Context, namespace uint64) context.Cont return metadata.NewOutgoingContext(ctx, md) } -// AttachGalaxyOperation specifies in the context that it will be used for doing a galaxy operation. -func AttachGalaxyOperation(ctx context.Context, ns uint64) context.Context { +// AttachRootNsOperation specifies in the context that it will be used for doing a Root Namespace operation. +func AttachRootNsOperation(ctx context.Context, ns uint64) context.Context { md, ok := metadata.FromOutgoingContext(ctx) if !ok { md = metadata.New(nil) @@ -1169,9 +1169,9 @@ func GetPassAndLogin(dg *dgo.Dgraph, opt *CredOpt) error { return nil } -func IsGuardian(groups []string) bool { +func IsSuperAdmin(groups []string) bool { for _, group := range groups { - if group == GuardiansId { + if group == SuperAdminId { return true } }