Separate accounts/host catalogs/host sets into their own packages (#311)

This commit is contained in:
Jeff Mitchell authored and GitHub committed 2020-08-27 20:43:33 -04:00
1 parent 936c970635
commit 17ecb6f2ce
64 files changed
+2298 -2265

No files matched your search

@@ -9,7 +9,7 @@ import (
"github.com/hashicorp/boundary/internal/auth/password"
"github.com/hashicorp/boundary/internal/auth/password/store"
"github.com/hashicorp/boundary/internal/db"
pb "github.com/hashicorp/boundary/internal/gen/controller/api/resources/authmethods"
pb "github.com/hashicorp/boundary/internal/gen/controller/api/resources/accounts"
pbs "github.com/hashicorp/boundary/internal/gen/controller/api/services"
"github.com/hashicorp/boundary/internal/servers/controller/handlers"
"google.golang.org/grpc/codes"
@@ -11,7 +11,7 @@ import (
"github.com/hashicorp/boundary/internal/auth/password"
"github.com/hashicorp/boundary/internal/authtoken"
"github.com/hashicorp/boundary/internal/db"
pb "github.com/hashicorp/boundary/internal/gen/controller/api/resources/authmethods"
pb "github.com/hashicorp/boundary/internal/gen/controller/api/resources/accounts"
scopepb "github.com/hashicorp/boundary/internal/gen/controller/api/resources/scopes"
pbs "github.com/hashicorp/boundary/internal/gen/controller/api/services"
"github.com/hashicorp/boundary/internal/iam"
@@ -5,7 +5,7 @@ import (
"fmt"
"github.com/hashicorp/boundary/internal/auth"
pb "github.com/hashicorp/boundary/internal/gen/controller/api/resources/hosts"
pb "github.com/hashicorp/boundary/internal/gen/controller/api/resources/hostcatalogs"
pbs "github.com/hashicorp/boundary/internal/gen/controller/api/services"
"github.com/hashicorp/boundary/internal/host"
"github.com/hashicorp/boundary/internal/host/static"
@@ -265,10 +265,6 @@ func validateCreateRequest(req *pbs.CreateHostCatalogRequest) error {
badFields := map[string]string{}
switch host.SubtypeFromType(req.GetItem().GetType()) {
case host.StaticSubtype:
shcAttrs := &pb.StaticHostCatalogDetails{}
if err := handlers.StructToProto(req.GetItem().GetAttributes(), shcAttrs); err != nil {
badFields["attributes"] = "Attribute fields do not match the expected format."
}
default:
badFields["type"] = fmt.Sprintf("This is a required field and must be %q.", host.StaticSubtype.String())
}
@@ -11,7 +11,7 @@ import (
"github.com/google/go-cmp/cmp"
"github.com/hashicorp/boundary/internal/auth"
"github.com/hashicorp/boundary/internal/db"
pb "github.com/hashicorp/boundary/internal/gen/controller/api/resources/hosts"
pb "github.com/hashicorp/boundary/internal/gen/controller/api/resources/hostcatalogs"
scopepb "github.com/hashicorp/boundary/internal/gen/controller/api/resources/scopes"
pbs "github.com/hashicorp/boundary/internal/gen/controller/api/services"
"github.com/hashicorp/boundary/internal/host/static"
@@ -5,7 +5,7 @@ import (
"fmt"
"github.com/hashicorp/boundary/internal/auth"
pb "github.com/hashicorp/boundary/internal/gen/controller/api/resources/hosts"
pb "github.com/hashicorp/boundary/internal/gen/controller/api/resources/hostsets"
pbs "github.com/hashicorp/boundary/internal/gen/controller/api/services"
"github.com/hashicorp/boundary/internal/host"
"github.com/hashicorp/boundary/internal/host/static"
@@ -11,7 +11,7 @@ import (
"github.com/google/go-cmp/cmp"
"github.com/hashicorp/boundary/internal/auth"
"github.com/hashicorp/boundary/internal/db"
pb "github.com/hashicorp/boundary/internal/gen/controller/api/resources/hosts"
pb "github.com/hashicorp/boundary/internal/gen/controller/api/resources/hostsets"
"github.com/hashicorp/boundary/internal/gen/controller/api/resources/scopes"
pbs "github.com/hashicorp/boundary/internal/gen/controller/api/services"
"github.com/hashicorp/boundary/internal/host"
@@ -5,8 +5,7 @@ import (
structpb "github.com/golang/protobuf/ptypes/struct"
"github.com/google/go-cmp/cmp"
authpb "github.com/hashicorp/boundary/internal/gen/controller/api/resources/authmethods"
hostpb "github.com/hashicorp/boundary/internal/gen/controller/api/resources/hosts"
accountspb "github.com/hashicorp/boundary/internal/gen/controller/api/resources/accounts"
"github.com/stretchr/testify/assert"
"github.com/stretchr/testify/require"
"google.golang.org/protobuf/encoding/protojson"
@@ -23,14 +22,9 @@ func TestStructToProtoToStruct(t *testing.T) {
}{
{
name: "password",
pb: &authpb.PasswordAccountAttributes{LoginName: "testun", Password: &wrapperspb.StringValue{Value: "testpw"}},
pb: &accountspb.PasswordAccountAttributes{LoginName: "testun", Password: &wrapperspb.StringValue{Value: "testpw"}},
wantJson: `{"login_name": "testun", "password": "testpw"}`,
},
{
name: "ec2hostcatalog",
pb: &hostpb.AwsEc2HostCatalogDetails{Regions: []string{"r1", "r2"}, AccessKey: &wrapperspb.StringValue{Value: "test"}},
wantJson: `{"regions": ["r1", "r2"], "access_key": "test"}`,
},
}
for _, tc := range testCases {
t.Run(tc.name, func(t *testing.T) {