Update API codes (#336)

This commit is contained in:
Jeff Mitchell authored and GitHub committed 2020-09-08 23:57:26 -04:00
1 parent 99d5456d7a
commit f94f21fd97
74 files changed
+1557 -1802

No files matched your search

@@ -80,7 +80,7 @@ func TestGet(t *testing.T) {
scopeId: o.GetPublicId(),
req: &pbs.GetAuthMethodRequest{Id: password.AuthMethodPrefix + "_DoesntExis"},
res: nil,
errCode: codes.PermissionDenied,
errCode: codes.NotFound,
},
{
name: "Wrong id prefix",
@@ -186,11 +186,10 @@ func TestList(t *testing.T) {
res: &pbs.ListAuthMethodsResponse{},
errCode: codes.OK,
},
// TODO: When an auth method doesn't exist, we should return a 404 instead of an empty list.
{
name: "Unfound Auth Method",
scopeId: password.AuthMethodPrefix + "_DoesntExis",
errCode: codes.PermissionDenied,
scopeId: "o_DoesntExis",
errCode: codes.NotFound,
},
}
for _, tc := range cases {
@@ -236,9 +235,6 @@ func TestDelete(t *testing.T) {
req: &pbs.DeleteAuthMethodRequest{
Id: am.GetPublicId(),
},
res: &pbs.DeleteAuthMethodResponse{
Existed: true,
},
errCode: codes.OK,
},
{
@@ -246,14 +242,13 @@ func TestDelete(t *testing.T) {
req: &pbs.DeleteAuthMethodRequest{
Id: password.AuthMethodPrefix + "_doesntexis",
},
errCode: codes.PermissionDenied,
errCode: codes.NotFound,
},
{
name: "Bad AuthMethod Id formatting",
req: &pbs.DeleteAuthMethodRequest{
Id: "bad_format",
},
res: nil,
errCode: codes.InvalidArgument,
},
}
@@ -290,12 +285,11 @@ func TestDelete_twice(t *testing.T) {
req := &pbs.DeleteAuthMethodRequest{
Id: am.GetPublicId(),
}
got, gErr := s.DeleteAuthMethod(auth.DisabledAuthTestContext(auth.WithScopeId(o.GetPublicId())), req)
_, gErr := s.DeleteAuthMethod(auth.DisabledAuthTestContext(auth.WithScopeId(o.GetPublicId())), req)
assert.NoError(gErr, "First attempt")
assert.True(got.GetExisted(), "Expected existed to be true for the first delete.")
got, gErr = s.DeleteAuthMethod(auth.DisabledAuthTestContext(auth.WithScopeId(o.GetPublicId())), req)
_, gErr = s.DeleteAuthMethod(auth.DisabledAuthTestContext(auth.WithScopeId(o.GetPublicId())), req)
assert.Error(gErr, "Second attempt")
assert.Equal(codes.PermissionDenied, status.Code(gErr), "Expected permission denied for the second delete.")
assert.Equal(codes.NotFound, status.Code(gErr), "Expected permission denied for the second delete.")
}
func TestCreate(t *testing.T) {
@@ -705,7 +699,7 @@ func TestUpdate(t *testing.T) {
Description: &wrapperspb.StringValue{Value: "desc"},
},
},
errCode: codes.PermissionDenied,
errCode: codes.NotFound,
},
{
name: "Cant change Id",