Move actions, resource (types), and scopes to packages. (#149)

This commit is contained in:
Jeff Mitchell authored and GitHub committed 2020-06-26 11:00:14 -04:00
1 parent 9d1d0ba08e
commit d8f11af4d7
37 files changed
+721 -460

No files matched your search

@@ -12,6 +12,7 @@ import (
pbs "github.com/hashicorp/watchtower/internal/gen/controller/api/services"
"github.com/hashicorp/watchtower/internal/iam"
"github.com/hashicorp/watchtower/internal/servers/controller/handlers"
"github.com/hashicorp/watchtower/internal/types/scope"
"google.golang.org/grpc/codes"
"google.golang.org/grpc/status"
"google.golang.org/protobuf/types/known/wrapperspb"
@@ -347,7 +348,7 @@ func validateAncestors(r ancestorProvider) map[string]string {
if r.GetOrgId() == "" {
return map[string]string{orgIdFieldName: "Missing organization id."}
}
if !validId(r.GetOrgId(), iam.OrganizationScope.Prefix()+"_") {
if !validId(r.GetOrgId(), scope.Organization.Prefix()+"_") {
return map[string]string{orgIdFieldName: "Improperly formatted identifier."}
}
return map[string]string{}
@@ -12,6 +12,7 @@ import (
pbs "github.com/hashicorp/watchtower/internal/gen/controller/api/services"
"github.com/hashicorp/watchtower/internal/iam"
"github.com/hashicorp/watchtower/internal/servers/controller/handlers/groups"
"github.com/hashicorp/watchtower/internal/types/scope"
"google.golang.org/genproto/protobuf/field_mask"
"google.golang.org/grpc/codes"
"google.golang.org/grpc/status"
@@ -155,14 +156,14 @@ func TestList(t *testing.T) {
},
{
name: "Invalid Org Id",
req: &pbs.ListGroupsRequest{OrgId: iam.OrganizationScope.Prefix() + "_this is invalid"},
req: &pbs.ListGroupsRequest{OrgId: scope.Organization.Prefix() + "_this is invalid"},
res: nil,
errCode: codes.InvalidArgument,
},
// TODO: When an org doesn't exist, we should return a 404 instead of an empty list.
{
name: "Unfound Org",
req: &pbs.ListGroupsRequest{OrgId: iam.OrganizationScope.Prefix() + "_DoesntExis"},
req: &pbs.ListGroupsRequest{OrgId: scope.Organization.Prefix() + "_DoesntExis"},
res: &pbs.ListGroupsResponse{},
errCode: codes.OK,
},