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) {
+4 -4
View File
@@ -35,14 +35,14 @@ func TestAuthenticationMulti(t *testing.T) {
})
defer c2.Shutdown()
auth := authmethods.NewAuthMethodsClient(c1.Client())
auth := authmethods.NewClient(c1.Client())
token1, apiErr, err := auth.Authenticate(c1.Context(), amId, user, password)
require.Nil(err)
require.Nil(apiErr)
require.NotNil(token1)
time.Sleep(5 * time.Second)
auth = authmethods.NewAuthMethodsClient(c2.Client())
auth = authmethods.NewClient(c2.Client())
token2, apiErr, err := auth.Authenticate(c2.Context(), amId, user, password)
require.Nil(err)
require.Nil(apiErr)
@@ -56,12 +56,12 @@ func TestAuthenticationMulti(t *testing.T) {
c2.Client().SetScopeId(scope.Global.String())
// Create a project, read from the other
org, apiErr, err := scopes.NewScopesClient(c1.Client()).Create(c1.Context(), scope.Global.String())
org, apiErr, err := scopes.NewClient(c1.Client()).Create(c1.Context(), scope.Global.String())
require.NoError(err)
require.Nil(apiErr)
require.NotNil(org)
proj, apiErr, err := scopes.NewScopesClient(c2.Client()).Read(c2.Context(), org.Id)
proj, apiErr, err := scopes.NewClient(c2.Client()).Read(c2.Context(), org.Id)
require.NoError(err)
require.Nil(apiErr)
require.NotNil(proj)