Test Cleanup. Alphabetize handler path test and add several paths that were missed (targets and sessions for example) (#534)

This commit is contained in:
Todd Knight authored and GitHub committed 2020-10-06 11:29:53 -07:00
1 parent 73872c5a7e
commit e19d68dcf0
2 files changed
+53 -36

No files matched your search

+44 -33
View File
@@ -93,16 +93,12 @@ func TestHandleImplementedPaths(t *testing.T) {
for verb, paths := range map[string][]string{
"GET": {
"v1/sessions/",
"v1/sessions/someid",
"v1/scopes",
"v1/scopes/someid",
"v1/auth-tokens",
"v1/auth-tokens/someid",
"v1/auth-methods",
"v1/auth-methods/someid",
"v1/accounts",
"v1/accounts/someid",
"v1/auth-methods",
"v1/auth-methods/someid",
"v1/auth-tokens",
"v1/auth-tokens/someid",
"v1/groups",
"v1/groups/someid",
"v1/host-catalogs",
@@ -113,62 +109,77 @@ func TestHandleImplementedPaths(t *testing.T) {
"v1/hosts/someid",
"v1/roles",
"v1/roles/someid",
"v1/users",
"v1/users/someid",
"v1/scopes",
"v1/scopes/someid",
"v1/sessions/",
"v1/sessions/someid",
"v1/targets",
"v1/targets/someid",
"v1/users",
"v1/users/someid",
},
"POST": {
// Creation end points
"v1/scopes",
"v1/groups",
"v1/roles",
"v1/users",
"v1/auth-methods",
"v1/accounts",
"v1/auth-methods",
"v1/groups",
"v1/host-catalogs",
"v1/host-sets",
"v1/hosts",
"v1/roles",
"v1/scopes",
"v1/targets",
"v1/users",
// custom methods
"v1/sessions/someid:cancel",
"v1/auth-methods/someid:authenticate",
"v1/accounts/someid:set-password",
"v1/accounts/someid:change-password",
"v1/roles/someid:add-principals",
"v1/roles/someid:set-principals",
"v1/roles/someid:remove-principals",
"v1/roles/someid:add-grants",
"v1/roles/someid:set-grants",
"v1/roles/someid:remove-grants",
"v1/auth-methods/someid:authenticate",
"v1/groups/someid:add-members",
"v1/groups/someid:set-members",
"v1/groups/someid:remove-members",
"v1/host-sets/someid:add-hosts",
"v1/host-sets/someid:remove-hosts",
"v1/host-sets/someid:set-hosts",
"v1/roles/someid:add-grants",
"v1/roles/someid:set-grants",
"v1/roles/someid:remove-grants",
"v1/roles/someid:add-principals",
"v1/roles/someid:set-principals",
"v1/roles/someid:remove-principals",
"v1/sessions/someid:cancel",
"v1/targets/someid:authorize-session",
"v1/targets/someid:add-host-sets",
"v1/targets/someid:set-host-sets",
"v1/targets/someid:remove-host-sets",
"v1/users/someid:add-accounts",
"v1/users/someid:set-accounts",
"v1/users/someid:remove-accounts",
},
"DELETE": {
"v1/scopes/someid",
"v1/users/someid",
"v1/roles/someid",
"v1/groups/someid",
"v1/auth-tokens/someid",
"v1/auth-methods/someid",
"v1/accounts/someid",
"v1/auth-methods/someid",
"v1/auth-tokens/someid",
"v1/groups/someid",
"v1/host-catalogs/someid",
"v1/host-sets/someid",
"v1/hosts/someid",
"v1/roles/someid",
"v1/scopes/someid",
"v1/targets/someid",
"v1/users/someid",
},
"PATCH": {
"v1/scopes/someid",
"v1/users/someid",
"v1/roles/someid",
"v1/groups/someid",
"v1/accounts/someid",
"v1/auth-methods/someid",
"v1/groups/someid",
"v1/host-catalogs/someid",
"v1/host-sets/someid",
"v1/hosts/someid",
"v1/roles/someid",
"v1/scopes/someid",
"v1/targets/someid",
"v1/users/someid",
},
} {
for _, p := range paths {
@@ -6,6 +6,7 @@ import (
structpb "github.com/golang/protobuf/ptypes/struct"
"github.com/google/go-cmp/cmp"
accountspb "github.com/hashicorp/boundary/internal/gen/controller/api/resources/accounts"
authmethodspb "github.com/hashicorp/boundary/internal/gen/controller/api/resources/authmethods"
hostspb "github.com/hashicorp/boundary/internal/gen/controller/api/resources/hosts"
targetspb "github.com/hashicorp/boundary/internal/gen/controller/api/resources/targets"
"github.com/stretchr/testify/assert"
@@ -23,17 +24,22 @@ func TestStructToProtoToStruct(t *testing.T) {
wantJson string
}{
{
name: "password",
name: "password accounts",
pb: &accountspb.PasswordAccountAttributes{LoginName: "testun", Password: &wrapperspb.StringValue{Value: "testpw"}},
wantJson: `{"login_name": "testun", "password": "testpw"}`,
},
{
name: "tcp",
name: "password auth-methods",
pb: &authmethodspb.PasswordAuthMethodAttributes{MinLoginNameLength: 4, MinPasswordLength: 2},
wantJson: `{"min_login_name_length": 4, "min_password_length": 2}`,
},
{
name: "tcp target",
pb: &targetspb.TcpTargetAttributes{DefaultPort: &wrapperspb.UInt32Value{Value: 22}},
wantJson: `{"default_port": 22}`,
},
{
name: "host",
name: "static host",
pb: &hostspb.StaticHostAttributes{Address: &wrapperspb.StringValue{Value: "::1"}},
wantJson: `{"address": "::1"}`,
},