Skip to content

Commit

Permalink
fix: check existence before banning namespace
Browse files Browse the repository at this point in the history
  • Loading branch information
ahsanbarkati authored and mangalaman93 committed May 31, 2023
1 parent 845593a commit 0a9c5ca
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 0 deletions.
3 changes: 3 additions & 0 deletions edgraph/multi_tenancy_ee.go
Original file line number Diff line number Diff line change
Expand Up @@ -138,5 +138,8 @@ func createGuardianAndGroot(ctx context.Context, namespace uint64, passwd string
// Authorization is handled by middlewares.
func (s *Server) DeleteNamespace(ctx context.Context, namespace uint64) error {
glog.Info("Deleting namespace", namespace)
if _, ok := schema.State().Namespaces()[namespace]; !ok {
return errors.Errorf("The namespace %#x doesn't exist", namespace)
}
return worker.ProcessDeleteNsRequest(ctx, namespace)
}
5 changes: 5 additions & 0 deletions systest/multi-tenancy/basic_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -276,6 +276,11 @@ func TestDeleteNamespace(t *testing.T) {
testutil.CompareJSON(t, expected, string(resp))
}

// Deleting a non-existent namespace should error out.
err = testutil.DeleteNamespace(t, galaxyToken, 1000)
require.Error(t, err)
require.Contains(t, err.Error(), "The namespace 0x3e8 doesn't exist")

require.NoError(t, addData(x.GalaxyNamespace))
check(x.GalaxyNamespace, `{"me": [{"name":"0"}]}`)
require.NoError(t, addData(ns))
Expand Down

0 comments on commit 0a9c5ca

Please sign in to comment.