Revert 0bf60996c5 (#3990)
Post-merge some issues were discovered with the ways typing is used for proto reflection. This will be reworked without moving the subtypes around.
This commit is contained in:
1 parent
4239f6d4a9
commit
a9e372930d
84 files changed
+1900
-1557
No files matched your search
@@ -14,6 +14,9 @@ import (
|
||||
"github.com/hashicorp/boundary/api/recovery"
|
||||
"github.com/hashicorp/boundary/globals"
|
||||
"github.com/hashicorp/boundary/internal/auth"
|
||||
"github.com/hashicorp/boundary/internal/auth/ldap"
|
||||
"github.com/hashicorp/boundary/internal/auth/oidc"
|
||||
"github.com/hashicorp/boundary/internal/auth/password"
|
||||
"github.com/hashicorp/boundary/internal/daemon/controller/common"
|
||||
"github.com/hashicorp/boundary/internal/daemon/controller/handlers"
|
||||
"github.com/hashicorp/boundary/internal/errors"
|
||||
@@ -553,21 +556,21 @@ func (v verifier) performAuthCheck(ctx context.Context) (
|
||||
var acct auth.Account
|
||||
var err error
|
||||
switch subtypes.SubtypeFromId(domain, *userData.Account.Id) {
|
||||
case globals.PasswordSubtype:
|
||||
case password.Subtype:
|
||||
repo, repoErr := v.passwordAuthRepoFn()
|
||||
if repoErr != nil {
|
||||
retErr = errors.Wrap(ctx, repoErr, op, errors.WithMsg("failed to get password auth repo"))
|
||||
return
|
||||
}
|
||||
acct, err = repo.LookupAccount(ctx, *userData.Account.Id)
|
||||
case globals.OidcSubtype:
|
||||
case oidc.Subtype:
|
||||
repo, repoErr := v.oidcAuthRepoFn()
|
||||
if repoErr != nil {
|
||||
retErr = errors.Wrap(ctx, repoErr, op, errors.WithMsg("failed to get oidc auth repo"))
|
||||
return
|
||||
}
|
||||
acct, err = repo.LookupAccount(ctx, *userData.Account.Id)
|
||||
case globals.LdapSubtype:
|
||||
case ldap.Subtype:
|
||||
repo, repoErr := v.ldapAuthRepoFn()
|
||||
if repoErr != nil {
|
||||
retErr = errors.Wrap(ctx, repoErr, op, errors.WithMsg("failed to get ldap auth repo"))
|
||||
|
||||
@@ -69,8 +69,8 @@ var (
|
||||
|
||||
// IdActions contains the set of actions that can be performed on
|
||||
// individual resources
|
||||
IdActions = map[globals.Subtype]action.ActionSet{
|
||||
globals.PasswordSubtype: {
|
||||
IdActions = map[subtypes.Subtype]action.ActionSet{
|
||||
password.Subtype: {
|
||||
action.NoOp,
|
||||
action.Read,
|
||||
action.Update,
|
||||
@@ -78,13 +78,13 @@ var (
|
||||
action.SetPassword,
|
||||
action.ChangePassword,
|
||||
},
|
||||
globals.OidcSubtype: {
|
||||
oidc.Subtype: {
|
||||
action.NoOp,
|
||||
action.Read,
|
||||
action.Update,
|
||||
action.Delete,
|
||||
},
|
||||
globals.LdapSubtype: {
|
||||
ldap.Subtype: {
|
||||
action.NoOp,
|
||||
action.Read,
|
||||
action.Update,
|
||||
@@ -418,7 +418,7 @@ func (s Service) getFromRepo(ctx context.Context, id string) (auth.Account, []st
|
||||
var acct auth.Account
|
||||
var mgIds []string
|
||||
switch subtypes.SubtypeFromId(domain, id) {
|
||||
case globals.PasswordSubtype:
|
||||
case password.Subtype:
|
||||
repo, err := s.pwRepoFn()
|
||||
if err != nil {
|
||||
return nil, nil, err
|
||||
@@ -431,7 +431,7 @@ func (s Service) getFromRepo(ctx context.Context, id string) (auth.Account, []st
|
||||
return nil, nil, err
|
||||
}
|
||||
acct = a
|
||||
case globals.OidcSubtype:
|
||||
case oidc.Subtype:
|
||||
repo, err := s.oidcRepoFn()
|
||||
if err != nil {
|
||||
return nil, nil, err
|
||||
@@ -451,7 +451,7 @@ func (s Service) getFromRepo(ctx context.Context, id string) (auth.Account, []st
|
||||
mgIds = append(mgIds, mg.GetManagedGroupId())
|
||||
}
|
||||
acct = a
|
||||
case globals.LdapSubtype:
|
||||
case ldap.Subtype:
|
||||
repo, err := s.ldapRepoFn()
|
||||
if err != nil {
|
||||
return nil, nil, err
|
||||
@@ -593,7 +593,7 @@ func (s Service) createInRepo(ctx context.Context, am auth.AuthMethod, item *pb.
|
||||
}
|
||||
var out auth.Account
|
||||
switch subtypes.SubtypeFromId(domain, am.GetPublicId()) {
|
||||
case globals.PasswordSubtype:
|
||||
case password.Subtype:
|
||||
am, err := s.createPwInRepo(ctx, am, item)
|
||||
if err != nil {
|
||||
return nil, errors.Wrap(ctx, err, op)
|
||||
@@ -602,7 +602,7 @@ func (s Service) createInRepo(ctx context.Context, am auth.AuthMethod, item *pb.
|
||||
return nil, handlers.ApiErrorWithCodeAndMessage(codes.Internal, "Unable to create account but no error returned from repository.")
|
||||
}
|
||||
out = am
|
||||
case globals.OidcSubtype:
|
||||
case oidc.Subtype:
|
||||
am, err := s.createOidcInRepo(ctx, am, item)
|
||||
if err != nil {
|
||||
return nil, errors.Wrap(ctx, err, op)
|
||||
@@ -611,7 +611,7 @@ func (s Service) createInRepo(ctx context.Context, am auth.AuthMethod, item *pb.
|
||||
return nil, handlers.ApiErrorWithCodeAndMessage(codes.Internal, "Unable to create account but no error returned from repository.")
|
||||
}
|
||||
out = am
|
||||
case globals.LdapSubtype:
|
||||
case ldap.Subtype:
|
||||
am, err := s.createLdapInRepo(ctx, am, item)
|
||||
if err != nil {
|
||||
return nil, errors.Wrap(ctx, err, op)
|
||||
@@ -753,7 +753,7 @@ func (s Service) updateInRepo(ctx context.Context, scopeId, authMethodId string,
|
||||
const op = "accounts.(Service).updateInRepo"
|
||||
var out auth.Account
|
||||
switch subtypes.SubtypeFromId(domain, req.GetId()) {
|
||||
case globals.PasswordSubtype:
|
||||
case password.Subtype:
|
||||
a, err := s.updatePwInRepo(ctx, scopeId, authMethodId, req.GetId(), req.GetUpdateMask().GetPaths(), req.GetItem())
|
||||
if err != nil {
|
||||
return nil, errors.Wrap(ctx, err, op)
|
||||
@@ -762,7 +762,7 @@ func (s Service) updateInRepo(ctx context.Context, scopeId, authMethodId string,
|
||||
return nil, handlers.ApiErrorWithCodeAndMessage(codes.Internal, "Unable to update account but no error returned from repository.")
|
||||
}
|
||||
out = a
|
||||
case globals.OidcSubtype:
|
||||
case oidc.Subtype:
|
||||
a, err := s.updateOidcInRepo(ctx, scopeId, authMethodId, req.GetId(), req.GetUpdateMask().GetPaths(), req.GetItem())
|
||||
if err != nil {
|
||||
return nil, errors.Wrap(ctx, err, op)
|
||||
@@ -771,7 +771,7 @@ func (s Service) updateInRepo(ctx context.Context, scopeId, authMethodId string,
|
||||
return nil, handlers.ApiErrorWithCodeAndMessage(codes.Internal, "Unable to update account but no error returned from repository.")
|
||||
}
|
||||
out = a
|
||||
case globals.LdapSubtype:
|
||||
case ldap.Subtype:
|
||||
a, err := s.updateLdapInRepo(ctx, scopeId, authMethodId, req.GetId(), req.GetUpdateMask().GetPaths(), req.GetItem())
|
||||
if err != nil {
|
||||
return nil, errors.Wrap(ctx, err, op)
|
||||
@@ -789,19 +789,19 @@ func (s Service) deleteFromRepo(ctx context.Context, scopeId, id string) (bool,
|
||||
var rows int
|
||||
var err error
|
||||
switch subtypes.SubtypeFromId(domain, id) {
|
||||
case globals.PasswordSubtype:
|
||||
case password.Subtype:
|
||||
repo, iErr := s.pwRepoFn()
|
||||
if iErr != nil {
|
||||
return false, iErr
|
||||
}
|
||||
rows, err = repo.DeleteAccount(ctx, scopeId, id)
|
||||
case globals.OidcSubtype:
|
||||
case oidc.Subtype:
|
||||
repo, iErr := s.oidcRepoFn()
|
||||
if iErr != nil {
|
||||
return false, iErr
|
||||
}
|
||||
rows, err = repo.DeleteAccount(ctx, scopeId, id)
|
||||
case globals.LdapSubtype:
|
||||
case ldap.Subtype:
|
||||
repo, iErr := s.ldapRepoFn()
|
||||
if iErr != nil {
|
||||
return false, iErr
|
||||
@@ -822,7 +822,7 @@ func (s Service) listFromRepo(ctx context.Context, authMethodId string) ([]auth.
|
||||
|
||||
var outUl []auth.Account
|
||||
switch subtypes.SubtypeFromId(domain, authMethodId) {
|
||||
case globals.PasswordSubtype:
|
||||
case password.Subtype:
|
||||
pwRepo, err := s.pwRepoFn()
|
||||
if err != nil {
|
||||
return nil, errors.Wrap(ctx, err, op)
|
||||
@@ -834,7 +834,7 @@ func (s Service) listFromRepo(ctx context.Context, authMethodId string) ([]auth.
|
||||
for _, a := range pwl {
|
||||
outUl = append(outUl, a)
|
||||
}
|
||||
case globals.OidcSubtype:
|
||||
case oidc.Subtype:
|
||||
oidcRepo, err := s.oidcRepoFn()
|
||||
if err != nil {
|
||||
return nil, errors.Wrap(ctx, err, op)
|
||||
@@ -846,7 +846,7 @@ func (s Service) listFromRepo(ctx context.Context, authMethodId string) ([]auth.
|
||||
for _, a := range oidcl {
|
||||
outUl = append(outUl, a)
|
||||
}
|
||||
case globals.LdapSubtype:
|
||||
case ldap.Subtype:
|
||||
ldapRepo, err := s.ldapRepoFn()
|
||||
if err != nil {
|
||||
return nil, errors.Wrap(ctx, err, op)
|
||||
@@ -934,7 +934,7 @@ func (s Service) parentAndAuthResult(ctx context.Context, id string, a action.Ty
|
||||
parentId = id
|
||||
default:
|
||||
switch subtypes.SubtypeFromId(domain, id) {
|
||||
case globals.PasswordSubtype:
|
||||
case password.Subtype:
|
||||
acct, err := pwRepo.LookupAccount(ctx, id)
|
||||
if err != nil {
|
||||
res.Error = err
|
||||
@@ -945,7 +945,7 @@ func (s Service) parentAndAuthResult(ctx context.Context, id string, a action.Ty
|
||||
return nil, res
|
||||
}
|
||||
parentId = acct.GetAuthMethodId()
|
||||
case globals.OidcSubtype:
|
||||
case oidc.Subtype:
|
||||
acct, err := oidcRepo.LookupAccount(ctx, id)
|
||||
if err != nil {
|
||||
res.Error = err
|
||||
@@ -956,7 +956,7 @@ func (s Service) parentAndAuthResult(ctx context.Context, id string, a action.Ty
|
||||
return nil, res
|
||||
}
|
||||
parentId = acct.GetAuthMethodId()
|
||||
case globals.LdapSubtype:
|
||||
case ldap.Subtype:
|
||||
acct, err := ldapRepo.LookupAccount(ctx, id)
|
||||
if err != nil {
|
||||
res.Error = err
|
||||
@@ -973,7 +973,7 @@ func (s Service) parentAndAuthResult(ctx context.Context, id string, a action.Ty
|
||||
|
||||
var authMeth auth.AuthMethod
|
||||
switch subtypes.SubtypeFromId(domain, parentId) {
|
||||
case globals.PasswordSubtype:
|
||||
case password.Subtype:
|
||||
am, err := pwRepo.LookupAuthMethod(ctx, parentId)
|
||||
if err != nil {
|
||||
res.Error = err
|
||||
@@ -984,7 +984,7 @@ func (s Service) parentAndAuthResult(ctx context.Context, id string, a action.Ty
|
||||
return nil, res
|
||||
}
|
||||
authMeth = am
|
||||
case globals.OidcSubtype:
|
||||
case oidc.Subtype:
|
||||
am, err := oidcRepo.LookupAuthMethod(ctx, parentId)
|
||||
if err != nil {
|
||||
res.Error = err
|
||||
@@ -995,7 +995,7 @@ func (s Service) parentAndAuthResult(ctx context.Context, id string, a action.Ty
|
||||
return nil, res
|
||||
}
|
||||
authMeth = am
|
||||
case globals.LdapSubtype:
|
||||
case ldap.Subtype:
|
||||
am, err := ldapRepo.LookupAuthMethod(ctx, parentId)
|
||||
if err != nil {
|
||||
res.Error = err
|
||||
@@ -1054,7 +1054,7 @@ func toProto(ctx context.Context, in auth.Account, opt ...handlers.Option) (*pb.
|
||||
switch i := in.(type) {
|
||||
case *password.Account:
|
||||
if outputFields.Has(globals.TypeField) {
|
||||
out.Type = globals.PasswordSubtype.String()
|
||||
out.Type = password.Subtype.String()
|
||||
}
|
||||
if !outputFields.Has(globals.AttributesField) {
|
||||
break
|
||||
@@ -1066,7 +1066,7 @@ func toProto(ctx context.Context, in auth.Account, opt ...handlers.Option) (*pb.
|
||||
}
|
||||
case *oidc.Account:
|
||||
if outputFields.Has(globals.TypeField) {
|
||||
out.Type = globals.OidcSubtype.String()
|
||||
out.Type = oidc.Subtype.String()
|
||||
}
|
||||
if !outputFields.Has(globals.AttributesField) {
|
||||
break
|
||||
@@ -1102,7 +1102,7 @@ func toProto(ctx context.Context, in auth.Account, opt ...handlers.Option) (*pb.
|
||||
out.Attrs = attrs
|
||||
case *ldap.Account:
|
||||
if outputFields.Has(globals.TypeField) {
|
||||
out.Type = globals.LdapSubtype.String()
|
||||
out.Type = ldap.Subtype.String()
|
||||
}
|
||||
if !outputFields.Has(globals.AttributesField) {
|
||||
break
|
||||
@@ -1175,8 +1175,8 @@ func validateCreateRequest(ctx context.Context, req *pbs.CreateAccountRequest) e
|
||||
badFields[authMethodIdField] = "This field is required."
|
||||
}
|
||||
switch subtypes.SubtypeFromId(domain, req.GetItem().GetAuthMethodId()) {
|
||||
case globals.PasswordSubtype:
|
||||
if req.GetItem().GetType() != "" && req.GetItem().GetType() != globals.PasswordSubtype.String() {
|
||||
case password.Subtype:
|
||||
if req.GetItem().GetType() != "" && req.GetItem().GetType() != password.Subtype.String() {
|
||||
badFields[typeField] = "Doesn't match the parent resource's type."
|
||||
}
|
||||
attrs := req.GetItem().GetPasswordAccountAttributes()
|
||||
@@ -1188,8 +1188,8 @@ func validateCreateRequest(ctx context.Context, req *pbs.CreateAccountRequest) e
|
||||
badFields[loginNameKey] = "This is a required field for this type."
|
||||
}
|
||||
}
|
||||
case globals.OidcSubtype:
|
||||
if req.GetItem().GetType() != "" && req.GetItem().GetType() != globals.OidcSubtype.String() {
|
||||
case oidc.Subtype:
|
||||
if req.GetItem().GetType() != "" && req.GetItem().GetType() != oidc.Subtype.String() {
|
||||
badFields[typeField] = "Doesn't match the parent resource's type."
|
||||
}
|
||||
attrs := req.GetItem().GetOidcAccountAttributes()
|
||||
@@ -1216,8 +1216,8 @@ func validateCreateRequest(ctx context.Context, req *pbs.CreateAccountRequest) e
|
||||
badFields[emailClaimField] = "This is a read only field."
|
||||
}
|
||||
}
|
||||
case globals.LdapSubtype:
|
||||
if req.GetItem().GetType() != "" && req.GetItem().GetType() != globals.LdapSubtype.String() {
|
||||
case ldap.Subtype:
|
||||
if req.GetItem().GetType() != "" && req.GetItem().GetType() != ldap.Subtype.String() {
|
||||
badFields[typeField] = "Doesn't match the parent resource's type."
|
||||
}
|
||||
attrs := req.GetItem().GetLdapAccountAttributes()
|
||||
@@ -1256,12 +1256,12 @@ func validateUpdateRequest(ctx context.Context, req *pbs.UpdateAccountRequest) e
|
||||
return handlers.ValidateUpdateRequest(req, req.GetItem(), func() map[string]string {
|
||||
badFields := map[string]string{}
|
||||
switch subtypes.SubtypeFromId(domain, req.GetId()) {
|
||||
case globals.PasswordSubtype:
|
||||
if req.GetItem().GetType() != "" && req.GetItem().GetType() != globals.PasswordSubtype.String() {
|
||||
case password.Subtype:
|
||||
if req.GetItem().GetType() != "" && req.GetItem().GetType() != password.Subtype.String() {
|
||||
badFields[typeField] = "Cannot modify the resource type."
|
||||
}
|
||||
case globals.OidcSubtype:
|
||||
if req.GetItem().GetType() != "" && req.GetItem().GetType() != globals.OidcSubtype.String() {
|
||||
case oidc.Subtype:
|
||||
if req.GetItem().GetType() != "" && req.GetItem().GetType() != oidc.Subtype.String() {
|
||||
badFields[typeField] = "Cannot modify the resource type."
|
||||
}
|
||||
if handlers.MaskContains(req.GetUpdateMask().GetPaths(), subjectField) {
|
||||
@@ -1276,8 +1276,8 @@ func validateUpdateRequest(ctx context.Context, req *pbs.UpdateAccountRequest) e
|
||||
if handlers.MaskContains(req.GetUpdateMask().GetPaths(), nameClaimField) {
|
||||
badFields[nameClaimField] = "Field is read only."
|
||||
}
|
||||
case globals.LdapSubtype:
|
||||
if req.GetItem().GetType() != "" && req.GetItem().GetType() != globals.LdapSubtype.String() {
|
||||
case ldap.Subtype:
|
||||
if req.GetItem().GetType() != "" && req.GetItem().GetType() != ldap.Subtype.String() {
|
||||
badFields[typeField] = "Cannot modify the resource type."
|
||||
}
|
||||
if handlers.MaskContains(req.GetUpdateMask().GetPaths(), loginAttrField) {
|
||||
|
||||
@@ -151,7 +151,7 @@ func TestGet(t *testing.T) {
|
||||
UpdatedTime: pwA.GetUpdateTime().GetTimestamp(),
|
||||
Scope: &scopepb.ScopeInfo{Id: org.GetPublicId(), Type: scope.Org.String(), ParentScopeId: scope.Global.String()},
|
||||
Version: 1,
|
||||
Type: globals.PasswordSubtype.String(),
|
||||
Type: password.Subtype.String(),
|
||||
Attrs: &pb.Account_PasswordAccountAttributes{
|
||||
&pb.PasswordAccountAttributes{LoginName: pwA.GetLoginName()},
|
||||
},
|
||||
@@ -178,7 +178,7 @@ func TestGet(t *testing.T) {
|
||||
UpdatedTime: oidcA.GetUpdateTime().GetTimestamp(),
|
||||
Scope: &scopepb.ScopeInfo{Id: org.GetPublicId(), Type: scope.Org.String(), ParentScopeId: scope.Global.String()},
|
||||
Version: 1,
|
||||
Type: globals.OidcSubtype.String(),
|
||||
Type: oidc.Subtype.String(),
|
||||
Attrs: &pb.Account_OidcAccountAttributes{
|
||||
&pb.OidcAccountAttributes{
|
||||
Issuer: oidcAm.GetIssuer(),
|
||||
@@ -213,7 +213,7 @@ func TestGet(t *testing.T) {
|
||||
MemberOfGroups: []string{"admin"},
|
||||
},
|
||||
},
|
||||
Type: globals.LdapSubtype.String(),
|
||||
Type: ldap.Subtype.String(),
|
||||
AuthorizedActions: ldapAuthorizedActions,
|
||||
ManagedGroupIds: []string{ldapMg.GetPublicId()},
|
||||
}
|
||||
@@ -280,7 +280,7 @@ func TestGet(t *testing.T) {
|
||||
t.Run(tc.name, func(t *testing.T) {
|
||||
assert, require := assert.New(t), require.New(t)
|
||||
|
||||
if subtypes.SubtypeFromId(domain, tc.req.Id) == globals.OidcSubtype {
|
||||
if subtypes.SubtypeFromId(domain, tc.req.Id) == oidc.Subtype {
|
||||
// Set up managed groups before getting. First get the current
|
||||
// managed group to make sure we have the right version.
|
||||
oidcRepo, err := oidcRepoFn()
|
||||
@@ -484,7 +484,7 @@ func TestListOidc(t *testing.T) {
|
||||
UpdatedTime: aa.GetUpdateTime().GetTimestamp(),
|
||||
Scope: &scopepb.ScopeInfo{Id: o.GetPublicId(), Type: scope.Org.String(), ParentScopeId: scope.Global.String()},
|
||||
Version: 1,
|
||||
Type: globals.OidcSubtype.String(),
|
||||
Type: oidc.Subtype.String(),
|
||||
Attrs: &pb.Account_OidcAccountAttributes{
|
||||
&pb.OidcAccountAttributes{
|
||||
Issuer: amSomeAccounts.GetIssuer(),
|
||||
@@ -506,7 +506,7 @@ func TestListOidc(t *testing.T) {
|
||||
UpdatedTime: aa.GetUpdateTime().GetTimestamp(),
|
||||
Scope: &scopepb.ScopeInfo{Id: o.GetPublicId(), Type: scope.Org.String(), ParentScopeId: scope.Global.String()},
|
||||
Version: 1,
|
||||
Type: globals.OidcSubtype.String(),
|
||||
Type: oidc.Subtype.String(),
|
||||
Attrs: &pb.Account_OidcAccountAttributes{
|
||||
&pb.OidcAccountAttributes{
|
||||
Issuer: amOtherAccounts.GetIssuer(),
|
||||
@@ -641,7 +641,7 @@ func TestListLdap(t *testing.T) {
|
||||
UpdatedTime: aa.GetUpdateTime().GetTimestamp(),
|
||||
Scope: &scopepb.ScopeInfo{Id: o.GetPublicId(), Type: scope.Org.String(), ParentScopeId: scope.Global.String()},
|
||||
Version: 1,
|
||||
Type: globals.LdapSubtype.String(),
|
||||
Type: ldap.Subtype.String(),
|
||||
Attrs: &pb.Account_LdapAccountAttributes{
|
||||
LdapAccountAttributes: &pb.LdapAccountAttributes{
|
||||
LoginName: loginName,
|
||||
@@ -662,7 +662,7 @@ func TestListLdap(t *testing.T) {
|
||||
UpdatedTime: aa.GetUpdateTime().GetTimestamp(),
|
||||
Scope: &scopepb.ScopeInfo{Id: o.GetPublicId(), Type: scope.Org.String(), ParentScopeId: scope.Global.String()},
|
||||
Version: 1,
|
||||
Type: globals.LdapSubtype.String(),
|
||||
Type: ldap.Subtype.String(),
|
||||
Attrs: &pb.Account_LdapAccountAttributes{
|
||||
LdapAccountAttributes: &pb.LdapAccountAttributes{
|
||||
LoginName: loginName,
|
||||
@@ -1210,7 +1210,7 @@ func TestCreateOidc(t *testing.T) {
|
||||
AuthMethodId: am.GetPublicId(),
|
||||
Name: &wrapperspb.StringValue{Value: "name"},
|
||||
Description: &wrapperspb.StringValue{Value: "desc"},
|
||||
Type: globals.OidcSubtype.String(),
|
||||
Type: oidc.Subtype.String(),
|
||||
Attrs: &pb.Account_OidcAccountAttributes{
|
||||
&pb.OidcAccountAttributes{
|
||||
Subject: "valid-account",
|
||||
@@ -1226,7 +1226,7 @@ func TestCreateOidc(t *testing.T) {
|
||||
Description: &wrapperspb.StringValue{Value: "desc"},
|
||||
Scope: &scopepb.ScopeInfo{Id: o.GetPublicId(), Type: scope.Org.String(), ParentScopeId: scope.Global.String()},
|
||||
Version: 1,
|
||||
Type: globals.OidcSubtype.String(),
|
||||
Type: oidc.Subtype.String(),
|
||||
Attrs: &pb.Account_OidcAccountAttributes{
|
||||
&pb.OidcAccountAttributes{
|
||||
Subject: "valid-account",
|
||||
@@ -1255,7 +1255,7 @@ func TestCreateOidc(t *testing.T) {
|
||||
AuthMethodId: am.GetPublicId(),
|
||||
Scope: &scopepb.ScopeInfo{Id: o.GetPublicId(), Type: scope.Org.String(), ParentScopeId: scope.Global.String()},
|
||||
Version: 1,
|
||||
Type: globals.OidcSubtype.String(),
|
||||
Type: oidc.Subtype.String(),
|
||||
Attrs: &pb.Account_OidcAccountAttributes{
|
||||
&pb.OidcAccountAttributes{
|
||||
Subject: "no type defined",
|
||||
@@ -1272,7 +1272,7 @@ func TestCreateOidc(t *testing.T) {
|
||||
Item: &pb.Account{
|
||||
AuthMethodId: am.GetPublicId(),
|
||||
Name: &wrapperspb.StringValue{Value: "overwritten issuer"},
|
||||
Type: globals.OidcSubtype.String(),
|
||||
Type: oidc.Subtype.String(),
|
||||
Attrs: &pb.Account_OidcAccountAttributes{
|
||||
&pb.OidcAccountAttributes{
|
||||
Subject: "overwritten-issuer",
|
||||
@@ -1288,7 +1288,7 @@ func TestCreateOidc(t *testing.T) {
|
||||
Name: &wrapperspb.StringValue{Value: "overwritten issuer"},
|
||||
Scope: &scopepb.ScopeInfo{Id: o.GetPublicId(), Type: scope.Org.String(), ParentScopeId: scope.Global.String()},
|
||||
Version: 1,
|
||||
Type: globals.OidcSubtype.String(),
|
||||
Type: oidc.Subtype.String(),
|
||||
Attrs: &pb.Account_OidcAccountAttributes{
|
||||
&pb.OidcAccountAttributes{
|
||||
Subject: "overwritten-issuer",
|
||||
@@ -1304,7 +1304,7 @@ func TestCreateOidc(t *testing.T) {
|
||||
req: &pbs.CreateAccountRequest{
|
||||
Item: &pb.Account{
|
||||
AuthMethodId: am.GetPublicId(),
|
||||
Type: globals.PasswordSubtype.String(),
|
||||
Type: password.Subtype.String(),
|
||||
Attrs: &pb.Account_OidcAccountAttributes{
|
||||
&pb.OidcAccountAttributes{
|
||||
Subject: "cant-specify-mismatching-type",
|
||||
@@ -1321,7 +1321,7 @@ func TestCreateOidc(t *testing.T) {
|
||||
Item: &pb.Account{
|
||||
AuthMethodId: am.GetPublicId(),
|
||||
Id: globals.OidcAccountPrefix + "_notallowed",
|
||||
Type: globals.OidcSubtype.String(),
|
||||
Type: oidc.Subtype.String(),
|
||||
Attrs: &pb.Account_OidcAccountAttributes{
|
||||
&pb.OidcAccountAttributes{
|
||||
Subject: "cant-specify-id",
|
||||
@@ -1338,7 +1338,7 @@ func TestCreateOidc(t *testing.T) {
|
||||
Item: &pb.Account{
|
||||
AuthMethodId: am.GetPublicId(),
|
||||
CreatedTime: timestamppb.Now(),
|
||||
Type: globals.OidcSubtype.String(),
|
||||
Type: oidc.Subtype.String(),
|
||||
Attrs: &pb.Account_OidcAccountAttributes{
|
||||
&pb.OidcAccountAttributes{
|
||||
Subject: "cant-specify-created-time",
|
||||
@@ -1355,7 +1355,7 @@ func TestCreateOidc(t *testing.T) {
|
||||
Item: &pb.Account{
|
||||
AuthMethodId: am.GetPublicId(),
|
||||
UpdatedTime: timestamppb.Now(),
|
||||
Type: globals.OidcSubtype.String(),
|
||||
Type: oidc.Subtype.String(),
|
||||
Attrs: &pb.Account_OidcAccountAttributes{
|
||||
&pb.OidcAccountAttributes{
|
||||
Subject: "cant-specify-update-time",
|
||||
@@ -1371,7 +1371,7 @@ func TestCreateOidc(t *testing.T) {
|
||||
req: &pbs.CreateAccountRequest{
|
||||
Item: &pb.Account{
|
||||
AuthMethodId: am.GetPublicId(),
|
||||
Type: globals.OidcSubtype.String(),
|
||||
Type: oidc.Subtype.String(),
|
||||
},
|
||||
},
|
||||
res: nil,
|
||||
@@ -1442,7 +1442,7 @@ func TestCreateLdap(t *testing.T) {
|
||||
AuthMethodId: am.GetPublicId(),
|
||||
Name: &wrapperspb.StringValue{Value: "name"},
|
||||
Description: &wrapperspb.StringValue{Value: "desc"},
|
||||
Type: globals.LdapSubtype.String(),
|
||||
Type: ldap.Subtype.String(),
|
||||
Attrs: &pb.Account_LdapAccountAttributes{
|
||||
LdapAccountAttributes: &pb.LdapAccountAttributes{
|
||||
LoginName: "valid-account",
|
||||
@@ -1458,7 +1458,7 @@ func TestCreateLdap(t *testing.T) {
|
||||
Description: &wrapperspb.StringValue{Value: "desc"},
|
||||
Scope: &scopepb.ScopeInfo{Id: o.GetPublicId(), Type: scope.Org.String(), ParentScopeId: scope.Global.String()},
|
||||
Version: 1,
|
||||
Type: globals.LdapSubtype.String(),
|
||||
Type: ldap.Subtype.String(),
|
||||
Attrs: &pb.Account_LdapAccountAttributes{
|
||||
LdapAccountAttributes: &pb.LdapAccountAttributes{
|
||||
LoginName: "valid-account",
|
||||
@@ -1486,7 +1486,7 @@ func TestCreateLdap(t *testing.T) {
|
||||
AuthMethodId: am.GetPublicId(),
|
||||
Scope: &scopepb.ScopeInfo{Id: o.GetPublicId(), Type: scope.Org.String(), ParentScopeId: scope.Global.String()},
|
||||
Version: 1,
|
||||
Type: globals.LdapSubtype.String(),
|
||||
Type: ldap.Subtype.String(),
|
||||
Attrs: &pb.Account_LdapAccountAttributes{
|
||||
LdapAccountAttributes: &pb.LdapAccountAttributes{
|
||||
LoginName: "no type defined",
|
||||
@@ -1501,7 +1501,7 @@ func TestCreateLdap(t *testing.T) {
|
||||
req: &pbs.CreateAccountRequest{
|
||||
Item: &pb.Account{
|
||||
AuthMethodId: am.GetPublicId(),
|
||||
Type: globals.PasswordSubtype.String(),
|
||||
Type: password.Subtype.String(),
|
||||
Attrs: &pb.Account_LdapAccountAttributes{
|
||||
LdapAccountAttributes: &pb.LdapAccountAttributes{
|
||||
LoginName: "cant-specify-mismatching-type",
|
||||
@@ -1519,7 +1519,7 @@ func TestCreateLdap(t *testing.T) {
|
||||
Item: &pb.Account{
|
||||
AuthMethodId: am.GetPublicId(),
|
||||
Id: globals.LdapAccountPrefix + "_notallowed",
|
||||
Type: globals.LdapSubtype.String(),
|
||||
Type: ldap.Subtype.String(),
|
||||
Attrs: &pb.Account_LdapAccountAttributes{
|
||||
LdapAccountAttributes: &pb.LdapAccountAttributes{
|
||||
LoginName: "cant-specify-mismatching-type",
|
||||
@@ -1537,7 +1537,7 @@ func TestCreateLdap(t *testing.T) {
|
||||
Item: &pb.Account{
|
||||
AuthMethodId: am.GetPublicId(),
|
||||
CreatedTime: timestamppb.Now(),
|
||||
Type: globals.OidcSubtype.String(),
|
||||
Type: oidc.Subtype.String(),
|
||||
Attrs: &pb.Account_LdapAccountAttributes{
|
||||
LdapAccountAttributes: &pb.LdapAccountAttributes{
|
||||
LoginName: "cant-specify-mismatching-type",
|
||||
@@ -1555,7 +1555,7 @@ func TestCreateLdap(t *testing.T) {
|
||||
Item: &pb.Account{
|
||||
AuthMethodId: am.GetPublicId(),
|
||||
UpdatedTime: timestamppb.Now(),
|
||||
Type: globals.LdapSubtype.String(),
|
||||
Type: ldap.Subtype.String(),
|
||||
Attrs: &pb.Account_LdapAccountAttributes{
|
||||
LdapAccountAttributes: &pb.LdapAccountAttributes{
|
||||
LoginName: "cant-specify-mismatching-type",
|
||||
@@ -1572,7 +1572,7 @@ func TestCreateLdap(t *testing.T) {
|
||||
req: &pbs.CreateAccountRequest{
|
||||
Item: &pb.Account{
|
||||
AuthMethodId: am.GetPublicId(),
|
||||
Type: globals.LdapSubtype.String(),
|
||||
Type: ldap.Subtype.String(),
|
||||
Attrs: &pb.Account_LdapAccountAttributes{
|
||||
LdapAccountAttributes: &pb.LdapAccountAttributes{},
|
||||
},
|
||||
@@ -1587,7 +1587,7 @@ func TestCreateLdap(t *testing.T) {
|
||||
req: &pbs.CreateAccountRequest{
|
||||
Item: &pb.Account{
|
||||
AuthMethodId: am.GetPublicId(),
|
||||
Type: globals.LdapSubtype.String(),
|
||||
Type: ldap.Subtype.String(),
|
||||
Attrs: &pb.Account_LdapAccountAttributes{
|
||||
LdapAccountAttributes: &pb.LdapAccountAttributes{
|
||||
LoginName: "cant-specify-full-name",
|
||||
@@ -1605,7 +1605,7 @@ func TestCreateLdap(t *testing.T) {
|
||||
req: &pbs.CreateAccountRequest{
|
||||
Item: &pb.Account{
|
||||
AuthMethodId: am.GetPublicId(),
|
||||
Type: globals.LdapSubtype.String(),
|
||||
Type: ldap.Subtype.String(),
|
||||
Attrs: &pb.Account_LdapAccountAttributes{
|
||||
LdapAccountAttributes: &pb.LdapAccountAttributes{
|
||||
LoginName: "cant-specify-email",
|
||||
@@ -1623,7 +1623,7 @@ func TestCreateLdap(t *testing.T) {
|
||||
req: &pbs.CreateAccountRequest{
|
||||
Item: &pb.Account{
|
||||
AuthMethodId: am.GetPublicId(),
|
||||
Type: globals.LdapSubtype.String(),
|
||||
Type: ldap.Subtype.String(),
|
||||
Attrs: &pb.Account_LdapAccountAttributes{
|
||||
LdapAccountAttributes: &pb.LdapAccountAttributes{
|
||||
LoginName: "cant-specify-dn",
|
||||
@@ -1641,7 +1641,7 @@ func TestCreateLdap(t *testing.T) {
|
||||
req: &pbs.CreateAccountRequest{
|
||||
Item: &pb.Account{
|
||||
AuthMethodId: am.GetPublicId(),
|
||||
Type: globals.LdapSubtype.String(),
|
||||
Type: ldap.Subtype.String(),
|
||||
Attrs: &pb.Account_LdapAccountAttributes{
|
||||
LdapAccountAttributes: &pb.LdapAccountAttributes{
|
||||
LoginName: "cant-specify-member-of",
|
||||
@@ -2145,7 +2145,7 @@ func TestUpdateOidc(t *testing.T) {
|
||||
Item: &pb.Account{
|
||||
Name: &wrapperspb.StringValue{Value: "new"},
|
||||
Description: &wrapperspb.StringValue{Value: "desc"},
|
||||
Type: globals.OidcSubtype.String(),
|
||||
Type: oidc.Subtype.String(),
|
||||
},
|
||||
},
|
||||
res: &pbs.UpdateAccountResponse{
|
||||
@@ -2153,7 +2153,7 @@ func TestUpdateOidc(t *testing.T) {
|
||||
AuthMethodId: am.GetPublicId(),
|
||||
Name: &wrapperspb.StringValue{Value: "new"},
|
||||
Description: &wrapperspb.StringValue{Value: "desc"},
|
||||
Type: globals.OidcSubtype.String(),
|
||||
Type: oidc.Subtype.String(),
|
||||
Attrs: defaultAttributes,
|
||||
Scope: defaultScopeInfo,
|
||||
AuthorizedActions: oidcAuthorizedActions,
|
||||
@@ -2169,7 +2169,7 @@ func TestUpdateOidc(t *testing.T) {
|
||||
Item: &pb.Account{
|
||||
Name: &wrapperspb.StringValue{Value: "new"},
|
||||
Description: &wrapperspb.StringValue{Value: "desc"},
|
||||
Type: globals.OidcSubtype.String(),
|
||||
Type: oidc.Subtype.String(),
|
||||
},
|
||||
},
|
||||
res: &pbs.UpdateAccountResponse{
|
||||
@@ -2177,7 +2177,7 @@ func TestUpdateOidc(t *testing.T) {
|
||||
AuthMethodId: am.GetPublicId(),
|
||||
Name: &wrapperspb.StringValue{Value: "new"},
|
||||
Description: &wrapperspb.StringValue{Value: "desc"},
|
||||
Type: globals.OidcSubtype.String(),
|
||||
Type: oidc.Subtype.String(),
|
||||
Attrs: defaultAttributes,
|
||||
Scope: defaultScopeInfo,
|
||||
AuthorizedActions: oidcAuthorizedActions,
|
||||
@@ -2247,7 +2247,7 @@ func TestUpdateOidc(t *testing.T) {
|
||||
Item: &pb.Account{
|
||||
AuthMethodId: am.GetPublicId(),
|
||||
Description: &wrapperspb.StringValue{Value: "default"},
|
||||
Type: globals.OidcSubtype.String(),
|
||||
Type: oidc.Subtype.String(),
|
||||
Attrs: defaultAttributes,
|
||||
Scope: defaultScopeInfo,
|
||||
AuthorizedActions: oidcAuthorizedActions,
|
||||
@@ -2271,7 +2271,7 @@ func TestUpdateOidc(t *testing.T) {
|
||||
AuthMethodId: am.GetPublicId(),
|
||||
Name: &wrapperspb.StringValue{Value: "updated"},
|
||||
Description: &wrapperspb.StringValue{Value: "default"},
|
||||
Type: globals.OidcSubtype.String(),
|
||||
Type: oidc.Subtype.String(),
|
||||
Attrs: defaultAttributes,
|
||||
Scope: defaultScopeInfo,
|
||||
AuthorizedActions: oidcAuthorizedActions,
|
||||
@@ -2295,7 +2295,7 @@ func TestUpdateOidc(t *testing.T) {
|
||||
AuthMethodId: am.GetPublicId(),
|
||||
Name: &wrapperspb.StringValue{Value: "default"},
|
||||
Description: &wrapperspb.StringValue{Value: "notignored"},
|
||||
Type: globals.OidcSubtype.String(),
|
||||
Type: oidc.Subtype.String(),
|
||||
Attrs: defaultAttributes,
|
||||
Scope: defaultScopeInfo,
|
||||
AuthorizedActions: oidcAuthorizedActions,
|
||||
@@ -2524,7 +2524,7 @@ func TestUpdateLdap(t *testing.T) {
|
||||
Item: &pb.Account{
|
||||
Name: &wrapperspb.StringValue{Value: "new"},
|
||||
Description: &wrapperspb.StringValue{Value: "desc"},
|
||||
Type: globals.LdapSubtype.String(),
|
||||
Type: ldap.Subtype.String(),
|
||||
},
|
||||
},
|
||||
res: &pbs.UpdateAccountResponse{
|
||||
@@ -2532,7 +2532,7 @@ func TestUpdateLdap(t *testing.T) {
|
||||
AuthMethodId: am.GetPublicId(),
|
||||
Name: &wrapperspb.StringValue{Value: "new"},
|
||||
Description: &wrapperspb.StringValue{Value: "desc"},
|
||||
Type: globals.LdapSubtype.String(),
|
||||
Type: ldap.Subtype.String(),
|
||||
Attrs: defaultAttributes,
|
||||
Scope: defaultScopeInfo,
|
||||
AuthorizedActions: ldapAuthorizedActions,
|
||||
@@ -2548,7 +2548,7 @@ func TestUpdateLdap(t *testing.T) {
|
||||
Item: &pb.Account{
|
||||
Name: &wrapperspb.StringValue{Value: "new"},
|
||||
Description: &wrapperspb.StringValue{Value: "desc"},
|
||||
Type: globals.LdapSubtype.String(),
|
||||
Type: ldap.Subtype.String(),
|
||||
},
|
||||
},
|
||||
res: &pbs.UpdateAccountResponse{
|
||||
@@ -2556,7 +2556,7 @@ func TestUpdateLdap(t *testing.T) {
|
||||
AuthMethodId: am.GetPublicId(),
|
||||
Name: &wrapperspb.StringValue{Value: "new"},
|
||||
Description: &wrapperspb.StringValue{Value: "desc"},
|
||||
Type: globals.LdapSubtype.String(),
|
||||
Type: ldap.Subtype.String(),
|
||||
Attrs: defaultAttributes,
|
||||
Scope: defaultScopeInfo,
|
||||
AuthorizedActions: ldapAuthorizedActions,
|
||||
@@ -2626,7 +2626,7 @@ func TestUpdateLdap(t *testing.T) {
|
||||
Item: &pb.Account{
|
||||
AuthMethodId: am.GetPublicId(),
|
||||
Description: &wrapperspb.StringValue{Value: "default"},
|
||||
Type: globals.LdapSubtype.String(),
|
||||
Type: ldap.Subtype.String(),
|
||||
Attrs: defaultAttributes,
|
||||
Scope: defaultScopeInfo,
|
||||
AuthorizedActions: ldapAuthorizedActions,
|
||||
@@ -2649,7 +2649,7 @@ func TestUpdateLdap(t *testing.T) {
|
||||
AuthMethodId: am.GetPublicId(),
|
||||
Name: &wrapperspb.StringValue{Value: "updated"},
|
||||
Description: &wrapperspb.StringValue{Value: "default"},
|
||||
Type: globals.LdapSubtype.String(),
|
||||
Type: ldap.Subtype.String(),
|
||||
Attrs: defaultAttributes,
|
||||
Scope: defaultScopeInfo,
|
||||
AuthorizedActions: ldapAuthorizedActions,
|
||||
@@ -2672,7 +2672,7 @@ func TestUpdateLdap(t *testing.T) {
|
||||
AuthMethodId: am.GetPublicId(),
|
||||
Name: &wrapperspb.StringValue{Value: "default"},
|
||||
Description: &wrapperspb.StringValue{Value: "notignored"},
|
||||
Type: globals.LdapSubtype.String(),
|
||||
Type: ldap.Subtype.String(),
|
||||
Attrs: defaultAttributes,
|
||||
Scope: defaultScopeInfo,
|
||||
AuthorizedActions: ldapAuthorizedActions,
|
||||
|
||||
@@ -10,6 +10,9 @@ import (
|
||||
"testing"
|
||||
|
||||
"github.com/hashicorp/boundary/globals"
|
||||
"github.com/hashicorp/boundary/internal/auth/ldap"
|
||||
"github.com/hashicorp/boundary/internal/auth/oidc"
|
||||
"github.com/hashicorp/boundary/internal/auth/password"
|
||||
pbs "github.com/hashicorp/boundary/internal/gen/controller/api/services"
|
||||
pb "github.com/hashicorp/boundary/sdk/pbs/controller/api/resources/accounts"
|
||||
"github.com/stretchr/testify/assert"
|
||||
@@ -38,7 +41,7 @@ func TestValidateCreateRequest(t *testing.T) {
|
||||
{
|
||||
name: "mismatched pw authmethod oidc type",
|
||||
item: &pb.Account{
|
||||
Type: globals.OidcSubtype.String(),
|
||||
Type: oidc.Subtype.String(),
|
||||
AuthMethodId: globals.PasswordAuthMethodPrefix + "_1234567890",
|
||||
},
|
||||
errContains: fieldError(typeField, "Doesn't match the parent resource's type."),
|
||||
@@ -46,7 +49,7 @@ func TestValidateCreateRequest(t *testing.T) {
|
||||
{
|
||||
name: "mismatched oidc authmethod pw type",
|
||||
item: &pb.Account{
|
||||
Type: globals.PasswordSubtype.String(),
|
||||
Type: password.Subtype.String(),
|
||||
AuthMethodId: globals.OidcAuthMethodPrefix + "_1234567890",
|
||||
},
|
||||
errContains: fieldError(typeField, "Doesn't match the parent resource's type."),
|
||||
@@ -54,7 +57,7 @@ func TestValidateCreateRequest(t *testing.T) {
|
||||
{
|
||||
name: "mismatched pw authmethod ldap type",
|
||||
item: &pb.Account{
|
||||
Type: globals.LdapSubtype.String(),
|
||||
Type: ldap.Subtype.String(),
|
||||
AuthMethodId: globals.PasswordAuthMethodPrefix + "_1234567890",
|
||||
},
|
||||
errContains: fieldError(typeField, "Doesn't match the parent resource's type."),
|
||||
@@ -62,7 +65,7 @@ func TestValidateCreateRequest(t *testing.T) {
|
||||
{
|
||||
name: "missing oidc attributes",
|
||||
item: &pb.Account{
|
||||
Type: globals.OidcSubtype.String(),
|
||||
Type: oidc.Subtype.String(),
|
||||
AuthMethodId: globals.OidcAuthMethodPrefix + "_1234567890",
|
||||
},
|
||||
errContains: fieldError(attributesField, "This is a required field."),
|
||||
@@ -70,7 +73,7 @@ func TestValidateCreateRequest(t *testing.T) {
|
||||
{
|
||||
name: "missing oidc subject",
|
||||
item: &pb.Account{
|
||||
Type: globals.OidcSubtype.String(),
|
||||
Type: oidc.Subtype.String(),
|
||||
AuthMethodId: globals.OidcAuthMethodPrefix + "_1234567890",
|
||||
Attrs: &pb.Account_OidcAccountAttributes{
|
||||
OidcAccountAttributes: &pb.OidcAccountAttributes{},
|
||||
@@ -81,7 +84,7 @@ func TestValidateCreateRequest(t *testing.T) {
|
||||
{
|
||||
name: "read only name claim field",
|
||||
item: &pb.Account{
|
||||
Type: globals.OidcSubtype.String(),
|
||||
Type: oidc.Subtype.String(),
|
||||
AuthMethodId: globals.OidcAuthMethodPrefix + "_1234567890",
|
||||
Attrs: &pb.Account_OidcAccountAttributes{
|
||||
OidcAccountAttributes: &pb.OidcAccountAttributes{FullName: "something"},
|
||||
@@ -92,7 +95,7 @@ func TestValidateCreateRequest(t *testing.T) {
|
||||
{
|
||||
name: "read only email claim field",
|
||||
item: &pb.Account{
|
||||
Type: globals.OidcSubtype.String(),
|
||||
Type: oidc.Subtype.String(),
|
||||
AuthMethodId: globals.OidcAuthMethodPrefix + "_1234567890",
|
||||
Attrs: &pb.Account_OidcAccountAttributes{
|
||||
OidcAccountAttributes: &pb.OidcAccountAttributes{Email: "something"},
|
||||
@@ -103,7 +106,7 @@ func TestValidateCreateRequest(t *testing.T) {
|
||||
{
|
||||
name: "missing ldap attributes",
|
||||
item: &pb.Account{
|
||||
Type: globals.LdapSubtype.String(),
|
||||
Type: ldap.Subtype.String(),
|
||||
AuthMethodId: globals.LdapAuthMethodPrefix + "_1234567890",
|
||||
},
|
||||
errContains: fieldError(attributesField, "This is a required field."),
|
||||
@@ -111,7 +114,7 @@ func TestValidateCreateRequest(t *testing.T) {
|
||||
{
|
||||
name: "missing login name for ldap type",
|
||||
item: &pb.Account{
|
||||
Type: globals.LdapSubtype.String(),
|
||||
Type: ldap.Subtype.String(),
|
||||
AuthMethodId: globals.LdapAuthMethodPrefix + "_1234567890",
|
||||
Attrs: &pb.Account_LdapAccountAttributes{
|
||||
LdapAccountAttributes: &pb.LdapAccountAttributes{},
|
||||
@@ -122,7 +125,7 @@ func TestValidateCreateRequest(t *testing.T) {
|
||||
{
|
||||
name: "read only full name attr field",
|
||||
item: &pb.Account{
|
||||
Type: globals.LdapSubtype.String(),
|
||||
Type: ldap.Subtype.String(),
|
||||
AuthMethodId: globals.LdapAuthMethodPrefix + "_1234567890",
|
||||
Attrs: &pb.Account_LdapAccountAttributes{
|
||||
LdapAccountAttributes: &pb.LdapAccountAttributes{FullName: "something"},
|
||||
@@ -133,7 +136,7 @@ func TestValidateCreateRequest(t *testing.T) {
|
||||
{
|
||||
name: "read only email attr field",
|
||||
item: &pb.Account{
|
||||
Type: globals.LdapSubtype.String(),
|
||||
Type: ldap.Subtype.String(),
|
||||
AuthMethodId: globals.LdapAuthMethodPrefix + "_1234567890",
|
||||
Attrs: &pb.Account_LdapAccountAttributes{
|
||||
LdapAccountAttributes: &pb.LdapAccountAttributes{Email: "something"},
|
||||
@@ -144,7 +147,7 @@ func TestValidateCreateRequest(t *testing.T) {
|
||||
{
|
||||
name: "read only dn attr field",
|
||||
item: &pb.Account{
|
||||
Type: globals.LdapSubtype.String(),
|
||||
Type: ldap.Subtype.String(),
|
||||
AuthMethodId: globals.LdapAuthMethodPrefix + "_1234567890",
|
||||
Attrs: &pb.Account_LdapAccountAttributes{
|
||||
LdapAccountAttributes: &pb.LdapAccountAttributes{Dn: "something"},
|
||||
@@ -155,7 +158,7 @@ func TestValidateCreateRequest(t *testing.T) {
|
||||
{
|
||||
name: "read only member of attr field",
|
||||
item: &pb.Account{
|
||||
Type: globals.LdapSubtype.String(),
|
||||
Type: ldap.Subtype.String(),
|
||||
AuthMethodId: globals.LdapAuthMethodPrefix + "_1234567890",
|
||||
Attrs: &pb.Account_LdapAccountAttributes{
|
||||
LdapAccountAttributes: &pb.LdapAccountAttributes{MemberOfGroups: []string{"something"}},
|
||||
@@ -166,7 +169,7 @@ func TestValidateCreateRequest(t *testing.T) {
|
||||
{
|
||||
name: "missing password attributes",
|
||||
item: &pb.Account{
|
||||
Type: globals.PasswordSubtype.String(),
|
||||
Type: password.Subtype.String(),
|
||||
AuthMethodId: globals.PasswordAuthMethodPrefix + "_1234567890",
|
||||
},
|
||||
errContains: fieldError(attributesField, "This is a required field."),
|
||||
@@ -174,7 +177,7 @@ func TestValidateCreateRequest(t *testing.T) {
|
||||
{
|
||||
name: "missing login name for password type",
|
||||
item: &pb.Account{
|
||||
Type: globals.PasswordSubtype.String(),
|
||||
Type: password.Subtype.String(),
|
||||
AuthMethodId: globals.PasswordAuthMethodPrefix + "_1234567890",
|
||||
Attrs: &pb.Account_PasswordAccountAttributes{
|
||||
PasswordAccountAttributes: &pb.PasswordAccountAttributes{},
|
||||
@@ -185,7 +188,7 @@ func TestValidateCreateRequest(t *testing.T) {
|
||||
{
|
||||
name: "no error",
|
||||
item: &pb.Account{
|
||||
Type: globals.PasswordSubtype.String(),
|
||||
Type: password.Subtype.String(),
|
||||
AuthMethodId: globals.PasswordAuthMethodPrefix + "_1234567890",
|
||||
Attrs: &pb.Account_PasswordAccountAttributes{
|
||||
PasswordAccountAttributes: &pb.PasswordAccountAttributes{
|
||||
@@ -197,7 +200,7 @@ func TestValidateCreateRequest(t *testing.T) {
|
||||
{
|
||||
name: "no oidc errors",
|
||||
item: &pb.Account{
|
||||
Type: globals.OidcSubtype.String(),
|
||||
Type: oidc.Subtype.String(),
|
||||
AuthMethodId: globals.OidcAuthMethodPrefix + "_1234567890",
|
||||
Attrs: &pb.Account_OidcAccountAttributes{
|
||||
OidcAccountAttributes: &pb.OidcAccountAttributes{Subject: "no oidc errors"},
|
||||
@@ -207,7 +210,7 @@ func TestValidateCreateRequest(t *testing.T) {
|
||||
{
|
||||
name: "no ldap errors",
|
||||
item: &pb.Account{
|
||||
Type: globals.LdapSubtype.String(),
|
||||
Type: ldap.Subtype.String(),
|
||||
AuthMethodId: globals.LdapAuthMethodPrefix + "_1234567890",
|
||||
Attrs: &pb.Account_LdapAccountAttributes{
|
||||
LdapAccountAttributes: &pb.LdapAccountAttributes{LoginName: "no oidc errors"},
|
||||
@@ -243,7 +246,7 @@ func TestValidateUpdateRequest(t *testing.T) {
|
||||
req: &pbs.UpdateAccountRequest{
|
||||
Id: globals.PasswordAccountPreviousPrefix + "_1234567890",
|
||||
Item: &pb.Account{
|
||||
Type: globals.OidcSubtype.String(),
|
||||
Type: oidc.Subtype.String(),
|
||||
},
|
||||
},
|
||||
errContains: fieldError(typeField, "Cannot modify the resource type."),
|
||||
@@ -253,7 +256,7 @@ func TestValidateUpdateRequest(t *testing.T) {
|
||||
req: &pbs.UpdateAccountRequest{
|
||||
Id: globals.PasswordAccountPrefix + "_1234567890",
|
||||
Item: &pb.Account{
|
||||
Type: globals.OidcSubtype.String(),
|
||||
Type: oidc.Subtype.String(),
|
||||
},
|
||||
},
|
||||
errContains: fieldError(typeField, "Cannot modify the resource type."),
|
||||
@@ -263,7 +266,7 @@ func TestValidateUpdateRequest(t *testing.T) {
|
||||
req: &pbs.UpdateAccountRequest{
|
||||
Id: globals.OidcAccountPrefix + "_1234567890",
|
||||
Item: &pb.Account{
|
||||
Type: globals.PasswordSubtype.String(),
|
||||
Type: password.Subtype.String(),
|
||||
},
|
||||
},
|
||||
errContains: fieldError(typeField, "Cannot modify the resource type."),
|
||||
|
||||
@@ -64,7 +64,7 @@ const (
|
||||
var (
|
||||
// IdActions contains the set of actions that can be performed on
|
||||
// individual resources
|
||||
IdActions = make(map[globals.Subtype]action.ActionSet)
|
||||
IdActions = make(map[subtypes.Subtype]action.ActionSet)
|
||||
|
||||
// CollectionActions contains the set of actions that can be performed on
|
||||
// this collection
|
||||
@@ -425,15 +425,15 @@ func (s Service) Authenticate(ctx context.Context, req *pbs.AuthenticateRequest)
|
||||
}
|
||||
|
||||
switch subtypes.SubtypeFromId(domain, req.GetAuthMethodId()) {
|
||||
case globals.PasswordSubtype:
|
||||
case password.Subtype:
|
||||
if err := validateAuthenticatePasswordRequest(req); err != nil {
|
||||
return nil, err
|
||||
}
|
||||
case globals.OidcSubtype:
|
||||
case oidc.Subtype:
|
||||
if err := validateAuthenticateOidcRequest(req); err != nil {
|
||||
return nil, err
|
||||
}
|
||||
case globals.LdapSubtype:
|
||||
case ldap.Subtype:
|
||||
if err := validateAuthenticateLdapRequest(req); err != nil {
|
||||
return nil, err
|
||||
}
|
||||
@@ -445,12 +445,12 @@ func (s Service) Authenticate(ctx context.Context, req *pbs.AuthenticateRequest)
|
||||
}
|
||||
|
||||
switch subtypes.SubtypeFromId(domain, req.GetAuthMethodId()) {
|
||||
case globals.PasswordSubtype:
|
||||
case password.Subtype:
|
||||
return s.authenticatePassword(ctx, req, &authResults)
|
||||
|
||||
case globals.OidcSubtype:
|
||||
case oidc.Subtype:
|
||||
return s.authenticateOidc(ctx, req, &authResults)
|
||||
case globals.LdapSubtype:
|
||||
case ldap.Subtype:
|
||||
return s.authenticateLdap(ctx, req, &authResults)
|
||||
}
|
||||
return nil, errors.New(ctx, errors.Internal, op, "Invalid auth method subtype not caught in validation function.")
|
||||
@@ -460,21 +460,21 @@ func (s Service) getFromRepo(ctx context.Context, id string) (auth.AuthMethod, e
|
||||
var lookupErr error
|
||||
var am auth.AuthMethod
|
||||
switch subtypes.SubtypeFromId(domain, id) {
|
||||
case globals.PasswordSubtype:
|
||||
case password.Subtype:
|
||||
repo, err := s.pwRepoFn()
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
am, lookupErr = repo.LookupAuthMethod(ctx, id)
|
||||
|
||||
case globals.OidcSubtype:
|
||||
case oidc.Subtype:
|
||||
repo, err := s.oidcRepoFn()
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
am, lookupErr = repo.LookupAuthMethod(ctx, id)
|
||||
|
||||
case globals.LdapSubtype:
|
||||
case ldap.Subtype:
|
||||
repo, err := s.ldapRepoFn()
|
||||
if err != nil {
|
||||
return nil, err
|
||||
@@ -550,7 +550,7 @@ func (s Service) createInRepo(ctx context.Context, scopeId string, item *pb.Auth
|
||||
const op = "authmethods.(Service).createInRepo"
|
||||
var out auth.AuthMethod
|
||||
switch subtypes.SubtypeFromType(domain, item.GetType()) {
|
||||
case globals.PasswordSubtype:
|
||||
case password.Subtype:
|
||||
am, err := s.createPwInRepo(ctx, scopeId, item)
|
||||
if err != nil {
|
||||
return nil, errors.Wrap(ctx, err, op)
|
||||
@@ -559,7 +559,7 @@ func (s Service) createInRepo(ctx context.Context, scopeId string, item *pb.Auth
|
||||
return nil, handlers.ApiErrorWithCodeAndMessage(codes.Internal, "Unable to create auth method but no error returned from repository.")
|
||||
}
|
||||
out = am
|
||||
case globals.OidcSubtype:
|
||||
case oidc.Subtype:
|
||||
am, err := s.createOidcInRepo(ctx, scopeId, item)
|
||||
if err != nil {
|
||||
return nil, errors.Wrap(ctx, err, op)
|
||||
@@ -568,7 +568,7 @@ func (s Service) createInRepo(ctx context.Context, scopeId string, item *pb.Auth
|
||||
return nil, handlers.ApiErrorWithCodeAndMessage(codes.Internal, "Unable to create auth method but no error returned from repository.")
|
||||
}
|
||||
out = am
|
||||
case globals.LdapSubtype:
|
||||
case ldap.Subtype:
|
||||
am, err := s.createLdapInRepo(ctx, scopeId, item)
|
||||
if err != nil {
|
||||
return nil, errors.Wrap(ctx, err, op)
|
||||
@@ -588,7 +588,7 @@ func (s Service) updateInRepo(ctx context.Context, scopeId string, req *pbs.Upda
|
||||
var dryRun bool
|
||||
|
||||
switch subtypes.SubtypeFromId(domain, req.GetId()) {
|
||||
case globals.PasswordSubtype:
|
||||
case password.Subtype:
|
||||
pam, err := s.updatePwInRepo(ctx, scopeId, req.GetId(), req.GetUpdateMask().GetPaths(), req.GetItem())
|
||||
if err != nil {
|
||||
return nil, false, errors.Wrap(ctx, err, op)
|
||||
@@ -598,7 +598,7 @@ func (s Service) updateInRepo(ctx context.Context, scopeId string, req *pbs.Upda
|
||||
}
|
||||
am = pam
|
||||
|
||||
case globals.OidcSubtype:
|
||||
case oidc.Subtype:
|
||||
oam, dr, err := s.updateOidcInRepo(ctx, scopeId, req)
|
||||
if err != nil {
|
||||
return nil, false, errors.Wrap(ctx, err, op)
|
||||
@@ -609,7 +609,7 @@ func (s Service) updateInRepo(ctx context.Context, scopeId string, req *pbs.Upda
|
||||
am = oam
|
||||
dryRun = dr
|
||||
|
||||
case globals.LdapSubtype:
|
||||
case ldap.Subtype:
|
||||
lam, err := s.updateLdapInRepo(ctx, scopeId, req.GetId(), req.GetUpdateMask().GetPaths(), req.GetItem())
|
||||
if err != nil {
|
||||
_, apiErr := err.(*handlers.ApiError)
|
||||
@@ -636,20 +636,20 @@ func (s Service) deleteFromRepo(ctx context.Context, scopeId, id string) (bool,
|
||||
var rows int
|
||||
var dErr error
|
||||
switch subtypes.SubtypeFromId(domain, id) {
|
||||
case globals.PasswordSubtype:
|
||||
case password.Subtype:
|
||||
repo, err := s.pwRepoFn()
|
||||
if err != nil {
|
||||
return false, errors.Wrap(ctx, err, op)
|
||||
}
|
||||
rows, dErr = repo.DeleteAuthMethod(ctx, scopeId, id)
|
||||
|
||||
case globals.OidcSubtype:
|
||||
case oidc.Subtype:
|
||||
repo, err := s.oidcRepoFn()
|
||||
if err != nil {
|
||||
return false, errors.Wrap(ctx, err, op)
|
||||
}
|
||||
rows, dErr = repo.DeleteAuthMethod(ctx, id)
|
||||
case globals.LdapSubtype:
|
||||
case ldap.Subtype:
|
||||
repo, err := s.ldapRepoFn()
|
||||
if err != nil {
|
||||
return false, errors.Wrap(ctx, err, op)
|
||||
@@ -673,7 +673,7 @@ func (s Service) changeStateInRepo(ctx context.Context, req *pbs.ChangeStateRequ
|
||||
const op = "authmethod_service.(Service).changeStateInRepo"
|
||||
|
||||
switch subtypes.SubtypeFromId(domain, req.GetId()) {
|
||||
case globals.OidcSubtype:
|
||||
case oidc.Subtype:
|
||||
repo, err := s.oidcRepoFn()
|
||||
if err != nil {
|
||||
return nil, err
|
||||
@@ -732,7 +732,7 @@ func (s Service) authResult(ctx context.Context, id string, a action.Type) reque
|
||||
default:
|
||||
var authMeth auth.AuthMethod
|
||||
switch subtypes.SubtypeFromId(domain, id) {
|
||||
case globals.PasswordSubtype:
|
||||
case password.Subtype:
|
||||
repo, err := s.pwRepoFn()
|
||||
if err != nil {
|
||||
res.Error = err
|
||||
@@ -748,7 +748,7 @@ func (s Service) authResult(ctx context.Context, id string, a action.Type) reque
|
||||
return res
|
||||
}
|
||||
authMeth = am
|
||||
case globals.OidcSubtype:
|
||||
case oidc.Subtype:
|
||||
repo, err := s.oidcRepoFn()
|
||||
if err != nil {
|
||||
res.Error = err
|
||||
@@ -764,7 +764,7 @@ func (s Service) authResult(ctx context.Context, id string, a action.Type) reque
|
||||
return res
|
||||
}
|
||||
authMeth = am
|
||||
case globals.LdapSubtype:
|
||||
case ldap.Subtype:
|
||||
repo, err := s.ldapRepoFn()
|
||||
if err != nil {
|
||||
res.Error = err
|
||||
@@ -835,7 +835,7 @@ func toAuthMethodProto(ctx context.Context, in auth.AuthMethod, opt ...handlers.
|
||||
switch i := in.(type) {
|
||||
case *password.AuthMethod:
|
||||
if outputFields.Has(globals.TypeField) {
|
||||
out.Type = globals.PasswordSubtype.String()
|
||||
out.Type = password.Subtype.String()
|
||||
}
|
||||
if !outputFields.Has(globals.AttributesField) {
|
||||
break
|
||||
@@ -848,7 +848,7 @@ func toAuthMethodProto(ctx context.Context, in auth.AuthMethod, opt ...handlers.
|
||||
}
|
||||
case *oidc.AuthMethod:
|
||||
if outputFields.Has(globals.TypeField) {
|
||||
out.Type = globals.OidcSubtype.String()
|
||||
out.Type = oidc.Subtype.String()
|
||||
}
|
||||
if !outputFields.Has(globals.AttributesField) {
|
||||
break
|
||||
@@ -886,7 +886,7 @@ func toAuthMethodProto(ctx context.Context, in auth.AuthMethod, opt ...handlers.
|
||||
}
|
||||
case *ldap.AuthMethod:
|
||||
if outputFields.Has(globals.TypeField) {
|
||||
out.Type = globals.LdapSubtype.String()
|
||||
out.Type = ldap.Subtype.String()
|
||||
}
|
||||
if !outputFields.Has(globals.AttributesField) {
|
||||
break
|
||||
@@ -988,9 +988,9 @@ func validateCreateRequest(ctx context.Context, req *pbs.CreateAuthMethodRequest
|
||||
badFields[isPrimaryField] = "This field is read only."
|
||||
}
|
||||
switch subtypes.SubtypeFromType(domain, req.GetItem().GetType()) {
|
||||
case globals.PasswordSubtype:
|
||||
case password.Subtype:
|
||||
// Password attributes are not required when creating a password auth method.
|
||||
case globals.OidcSubtype:
|
||||
case oidc.Subtype:
|
||||
attrs := req.GetItem().GetOidcAuthMethodsAttributes()
|
||||
if attrs == nil {
|
||||
// OIDC attributes are required when creating an OIDC auth method.
|
||||
@@ -1066,13 +1066,13 @@ func validateCreateRequest(ctx context.Context, req *pbs.CreateAuthMethodRequest
|
||||
}
|
||||
}
|
||||
}
|
||||
case globals.LdapSubtype:
|
||||
case ldap.Subtype:
|
||||
if len(req.GetItem().GetLdapAuthMethodsAttributes().GetUrls()) == 0 {
|
||||
badFields[urlsField] = "At least one URL is required"
|
||||
}
|
||||
validateLdapAttributes(ctx, req.GetItem().GetLdapAuthMethodsAttributes(), badFields)
|
||||
default:
|
||||
badFields[typeField] = fmt.Sprintf("This is a required field and must be %q.", globals.PasswordSubtype.String())
|
||||
badFields[typeField] = fmt.Sprintf("This is a required field and must be %q.", password.Subtype.String())
|
||||
}
|
||||
return badFields
|
||||
})
|
||||
@@ -1089,12 +1089,12 @@ func validateUpdateRequest(ctx context.Context, req *pbs.UpdateAuthMethodRequest
|
||||
badFields[isPrimaryField] = "This field is read only."
|
||||
}
|
||||
switch subtypes.SubtypeFromId(domain, req.GetId()) {
|
||||
case globals.PasswordSubtype:
|
||||
if req.GetItem().GetType() != "" && subtypes.SubtypeFromType(domain, req.GetItem().GetType()) != globals.PasswordSubtype {
|
||||
case password.Subtype:
|
||||
if req.GetItem().GetType() != "" && subtypes.SubtypeFromType(domain, req.GetItem().GetType()) != password.Subtype {
|
||||
badFields[typeField] = "Cannot modify the resource type."
|
||||
}
|
||||
case globals.OidcSubtype:
|
||||
if req.GetItem().GetType() != "" && subtypes.SubtypeFromType(domain, req.GetItem().GetType()) != globals.OidcSubtype {
|
||||
case oidc.Subtype:
|
||||
if req.GetItem().GetType() != "" && subtypes.SubtypeFromType(domain, req.GetItem().GetType()) != oidc.Subtype {
|
||||
badFields[typeField] = "Cannot modify the resource type."
|
||||
}
|
||||
attrs := req.GetItem().GetOidcAuthMethodsAttributes()
|
||||
@@ -1197,8 +1197,8 @@ func validateUpdateRequest(ctx context.Context, req *pbs.UpdateAuthMethodRequest
|
||||
}
|
||||
}
|
||||
}
|
||||
case globals.LdapSubtype:
|
||||
if req.GetItem().GetType() != "" && subtypes.SubtypeFromType(domain, req.GetItem().GetType()) != globals.LdapSubtype {
|
||||
case ldap.Subtype:
|
||||
if req.GetItem().GetType() != "" && subtypes.SubtypeFromType(domain, req.GetItem().GetType()) != ldap.Subtype {
|
||||
badFields[typeField] = "Cannot modify the resource type."
|
||||
}
|
||||
validateLdapAttributes(ctx, req.GetItem().GetLdapAuthMethodsAttributes(), badFields)
|
||||
@@ -1241,8 +1241,8 @@ func validateChangeStateRequest(ctx context.Context, req *pbs.ChangeStateRequest
|
||||
if req == nil {
|
||||
return errors.New(ctx, errors.InvalidParameter, op, "Missing request")
|
||||
}
|
||||
if st := subtypes.SubtypeFromId(domain, req.GetId()); st != globals.OidcSubtype {
|
||||
return handlers.NotFoundErrorf("This endpoint is only available for the %q Auth Method type.", globals.OidcSubtype.String())
|
||||
if st := subtypes.SubtypeFromId(domain, req.GetId()); st != oidc.Subtype {
|
||||
return handlers.NotFoundErrorf("This endpoint is only available for the %q Auth Method type.", oidc.Subtype.String())
|
||||
}
|
||||
badFields := make(map[string]string)
|
||||
if req.GetVersion() == 0 {
|
||||
@@ -1278,7 +1278,7 @@ func validateAuthenticateRequest(ctx context.Context, req *pbs.AuthenticateReque
|
||||
} else {
|
||||
st := subtypes.SubtypeFromId(domain, req.GetAuthMethodId())
|
||||
switch st {
|
||||
case globals.PasswordSubtype, globals.OidcSubtype, globals.LdapSubtype:
|
||||
case password.Subtype, oidc.Subtype, ldap.Subtype:
|
||||
default:
|
||||
badFields[authMethodIdField] = "Unknown auth method type."
|
||||
}
|
||||
@@ -1381,7 +1381,7 @@ func transformAuthenticateRequestAttributes(msg proto.Message) error {
|
||||
return nil
|
||||
}
|
||||
switch subtypes.SubtypeFromId(domain, authRequest.GetAuthMethodId()) {
|
||||
case globals.PasswordSubtype:
|
||||
case password.Subtype:
|
||||
newAttrs := &pbs.PasswordLoginAttributes{}
|
||||
if err := handlers.StructToProto(attrs, newAttrs); err != nil {
|
||||
return err
|
||||
@@ -1389,7 +1389,7 @@ func transformAuthenticateRequestAttributes(msg proto.Message) error {
|
||||
authRequest.Attrs = &pbs.AuthenticateRequest_PasswordLoginAttributes{
|
||||
PasswordLoginAttributes: newAttrs,
|
||||
}
|
||||
case globals.OidcSubtype:
|
||||
case oidc.Subtype:
|
||||
switch authRequest.GetCommand() {
|
||||
case startCommand:
|
||||
newAttrs := &pbs.OidcStartAttributes{}
|
||||
@@ -1418,7 +1418,7 @@ func transformAuthenticateRequestAttributes(msg proto.Message) error {
|
||||
default:
|
||||
return fmt.Errorf("%s: unknown command %q", op, authRequest.GetCommand())
|
||||
}
|
||||
case globals.LdapSubtype:
|
||||
case ldap.Subtype:
|
||||
newAttrs := &pbs.LdapLoginAttributes{}
|
||||
if err := handlers.StructToProto(attrs, newAttrs); err != nil {
|
||||
return err
|
||||
|
||||
@@ -150,7 +150,7 @@ func TestGet(t *testing.T) {
|
||||
ScopeId: oidcam.GetScopeId(),
|
||||
CreatedTime: oidcam.CreateTime.GetTimestamp(),
|
||||
UpdatedTime: oidcam.UpdateTime.GetTimestamp(),
|
||||
Type: globals.OidcSubtype.String(),
|
||||
Type: oidc.Subtype.String(),
|
||||
Attrs: &pb.AuthMethod_OidcAuthMethodsAttributes{
|
||||
OidcAuthMethodsAttributes: &pb.OidcAuthMethodAttributes{
|
||||
Issuer: wrapperspb.String("https://alice.com"),
|
||||
@@ -183,7 +183,7 @@ func TestGet(t *testing.T) {
|
||||
ScopeId: ldapAm.GetScopeId(),
|
||||
CreatedTime: ldapAm.CreateTime.GetTimestamp(),
|
||||
UpdatedTime: ldapAm.UpdateTime.GetTimestamp(),
|
||||
Type: globals.LdapSubtype.String(),
|
||||
Type: ldap.Subtype.String(),
|
||||
Attrs: &pb.AuthMethod_LdapAuthMethodsAttributes{
|
||||
LdapAuthMethodsAttributes: &pb.LdapAuthMethodAttributes{
|
||||
State: string(ldap.InactiveState),
|
||||
@@ -313,7 +313,7 @@ func TestList(t *testing.T) {
|
||||
UpdatedTime: oidcam.GetUpdateTime().GetTimestamp(),
|
||||
Scope: &scopepb.ScopeInfo{Id: oWithAuthMethods.GetPublicId(), Type: scope.Org.String(), ParentScopeId: scope.Global.String()},
|
||||
Version: 2,
|
||||
Type: globals.OidcSubtype.String(),
|
||||
Type: oidc.Subtype.String(),
|
||||
Attrs: &pb.AuthMethod_OidcAuthMethodsAttributes{
|
||||
OidcAuthMethodsAttributes: &pb.OidcAuthMethodAttributes{
|
||||
Issuer: wrapperspb.String("https://alice.com"),
|
||||
@@ -376,7 +376,7 @@ func TestList(t *testing.T) {
|
||||
UpdatedTime: ldapAm.GetUpdateTime().GetTimestamp(),
|
||||
Scope: &scopepb.ScopeInfo{Id: oWithAuthMethods.GetPublicId(), Type: scope.Org.String(), ParentScopeId: scope.Global.String()},
|
||||
Version: 1,
|
||||
Type: globals.LdapSubtype.String(),
|
||||
Type: ldap.Subtype.String(),
|
||||
Attrs: &pb.AuthMethod_LdapAuthMethodsAttributes{
|
||||
LdapAuthMethodsAttributes: &pb.LdapAuthMethodAttributes{
|
||||
State: string(ldap.ActivePublicState),
|
||||
@@ -713,7 +713,7 @@ func TestCreate(t *testing.T) {
|
||||
name: "Create a valid OIDC AuthMethod",
|
||||
req: &pbs.CreateAuthMethodRequest{Item: &pb.AuthMethod{
|
||||
ScopeId: o.GetPublicId(),
|
||||
Type: globals.OidcSubtype.String(),
|
||||
Type: oidc.Subtype.String(),
|
||||
Attrs: &pb.AuthMethod_OidcAuthMethodsAttributes{
|
||||
OidcAuthMethodsAttributes: &pb.OidcAuthMethodAttributes{
|
||||
Issuer: wrapperspb.String("https://example.discovery.url:4821/.well-known/openid-configuration/"),
|
||||
@@ -736,7 +736,7 @@ func TestCreate(t *testing.T) {
|
||||
UpdatedTime: defaultAm.GetUpdateTime().GetTimestamp(),
|
||||
Scope: &scopepb.ScopeInfo{Id: o.GetPublicId(), Type: o.GetType(), ParentScopeId: scope.Global.String()},
|
||||
Version: 1,
|
||||
Type: globals.OidcSubtype.String(),
|
||||
Type: oidc.Subtype.String(),
|
||||
Attrs: &pb.AuthMethod_OidcAuthMethodsAttributes{
|
||||
OidcAuthMethodsAttributes: &pb.OidcAuthMethodAttributes{
|
||||
Issuer: wrapperspb.String("https://example.discovery.url:4821/"),
|
||||
@@ -759,7 +759,7 @@ func TestCreate(t *testing.T) {
|
||||
name: "create-a-valid-ldap-auth-method",
|
||||
req: &pbs.CreateAuthMethodRequest{Item: &pb.AuthMethod{
|
||||
ScopeId: o.GetPublicId(),
|
||||
Type: globals.LdapSubtype.String(),
|
||||
Type: ldap.Subtype.String(),
|
||||
Attrs: &pb.AuthMethod_LdapAuthMethodsAttributes{
|
||||
LdapAuthMethodsAttributes: &pb.LdapAuthMethodAttributes{
|
||||
StartTls: true,
|
||||
@@ -796,7 +796,7 @@ func TestCreate(t *testing.T) {
|
||||
UpdatedTime: defaultAm.GetUpdateTime().GetTimestamp(),
|
||||
Scope: &scopepb.ScopeInfo{Id: o.GetPublicId(), Type: o.GetType(), ParentScopeId: scope.Global.String()},
|
||||
Version: 1,
|
||||
Type: globals.LdapSubtype.String(),
|
||||
Type: ldap.Subtype.String(),
|
||||
Attrs: &pb.AuthMethod_LdapAuthMethodsAttributes{
|
||||
LdapAuthMethodsAttributes: &pb.LdapAuthMethodAttributes{
|
||||
State: string(ldap.InactiveState),
|
||||
@@ -863,7 +863,7 @@ func TestCreate(t *testing.T) {
|
||||
name: "Create a global OIDC AuthMethod",
|
||||
req: &pbs.CreateAuthMethodRequest{Item: &pb.AuthMethod{
|
||||
ScopeId: scope.Global.String(),
|
||||
Type: globals.OidcSubtype.String(),
|
||||
Type: oidc.Subtype.String(),
|
||||
Attrs: &pb.AuthMethod_OidcAuthMethodsAttributes{
|
||||
OidcAuthMethodsAttributes: &pb.OidcAuthMethodAttributes{
|
||||
Issuer: wrapperspb.String("https://example.discovery.url"),
|
||||
@@ -883,7 +883,7 @@ func TestCreate(t *testing.T) {
|
||||
UpdatedTime: defaultAm.GetUpdateTime().GetTimestamp(),
|
||||
Scope: &scopepb.ScopeInfo{Id: scope.Global.String(), Type: scope.Global.String(), Name: scope.Global.String(), Description: "Global Scope"},
|
||||
Version: 1,
|
||||
Type: globals.OidcSubtype.String(),
|
||||
Type: oidc.Subtype.String(),
|
||||
Attrs: &pb.AuthMethod_OidcAuthMethodsAttributes{
|
||||
OidcAuthMethodsAttributes: &pb.OidcAuthMethodAttributes{
|
||||
ApiUrlPrefix: wrapperspb.String("https://api.com"),
|
||||
@@ -902,7 +902,7 @@ func TestCreate(t *testing.T) {
|
||||
name: "create-a-global-ldap-auth-method",
|
||||
req: &pbs.CreateAuthMethodRequest{Item: &pb.AuthMethod{
|
||||
ScopeId: scope.Global.String(),
|
||||
Type: globals.LdapSubtype.String(),
|
||||
Type: ldap.Subtype.String(),
|
||||
Attrs: &pb.AuthMethod_LdapAuthMethodsAttributes{
|
||||
LdapAuthMethodsAttributes: &pb.LdapAuthMethodAttributes{
|
||||
Urls: []string{"ldap://ldap1", "ldaps://ldap1"},
|
||||
@@ -920,7 +920,7 @@ func TestCreate(t *testing.T) {
|
||||
UpdatedTime: defaultAm.GetUpdateTime().GetTimestamp(),
|
||||
Scope: &scopepb.ScopeInfo{Id: scope.Global.String(), Type: scope.Global.String(), Name: scope.Global.String(), Description: "Global Scope"},
|
||||
Version: 1,
|
||||
Type: globals.LdapSubtype.String(),
|
||||
Type: ldap.Subtype.String(),
|
||||
Attrs: &pb.AuthMethod_LdapAuthMethodsAttributes{
|
||||
LdapAuthMethodsAttributes: &pb.LdapAuthMethodAttributes{
|
||||
State: string(ldap.InactiveState),
|
||||
@@ -949,7 +949,7 @@ func TestCreate(t *testing.T) {
|
||||
req: &pbs.CreateAuthMethodRequest{Item: &pb.AuthMethod{
|
||||
ScopeId: o.GetPublicId(),
|
||||
CreatedTime: timestamppb.Now(),
|
||||
Type: globals.PasswordSubtype.String(),
|
||||
Type: password.Subtype.String(),
|
||||
}},
|
||||
res: nil,
|
||||
err: handlers.ApiErrorWithCode(codes.InvalidArgument),
|
||||
@@ -959,7 +959,7 @@ func TestCreate(t *testing.T) {
|
||||
req: &pbs.CreateAuthMethodRequest{Item: &pb.AuthMethod{
|
||||
ScopeId: o.GetPublicId(),
|
||||
UpdatedTime: timestamppb.Now(),
|
||||
Type: globals.PasswordSubtype.String(),
|
||||
Type: password.Subtype.String(),
|
||||
}},
|
||||
res: nil,
|
||||
err: handlers.ApiErrorWithCode(codes.InvalidArgument),
|
||||
@@ -968,7 +968,7 @@ func TestCreate(t *testing.T) {
|
||||
name: "Can't specify IsPrimary",
|
||||
req: &pbs.CreateAuthMethodRequest{Item: &pb.AuthMethod{
|
||||
ScopeId: o.GetPublicId(),
|
||||
Type: globals.PasswordSubtype.String(),
|
||||
Type: password.Subtype.String(),
|
||||
IsPrimary: true,
|
||||
}},
|
||||
res: nil,
|
||||
@@ -979,7 +979,7 @@ func TestCreate(t *testing.T) {
|
||||
req: &pbs.CreateAuthMethodRequest{Item: &pb.AuthMethod{
|
||||
ScopeId: o.GetPublicId(),
|
||||
UpdatedTime: timestamppb.Now(),
|
||||
Type: globals.PasswordSubtype.String(),
|
||||
Type: password.Subtype.String(),
|
||||
}},
|
||||
res: nil,
|
||||
err: handlers.ApiErrorWithCode(codes.InvalidArgument),
|
||||
@@ -998,7 +998,7 @@ func TestCreate(t *testing.T) {
|
||||
name: "OIDC AuthMethod Doesn't Require Issuer",
|
||||
req: &pbs.CreateAuthMethodRequest{Item: &pb.AuthMethod{
|
||||
ScopeId: o.GetPublicId(),
|
||||
Type: globals.OidcSubtype.String(),
|
||||
Type: oidc.Subtype.String(),
|
||||
Attrs: &pb.AuthMethod_OidcAuthMethodsAttributes{
|
||||
OidcAuthMethodsAttributes: &pb.OidcAuthMethodAttributes{
|
||||
ApiUrlPrefix: wrapperspb.String("https://api.com"),
|
||||
@@ -1016,7 +1016,7 @@ func TestCreate(t *testing.T) {
|
||||
UpdatedTime: defaultAm.GetUpdateTime().GetTimestamp(),
|
||||
Scope: &scopepb.ScopeInfo{Id: o.GetPublicId(), Type: o.GetType(), ParentScopeId: scope.Global.String()},
|
||||
Version: 1,
|
||||
Type: globals.OidcSubtype.String(),
|
||||
Type: oidc.Subtype.String(),
|
||||
Attrs: &pb.AuthMethod_OidcAuthMethodsAttributes{
|
||||
OidcAuthMethodsAttributes: &pb.OidcAuthMethodAttributes{
|
||||
ApiUrlPrefix: wrapperspb.String("https://api.com"),
|
||||
@@ -1034,7 +1034,7 @@ func TestCreate(t *testing.T) {
|
||||
name: "OIDC AuthMethod Requires ApiUrl",
|
||||
req: &pbs.CreateAuthMethodRequest{Item: &pb.AuthMethod{
|
||||
ScopeId: o.GetPublicId(),
|
||||
Type: globals.OidcSubtype.String(),
|
||||
Type: oidc.Subtype.String(),
|
||||
Attrs: &pb.AuthMethod_OidcAuthMethodsAttributes{
|
||||
OidcAuthMethodsAttributes: &pb.OidcAuthMethodAttributes{
|
||||
ClientId: wrapperspb.String("someclientid"),
|
||||
@@ -1048,7 +1048,7 @@ func TestCreate(t *testing.T) {
|
||||
name: "OIDC AuthMethod Requires Client Id",
|
||||
req: &pbs.CreateAuthMethodRequest{Item: &pb.AuthMethod{
|
||||
ScopeId: o.GetPublicId(),
|
||||
Type: globals.OidcSubtype.String(),
|
||||
Type: oidc.Subtype.String(),
|
||||
Attrs: &pb.AuthMethod_OidcAuthMethodsAttributes{
|
||||
OidcAuthMethodsAttributes: &pb.OidcAuthMethodAttributes{
|
||||
ApiUrlPrefix: wrapperspb.String("https://api.com"),
|
||||
@@ -1063,7 +1063,7 @@ func TestCreate(t *testing.T) {
|
||||
name: "OIDC AuthMethod Requires Client Secret",
|
||||
req: &pbs.CreateAuthMethodRequest{Item: &pb.AuthMethod{
|
||||
ScopeId: o.GetPublicId(),
|
||||
Type: globals.OidcSubtype.String(),
|
||||
Type: oidc.Subtype.String(),
|
||||
Attrs: &pb.AuthMethod_OidcAuthMethodsAttributes{
|
||||
OidcAuthMethodsAttributes: &pb.OidcAuthMethodAttributes{
|
||||
ApiUrlPrefix: wrapperspb.String("https://api.com"),
|
||||
@@ -1078,7 +1078,7 @@ func TestCreate(t *testing.T) {
|
||||
name: "OIDC AuthMethod cant specify client secret hmac",
|
||||
req: &pbs.CreateAuthMethodRequest{Item: &pb.AuthMethod{
|
||||
ScopeId: o.GetPublicId(),
|
||||
Type: globals.OidcSubtype.String(),
|
||||
Type: oidc.Subtype.String(),
|
||||
Attrs: &pb.AuthMethod_OidcAuthMethodsAttributes{
|
||||
OidcAuthMethodsAttributes: &pb.OidcAuthMethodAttributes{
|
||||
ApiUrlPrefix: wrapperspb.String("https://api.com"),
|
||||
@@ -1095,7 +1095,7 @@ func TestCreate(t *testing.T) {
|
||||
name: "OIDC AuthMethod cant specify state",
|
||||
req: &pbs.CreateAuthMethodRequest{Item: &pb.AuthMethod{
|
||||
ScopeId: o.GetPublicId(),
|
||||
Type: globals.OidcSubtype.String(),
|
||||
Type: oidc.Subtype.String(),
|
||||
Attrs: &pb.AuthMethod_OidcAuthMethodsAttributes{
|
||||
OidcAuthMethodsAttributes: &pb.OidcAuthMethodAttributes{
|
||||
ApiUrlPrefix: wrapperspb.String("https://api.com"),
|
||||
@@ -1112,7 +1112,7 @@ func TestCreate(t *testing.T) {
|
||||
name: "OIDC AuthMethod Must Match Standard Alg Names",
|
||||
req: &pbs.CreateAuthMethodRequest{Item: &pb.AuthMethod{
|
||||
ScopeId: o.GetPublicId(),
|
||||
Type: globals.OidcSubtype.String(),
|
||||
Type: oidc.Subtype.String(),
|
||||
Attrs: &pb.AuthMethod_OidcAuthMethodsAttributes{
|
||||
OidcAuthMethodsAttributes: &pb.OidcAuthMethodAttributes{
|
||||
ApiUrlPrefix: wrapperspb.String("https://api.com"),
|
||||
@@ -1129,7 +1129,7 @@ func TestCreate(t *testing.T) {
|
||||
name: "OIDC AuthMethod API Urls Prefix Format",
|
||||
req: &pbs.CreateAuthMethodRequest{Item: &pb.AuthMethod{
|
||||
ScopeId: o.GetPublicId(),
|
||||
Type: globals.OidcSubtype.String(),
|
||||
Type: oidc.Subtype.String(),
|
||||
Attrs: &pb.AuthMethod_OidcAuthMethodsAttributes{
|
||||
OidcAuthMethodsAttributes: &pb.OidcAuthMethodAttributes{
|
||||
Issuer: wrapperspb.String("https://example2.discovery.url:4821"),
|
||||
@@ -1145,7 +1145,7 @@ func TestCreate(t *testing.T) {
|
||||
name: "OIDC AuthMethod Callback Url Read Only",
|
||||
req: &pbs.CreateAuthMethodRequest{Item: &pb.AuthMethod{
|
||||
ScopeId: o.GetPublicId(),
|
||||
Type: globals.OidcSubtype.String(),
|
||||
Type: oidc.Subtype.String(),
|
||||
Attrs: &pb.AuthMethod_OidcAuthMethodsAttributes{
|
||||
OidcAuthMethodsAttributes: &pb.OidcAuthMethodAttributes{
|
||||
Issuer: wrapperspb.String("https://example2.discovery.url:4821"),
|
||||
@@ -1161,7 +1161,7 @@ func TestCreate(t *testing.T) {
|
||||
name: "OIDC AuthMethod unparseable certificates",
|
||||
req: &pbs.CreateAuthMethodRequest{Item: &pb.AuthMethod{
|
||||
ScopeId: o.GetPublicId(),
|
||||
Type: globals.OidcSubtype.String(),
|
||||
Type: oidc.Subtype.String(),
|
||||
Attrs: &pb.AuthMethod_OidcAuthMethodsAttributes{
|
||||
OidcAuthMethodsAttributes: &pb.OidcAuthMethodAttributes{
|
||||
ApiUrlPrefix: wrapperspb.String("https://api.com"),
|
||||
@@ -1178,7 +1178,7 @@ func TestCreate(t *testing.T) {
|
||||
name: "OIDC AuthMethod cant specify default claims scopes of openid",
|
||||
req: &pbs.CreateAuthMethodRequest{Item: &pb.AuthMethod{
|
||||
ScopeId: o.GetPublicId(),
|
||||
Type: globals.OidcSubtype.String(),
|
||||
Type: oidc.Subtype.String(),
|
||||
Attrs: &pb.AuthMethod_OidcAuthMethodsAttributes{
|
||||
OidcAuthMethodsAttributes: &pb.OidcAuthMethodAttributes{
|
||||
ApiUrlPrefix: wrapperspb.String("https://api.com"),
|
||||
@@ -1195,7 +1195,7 @@ func TestCreate(t *testing.T) {
|
||||
name: "ldap-auth-method-requires-urls",
|
||||
req: &pbs.CreateAuthMethodRequest{Item: &pb.AuthMethod{
|
||||
ScopeId: o.GetPublicId(),
|
||||
Type: globals.LdapSubtype.String(),
|
||||
Type: ldap.Subtype.String(),
|
||||
Attrs: &pb.AuthMethod_LdapAuthMethodsAttributes{
|
||||
LdapAuthMethodsAttributes: &pb.LdapAuthMethodAttributes{},
|
||||
},
|
||||
@@ -1207,7 +1207,7 @@ func TestCreate(t *testing.T) {
|
||||
name: "ldap-auth-method-invalid-urls",
|
||||
req: &pbs.CreateAuthMethodRequest{Item: &pb.AuthMethod{
|
||||
ScopeId: o.GetPublicId(),
|
||||
Type: globals.LdapSubtype.String(),
|
||||
Type: ldap.Subtype.String(),
|
||||
Attrs: &pb.AuthMethod_LdapAuthMethodsAttributes{
|
||||
LdapAuthMethodsAttributes: &pb.LdapAuthMethodAttributes{
|
||||
Urls: []string{"ldap://ldap1", "not-ldap-scheme://ldap2"},
|
||||
@@ -1221,7 +1221,7 @@ func TestCreate(t *testing.T) {
|
||||
name: "ldap-auth-method-invalid-deref-aliases",
|
||||
req: &pbs.CreateAuthMethodRequest{Item: &pb.AuthMethod{
|
||||
ScopeId: o.GetPublicId(),
|
||||
Type: globals.LdapSubtype.String(),
|
||||
Type: ldap.Subtype.String(),
|
||||
Attrs: &pb.AuthMethod_LdapAuthMethodsAttributes{
|
||||
LdapAuthMethodsAttributes: &pb.LdapAuthMethodAttributes{
|
||||
Urls: []string{"ldap://ldap1"},
|
||||
@@ -1236,7 +1236,7 @@ func TestCreate(t *testing.T) {
|
||||
name: "ldap-auth-method-invalid-cert",
|
||||
req: &pbs.CreateAuthMethodRequest{Item: &pb.AuthMethod{
|
||||
ScopeId: o.GetPublicId(),
|
||||
Type: globals.LdapSubtype.String(),
|
||||
Type: ldap.Subtype.String(),
|
||||
Attrs: &pb.AuthMethod_LdapAuthMethodsAttributes{
|
||||
LdapAuthMethodsAttributes: &pb.LdapAuthMethodAttributes{
|
||||
Urls: []string{"ldap://ldap1"},
|
||||
@@ -1251,7 +1251,7 @@ func TestCreate(t *testing.T) {
|
||||
name: "ldap-auth-method-missing-bind-dn",
|
||||
req: &pbs.CreateAuthMethodRequest{Item: &pb.AuthMethod{
|
||||
ScopeId: o.GetPublicId(),
|
||||
Type: globals.LdapSubtype.String(),
|
||||
Type: ldap.Subtype.String(),
|
||||
Attrs: &pb.AuthMethod_LdapAuthMethodsAttributes{
|
||||
LdapAuthMethodsAttributes: &pb.LdapAuthMethodAttributes{
|
||||
Urls: []string{"ldap://ldap1"},
|
||||
@@ -1265,7 +1265,7 @@ func TestCreate(t *testing.T) {
|
||||
name: "ldap-auth-method-missing-bind-password",
|
||||
req: &pbs.CreateAuthMethodRequest{Item: &pb.AuthMethod{
|
||||
ScopeId: o.GetPublicId(),
|
||||
Type: globals.LdapSubtype.String(),
|
||||
Type: ldap.Subtype.String(),
|
||||
Attrs: &pb.AuthMethod_LdapAuthMethodsAttributes{
|
||||
LdapAuthMethodsAttributes: &pb.LdapAuthMethodAttributes{
|
||||
Urls: []string{"ldap://ldap1"},
|
||||
@@ -1279,7 +1279,7 @@ func TestCreate(t *testing.T) {
|
||||
name: "ldap-auth-method-invalid-client-cert",
|
||||
req: &pbs.CreateAuthMethodRequest{Item: &pb.AuthMethod{
|
||||
ScopeId: o.GetPublicId(),
|
||||
Type: globals.LdapSubtype.String(),
|
||||
Type: ldap.Subtype.String(),
|
||||
Attrs: &pb.AuthMethod_LdapAuthMethodsAttributes{
|
||||
LdapAuthMethodsAttributes: &pb.LdapAuthMethodAttributes{
|
||||
Urls: []string{"ldap://ldap1"},
|
||||
@@ -1295,7 +1295,7 @@ func TestCreate(t *testing.T) {
|
||||
name: "ldap-auth-method-invalid-client-cert-key",
|
||||
req: &pbs.CreateAuthMethodRequest{Item: &pb.AuthMethod{
|
||||
ScopeId: o.GetPublicId(),
|
||||
Type: globals.LdapSubtype.String(),
|
||||
Type: ldap.Subtype.String(),
|
||||
Attrs: &pb.AuthMethod_LdapAuthMethodsAttributes{
|
||||
LdapAuthMethodsAttributes: &pb.LdapAuthMethodAttributes{
|
||||
Urls: []string{"ldap://ldap1"},
|
||||
@@ -1311,7 +1311,7 @@ func TestCreate(t *testing.T) {
|
||||
name: "ldap-auth-method-client-cert-key-not-a-key",
|
||||
req: &pbs.CreateAuthMethodRequest{Item: &pb.AuthMethod{
|
||||
ScopeId: o.GetPublicId(),
|
||||
Type: globals.LdapSubtype.String(),
|
||||
Type: ldap.Subtype.String(),
|
||||
Attrs: &pb.AuthMethod_LdapAuthMethodsAttributes{
|
||||
LdapAuthMethodsAttributes: &pb.LdapAuthMethodAttributes{
|
||||
Urls: []string{"ldap://ldap1"},
|
||||
@@ -1327,7 +1327,7 @@ func TestCreate(t *testing.T) {
|
||||
name: "ldap-auth-method-missing-client-cert-key",
|
||||
req: &pbs.CreateAuthMethodRequest{Item: &pb.AuthMethod{
|
||||
ScopeId: o.GetPublicId(),
|
||||
Type: globals.LdapSubtype.String(),
|
||||
Type: ldap.Subtype.String(),
|
||||
Attrs: &pb.AuthMethod_LdapAuthMethodsAttributes{
|
||||
LdapAuthMethodsAttributes: &pb.LdapAuthMethodAttributes{
|
||||
Urls: []string{"ldap://ldap1"},
|
||||
@@ -1342,7 +1342,7 @@ func TestCreate(t *testing.T) {
|
||||
name: "ldap-auth-method-missing-client-cert",
|
||||
req: &pbs.CreateAuthMethodRequest{Item: &pb.AuthMethod{
|
||||
ScopeId: o.GetPublicId(),
|
||||
Type: globals.LdapSubtype.String(),
|
||||
Type: ldap.Subtype.String(),
|
||||
Attrs: &pb.AuthMethod_LdapAuthMethodsAttributes{
|
||||
LdapAuthMethodsAttributes: &pb.LdapAuthMethodAttributes{
|
||||
Urls: []string{"ldap://ldap1"},
|
||||
@@ -1357,7 +1357,7 @@ func TestCreate(t *testing.T) {
|
||||
name: "ldap-auth-method-invalid-attribute-map",
|
||||
req: &pbs.CreateAuthMethodRequest{Item: &pb.AuthMethod{
|
||||
ScopeId: o.GetPublicId(),
|
||||
Type: globals.LdapSubtype.String(),
|
||||
Type: ldap.Subtype.String(),
|
||||
Attrs: &pb.AuthMethod_LdapAuthMethodsAttributes{
|
||||
LdapAuthMethodsAttributes: &pb.LdapAuthMethodAttributes{
|
||||
Urls: []string{"ldap://ldap1"},
|
||||
|
||||
@@ -11,7 +11,6 @@ import (
|
||||
"net/url"
|
||||
"strings"
|
||||
|
||||
"github.com/hashicorp/boundary/globals"
|
||||
"github.com/hashicorp/boundary/internal/auth/ldap"
|
||||
ldapstore "github.com/hashicorp/boundary/internal/auth/ldap/store"
|
||||
"github.com/hashicorp/boundary/internal/daemon/controller/auth"
|
||||
@@ -37,7 +36,7 @@ func init() {
|
||||
panic(err)
|
||||
}
|
||||
|
||||
IdActions[globals.LdapSubtype] = action.ActionSet{
|
||||
IdActions[ldap.Subtype] = action.ActionSet{
|
||||
action.NoOp,
|
||||
action.Read,
|
||||
action.Update,
|
||||
|
||||
@@ -96,7 +96,7 @@ func Test_UpdateLdap(t *testing.T) {
|
||||
ScopeId: o.GetPublicId(),
|
||||
Name: wrapperspb.String("default"),
|
||||
Description: wrapperspb.String("default"),
|
||||
Type: globals.LdapSubtype.String(),
|
||||
Type: ldap.Subtype.String(),
|
||||
Attrs: attrs,
|
||||
}})
|
||||
require.NoError(t, err)
|
||||
@@ -129,7 +129,7 @@ func Test_UpdateLdap(t *testing.T) {
|
||||
Item: &pb.AuthMethod{
|
||||
Name: &wrapperspb.StringValue{Value: "new"},
|
||||
Description: &wrapperspb.StringValue{Value: "desc"},
|
||||
Type: globals.LdapSubtype.String(),
|
||||
Type: ldap.Subtype.String(),
|
||||
},
|
||||
},
|
||||
res: &pbs.UpdateAuthMethodResponse{
|
||||
@@ -138,7 +138,7 @@ func Test_UpdateLdap(t *testing.T) {
|
||||
Name: &wrapperspb.StringValue{Value: "new"},
|
||||
Description: &wrapperspb.StringValue{Value: "desc"},
|
||||
Version: 2,
|
||||
Type: globals.LdapSubtype.String(),
|
||||
Type: ldap.Subtype.String(),
|
||||
Attrs: defaultReadAttributes,
|
||||
Scope: defaultScopeInfo,
|
||||
AuthorizedActions: ldapAuthorizedActions,
|
||||
@@ -155,7 +155,7 @@ func Test_UpdateLdap(t *testing.T) {
|
||||
Item: &pb.AuthMethod{
|
||||
Name: &wrapperspb.StringValue{Value: "new"},
|
||||
Description: &wrapperspb.StringValue{Value: "desc"},
|
||||
Type: globals.LdapSubtype.String(),
|
||||
Type: ldap.Subtype.String(),
|
||||
},
|
||||
},
|
||||
res: &pbs.UpdateAuthMethodResponse{
|
||||
@@ -164,7 +164,7 @@ func Test_UpdateLdap(t *testing.T) {
|
||||
Version: 2,
|
||||
Name: &wrapperspb.StringValue{Value: "new"},
|
||||
Description: &wrapperspb.StringValue{Value: "desc"},
|
||||
Type: globals.LdapSubtype.String(),
|
||||
Type: ldap.Subtype.String(),
|
||||
Attrs: defaultReadAttributes,
|
||||
Scope: defaultScopeInfo,
|
||||
AuthorizedActions: ldapAuthorizedActions,
|
||||
@@ -213,7 +213,7 @@ func Test_UpdateLdap(t *testing.T) {
|
||||
UpdateMask: &field_mask.FieldMask{Paths: []string{"name", "type"}},
|
||||
Item: &pb.AuthMethod{
|
||||
Name: &wrapperspb.StringValue{Value: "updated name"},
|
||||
Type: globals.PasswordSubtype.String(),
|
||||
Type: password.Subtype.String(),
|
||||
},
|
||||
},
|
||||
err: handlers.ApiErrorWithCode(codes.InvalidArgument),
|
||||
@@ -245,7 +245,7 @@ func Test_UpdateLdap(t *testing.T) {
|
||||
ScopeId: o.GetPublicId(),
|
||||
Version: 2,
|
||||
Description: &wrapperspb.StringValue{Value: "default"},
|
||||
Type: globals.LdapSubtype.String(),
|
||||
Type: ldap.Subtype.String(),
|
||||
Attrs: defaultReadAttributes,
|
||||
Scope: defaultScopeInfo,
|
||||
AuthorizedActions: ldapAuthorizedActions,
|
||||
@@ -268,7 +268,7 @@ func Test_UpdateLdap(t *testing.T) {
|
||||
ScopeId: o.GetPublicId(),
|
||||
Version: 2,
|
||||
Name: &wrapperspb.StringValue{Value: "default"},
|
||||
Type: globals.LdapSubtype.String(),
|
||||
Type: ldap.Subtype.String(),
|
||||
Attrs: defaultReadAttributes,
|
||||
Scope: defaultScopeInfo,
|
||||
AuthorizedActions: ldapAuthorizedActions,
|
||||
@@ -296,7 +296,7 @@ func Test_UpdateLdap(t *testing.T) {
|
||||
Version: 2,
|
||||
Name: &wrapperspb.StringValue{Value: "default"},
|
||||
Description: &wrapperspb.StringValue{Value: "default"},
|
||||
Type: globals.LdapSubtype.String(),
|
||||
Type: ldap.Subtype.String(),
|
||||
Attrs: &pb.AuthMethod_LdapAuthMethodsAttributes{
|
||||
LdapAuthMethodsAttributes: &pb.LdapAuthMethodAttributes{
|
||||
Urls: []string{"ldaps://ldap1"},
|
||||
@@ -326,7 +326,7 @@ func Test_UpdateLdap(t *testing.T) {
|
||||
Version: 2,
|
||||
Name: &wrapperspb.StringValue{Value: "updated"},
|
||||
Description: &wrapperspb.StringValue{Value: "default"},
|
||||
Type: globals.LdapSubtype.String(),
|
||||
Type: ldap.Subtype.String(),
|
||||
Attrs: defaultReadAttributes,
|
||||
Scope: defaultScopeInfo,
|
||||
AuthorizedActions: ldapAuthorizedActions,
|
||||
@@ -351,7 +351,7 @@ func Test_UpdateLdap(t *testing.T) {
|
||||
Version: 2,
|
||||
Name: &wrapperspb.StringValue{Value: "default"},
|
||||
Description: &wrapperspb.StringValue{Value: "notignored"},
|
||||
Type: globals.LdapSubtype.String(),
|
||||
Type: ldap.Subtype.String(),
|
||||
Attrs: defaultReadAttributes,
|
||||
Scope: defaultScopeInfo,
|
||||
AuthorizedActions: ldapAuthorizedActions,
|
||||
@@ -387,7 +387,7 @@ func Test_UpdateLdap(t *testing.T) {
|
||||
Version: 2,
|
||||
Name: &wrapperspb.StringValue{Value: "default"},
|
||||
Description: &wrapperspb.StringValue{Value: "default"},
|
||||
Type: globals.LdapSubtype.String(),
|
||||
Type: ldap.Subtype.String(),
|
||||
Attrs: &pb.AuthMethod_LdapAuthMethodsAttributes{
|
||||
LdapAuthMethodsAttributes: &pb.LdapAuthMethodAttributes{
|
||||
Urls: []string{"ldaps://ldap1"},
|
||||
@@ -448,7 +448,7 @@ func Test_UpdateLdap(t *testing.T) {
|
||||
Version: 2,
|
||||
Name: &wrapperspb.StringValue{Value: "default"},
|
||||
Description: &wrapperspb.StringValue{Value: "default"},
|
||||
Type: globals.LdapSubtype.String(),
|
||||
Type: ldap.Subtype.String(),
|
||||
Attrs: &pb.AuthMethod_LdapAuthMethodsAttributes{
|
||||
LdapAuthMethodsAttributes: &pb.LdapAuthMethodAttributes{
|
||||
Urls: []string{"ldaps://ldap1"},
|
||||
@@ -547,7 +547,7 @@ func Test_UpdateLdap(t *testing.T) {
|
||||
Paths: []string{"type"},
|
||||
},
|
||||
Item: &pb.AuthMethod{
|
||||
Type: globals.LdapSubtype.String(),
|
||||
Type: ldap.Subtype.String(),
|
||||
},
|
||||
},
|
||||
res: nil,
|
||||
@@ -609,7 +609,7 @@ func Test_UpdateLdap(t *testing.T) {
|
||||
Version: 2,
|
||||
Name: &wrapperspb.StringValue{Value: "default"},
|
||||
Description: &wrapperspb.StringValue{Value: "default"},
|
||||
Type: globals.LdapSubtype.String(),
|
||||
Type: ldap.Subtype.String(),
|
||||
Attrs: &pb.AuthMethod_LdapAuthMethodsAttributes{
|
||||
LdapAuthMethodsAttributes: &pb.LdapAuthMethodAttributes{
|
||||
Urls: []string{"ldaps://ldap1"},
|
||||
@@ -643,7 +643,7 @@ func Test_UpdateLdap(t *testing.T) {
|
||||
Version: 2,
|
||||
Name: &wrapperspb.StringValue{Value: "default"},
|
||||
Description: &wrapperspb.StringValue{Value: "default"},
|
||||
Type: globals.LdapSubtype.String(),
|
||||
Type: ldap.Subtype.String(),
|
||||
Attrs: &pb.AuthMethod_LdapAuthMethodsAttributes{
|
||||
LdapAuthMethodsAttributes: &pb.LdapAuthMethodAttributes{
|
||||
Urls: []string{"ldaps://ldap2", "ldaps://ldap3"},
|
||||
@@ -696,7 +696,7 @@ func Test_UpdateLdap(t *testing.T) {
|
||||
Version: 2,
|
||||
Name: &wrapperspb.StringValue{Value: "default"},
|
||||
Description: &wrapperspb.StringValue{Value: "default"},
|
||||
Type: globals.LdapSubtype.String(),
|
||||
Type: ldap.Subtype.String(),
|
||||
Attrs: &pb.AuthMethod_LdapAuthMethodsAttributes{
|
||||
LdapAuthMethodsAttributes: &pb.LdapAuthMethodAttributes{
|
||||
Urls: []string{"ldaps://ldap1"},
|
||||
@@ -733,7 +733,7 @@ func Test_UpdateLdap(t *testing.T) {
|
||||
Version: 2,
|
||||
Name: &wrapperspb.StringValue{Value: "default"},
|
||||
Description: &wrapperspb.StringValue{Value: "default"},
|
||||
Type: globals.LdapSubtype.String(),
|
||||
Type: ldap.Subtype.String(),
|
||||
Attrs: &pb.AuthMethod_LdapAuthMethodsAttributes{
|
||||
LdapAuthMethodsAttributes: &pb.LdapAuthMethodAttributes{
|
||||
Urls: []string{"ldaps://ldap1"},
|
||||
@@ -788,7 +788,7 @@ func Test_UpdateLdap(t *testing.T) {
|
||||
Version: 2,
|
||||
Name: &wrapperspb.StringValue{Value: "default"},
|
||||
Description: &wrapperspb.StringValue{Value: "default"},
|
||||
Type: globals.LdapSubtype.String(),
|
||||
Type: ldap.Subtype.String(),
|
||||
Attrs: &pb.AuthMethod_LdapAuthMethodsAttributes{
|
||||
LdapAuthMethodsAttributes: &pb.LdapAuthMethodAttributes{
|
||||
Urls: []string{"ldaps://ldap1"},
|
||||
|
||||
@@ -10,7 +10,6 @@ import (
|
||||
"net/url"
|
||||
"strings"
|
||||
|
||||
"github.com/hashicorp/boundary/globals"
|
||||
"github.com/hashicorp/boundary/internal/auth/oidc"
|
||||
oidcstore "github.com/hashicorp/boundary/internal/auth/oidc/store"
|
||||
"github.com/hashicorp/boundary/internal/daemon/controller/auth"
|
||||
@@ -57,7 +56,7 @@ func init() {
|
||||
panic(err)
|
||||
}
|
||||
|
||||
IdActions[globals.OidcSubtype] = action.ActionSet{
|
||||
IdActions[oidc.Subtype] = action.ActionSet{
|
||||
action.NoOp,
|
||||
action.Read,
|
||||
action.Update,
|
||||
|
||||
@@ -311,7 +311,7 @@ func TestUpdate_OIDC(t *testing.T) {
|
||||
ScopeId: o.GetPublicId(),
|
||||
Name: wrapperspb.String("default"),
|
||||
Description: wrapperspb.String("default"),
|
||||
Type: globals.OidcSubtype.String(),
|
||||
Type: oidc.Subtype.String(),
|
||||
Attrs: defaultAttributes,
|
||||
}})
|
||||
require.NoError(t, err)
|
||||
@@ -351,7 +351,7 @@ func TestUpdate_OIDC(t *testing.T) {
|
||||
Item: &pb.AuthMethod{
|
||||
Name: &wrapperspb.StringValue{Value: "new"},
|
||||
Description: &wrapperspb.StringValue{Value: "desc"},
|
||||
Type: globals.OidcSubtype.String(),
|
||||
Type: oidc.Subtype.String(),
|
||||
},
|
||||
},
|
||||
res: &pbs.UpdateAuthMethodResponse{
|
||||
@@ -359,7 +359,7 @@ func TestUpdate_OIDC(t *testing.T) {
|
||||
ScopeId: o.GetPublicId(),
|
||||
Name: &wrapperspb.StringValue{Value: "new"},
|
||||
Description: &wrapperspb.StringValue{Value: "desc"},
|
||||
Type: globals.OidcSubtype.String(),
|
||||
Type: oidc.Subtype.String(),
|
||||
Attrs: defaultReadAttributes,
|
||||
Scope: defaultScopeInfo,
|
||||
AuthorizedActions: oidcAuthorizedActions,
|
||||
@@ -376,7 +376,7 @@ func TestUpdate_OIDC(t *testing.T) {
|
||||
Item: &pb.AuthMethod{
|
||||
Name: &wrapperspb.StringValue{Value: "new"},
|
||||
Description: &wrapperspb.StringValue{Value: "desc"},
|
||||
Type: globals.OidcSubtype.String(),
|
||||
Type: oidc.Subtype.String(),
|
||||
},
|
||||
},
|
||||
res: &pbs.UpdateAuthMethodResponse{
|
||||
@@ -384,7 +384,7 @@ func TestUpdate_OIDC(t *testing.T) {
|
||||
ScopeId: o.GetPublicId(),
|
||||
Name: &wrapperspb.StringValue{Value: "new"},
|
||||
Description: &wrapperspb.StringValue{Value: "desc"},
|
||||
Type: globals.OidcSubtype.String(),
|
||||
Type: oidc.Subtype.String(),
|
||||
Attrs: defaultReadAttributes,
|
||||
Scope: defaultScopeInfo,
|
||||
AuthorizedActions: oidcAuthorizedActions,
|
||||
@@ -412,7 +412,7 @@ func TestUpdate_OIDC(t *testing.T) {
|
||||
ScopeId: o.GetPublicId(),
|
||||
Name: &wrapperspb.StringValue{Value: "default"},
|
||||
Description: &wrapperspb.StringValue{Value: "default"},
|
||||
Type: globals.OidcSubtype.String(),
|
||||
Type: oidc.Subtype.String(),
|
||||
Attrs: func() *pb.AuthMethod_OidcAuthMethodsAttributes {
|
||||
f := proto.Clone(defaultReadAttributes.OidcAuthMethodsAttributes).(*pb.OidcAuthMethodAttributes)
|
||||
f.Issuer = wrapperspb.String("http://localhost:72759/somepath/")
|
||||
@@ -481,7 +481,7 @@ func TestUpdate_OIDC(t *testing.T) {
|
||||
UpdateMask: &field_mask.FieldMask{Paths: []string{"name", "type"}},
|
||||
Item: &pb.AuthMethod{
|
||||
Name: &wrapperspb.StringValue{Value: "updated name"},
|
||||
Type: globals.PasswordSubtype.String(),
|
||||
Type: password.Subtype.String(),
|
||||
},
|
||||
},
|
||||
err: handlers.ApiErrorWithCode(codes.InvalidArgument),
|
||||
@@ -510,7 +510,7 @@ func TestUpdate_OIDC(t *testing.T) {
|
||||
Item: &pb.AuthMethod{
|
||||
ScopeId: o.GetPublicId(),
|
||||
Description: &wrapperspb.StringValue{Value: "default"},
|
||||
Type: globals.OidcSubtype.String(),
|
||||
Type: oidc.Subtype.String(),
|
||||
Attrs: defaultReadAttributes,
|
||||
Scope: defaultScopeInfo,
|
||||
AuthorizedActions: oidcAuthorizedActions,
|
||||
@@ -532,7 +532,7 @@ func TestUpdate_OIDC(t *testing.T) {
|
||||
Item: &pb.AuthMethod{
|
||||
ScopeId: o.GetPublicId(),
|
||||
Name: &wrapperspb.StringValue{Value: "default"},
|
||||
Type: globals.OidcSubtype.String(),
|
||||
Type: oidc.Subtype.String(),
|
||||
Attrs: defaultReadAttributes,
|
||||
Scope: defaultScopeInfo,
|
||||
AuthorizedActions: oidcAuthorizedActions,
|
||||
@@ -556,7 +556,7 @@ func TestUpdate_OIDC(t *testing.T) {
|
||||
ScopeId: o.GetPublicId(),
|
||||
Name: &wrapperspb.StringValue{Value: "updated"},
|
||||
Description: &wrapperspb.StringValue{Value: "default"},
|
||||
Type: globals.OidcSubtype.String(),
|
||||
Type: oidc.Subtype.String(),
|
||||
Attrs: defaultReadAttributes,
|
||||
Scope: defaultScopeInfo,
|
||||
AuthorizedActions: oidcAuthorizedActions,
|
||||
@@ -580,7 +580,7 @@ func TestUpdate_OIDC(t *testing.T) {
|
||||
ScopeId: o.GetPublicId(),
|
||||
Name: &wrapperspb.StringValue{Value: "default"},
|
||||
Description: &wrapperspb.StringValue{Value: "notignored"},
|
||||
Type: globals.OidcSubtype.String(),
|
||||
Type: oidc.Subtype.String(),
|
||||
Attrs: defaultReadAttributes,
|
||||
Scope: defaultScopeInfo,
|
||||
AuthorizedActions: oidcAuthorizedActions,
|
||||
@@ -650,7 +650,7 @@ func TestUpdate_OIDC(t *testing.T) {
|
||||
Paths: []string{"type"},
|
||||
},
|
||||
Item: &pb.AuthMethod{
|
||||
Type: globals.OidcSubtype.String(),
|
||||
Type: oidc.Subtype.String(),
|
||||
},
|
||||
},
|
||||
res: nil,
|
||||
@@ -705,7 +705,7 @@ func TestUpdate_OIDC(t *testing.T) {
|
||||
ScopeId: o.GetPublicId(),
|
||||
Name: &wrapperspb.StringValue{Value: "default"},
|
||||
Description: &wrapperspb.StringValue{Value: "default"},
|
||||
Type: globals.OidcSubtype.String(),
|
||||
Type: oidc.Subtype.String(),
|
||||
Attrs: func() *pb.AuthMethod_OidcAuthMethodsAttributes {
|
||||
f := proto.Clone(defaultReadAttributes.OidcAuthMethodsAttributes).(*pb.OidcAuthMethodAttributes)
|
||||
f.MaxAge = wrapperspb.UInt32(0)
|
||||
@@ -736,7 +736,7 @@ func TestUpdate_OIDC(t *testing.T) {
|
||||
ScopeId: o.GetPublicId(),
|
||||
Name: &wrapperspb.StringValue{Value: "default"},
|
||||
Description: &wrapperspb.StringValue{Value: "default"},
|
||||
Type: globals.OidcSubtype.String(),
|
||||
Type: oidc.Subtype.String(),
|
||||
Attrs: func() *pb.AuthMethod_OidcAuthMethodsAttributes {
|
||||
f := proto.Clone(defaultReadAttributes.OidcAuthMethodsAttributes).(*pb.OidcAuthMethodAttributes)
|
||||
f.MaxAge = wrapperspb.UInt32(4)
|
||||
@@ -767,7 +767,7 @@ func TestUpdate_OIDC(t *testing.T) {
|
||||
ScopeId: o.GetPublicId(),
|
||||
Name: &wrapperspb.StringValue{Value: "default"},
|
||||
Description: &wrapperspb.StringValue{Value: "default"},
|
||||
Type: globals.OidcSubtype.String(),
|
||||
Type: oidc.Subtype.String(),
|
||||
Attrs: func() *pb.AuthMethod_OidcAuthMethodsAttributes {
|
||||
f := proto.Clone(defaultReadAttributes.OidcAuthMethodsAttributes).(*pb.OidcAuthMethodAttributes)
|
||||
f.ClientId = wrapperspb.String("new id")
|
||||
@@ -814,7 +814,7 @@ func TestUpdate_OIDC(t *testing.T) {
|
||||
ScopeId: o.GetPublicId(),
|
||||
Name: &wrapperspb.StringValue{Value: "default"},
|
||||
Description: &wrapperspb.StringValue{Value: "default"},
|
||||
Type: globals.OidcSubtype.String(),
|
||||
Type: oidc.Subtype.String(),
|
||||
Attrs: func() *pb.AuthMethod_OidcAuthMethodsAttributes {
|
||||
f := proto.Clone(defaultReadAttributes.OidcAuthMethodsAttributes).(*pb.OidcAuthMethodAttributes)
|
||||
f.ApiUrlPrefix = wrapperspb.String("https://callback.prefix:9281/path")
|
||||
@@ -846,7 +846,7 @@ func TestUpdate_OIDC(t *testing.T) {
|
||||
ScopeId: o.GetPublicId(),
|
||||
Name: &wrapperspb.StringValue{Value: "default"},
|
||||
Description: &wrapperspb.StringValue{Value: "default"},
|
||||
Type: globals.OidcSubtype.String(),
|
||||
Type: oidc.Subtype.String(),
|
||||
Attrs: func() *pb.AuthMethod_OidcAuthMethodsAttributes {
|
||||
f := proto.Clone(defaultReadAttributes.OidcAuthMethodsAttributes).(*pb.OidcAuthMethodAttributes)
|
||||
f.AllowedAudiences = []string{"bar", "foo"}
|
||||
@@ -877,7 +877,7 @@ func TestUpdate_OIDC(t *testing.T) {
|
||||
ScopeId: o.GetPublicId(),
|
||||
Name: &wrapperspb.StringValue{Value: "default"},
|
||||
Description: &wrapperspb.StringValue{Value: "default"},
|
||||
Type: globals.OidcSubtype.String(),
|
||||
Type: oidc.Subtype.String(),
|
||||
Attrs: func() *pb.AuthMethod_OidcAuthMethodsAttributes {
|
||||
f := proto.Clone(defaultReadAttributes.OidcAuthMethodsAttributes).(*pb.OidcAuthMethodAttributes)
|
||||
f.ClaimsScopes = []string{"email", "profile"}
|
||||
@@ -908,7 +908,7 @@ func TestUpdate_OIDC(t *testing.T) {
|
||||
ScopeId: o.GetPublicId(),
|
||||
Name: &wrapperspb.StringValue{Value: "default"},
|
||||
Description: &wrapperspb.StringValue{Value: "default"},
|
||||
Type: globals.OidcSubtype.String(),
|
||||
Type: oidc.Subtype.String(),
|
||||
Attrs: func() *pb.AuthMethod_OidcAuthMethodsAttributes {
|
||||
f := proto.Clone(defaultReadAttributes.OidcAuthMethodsAttributes).(*pb.OidcAuthMethodAttributes)
|
||||
f.AccountClaimMaps = []string{"display_name=name"}
|
||||
@@ -982,7 +982,7 @@ func TestUpdate_OIDC(t *testing.T) {
|
||||
ScopeId: o.GetPublicId(),
|
||||
Name: &wrapperspb.StringValue{Value: "default"},
|
||||
Description: &wrapperspb.StringValue{Value: "default"},
|
||||
Type: globals.OidcSubtype.String(),
|
||||
Type: oidc.Subtype.String(),
|
||||
Attrs: func() *pb.AuthMethod_OidcAuthMethodsAttributes {
|
||||
f := proto.Clone(defaultReadAttributes.OidcAuthMethodsAttributes).(*pb.OidcAuthMethodAttributes)
|
||||
f.SigningAlgorithms = []string{string(oidc.EdDSA)}
|
||||
@@ -1115,7 +1115,7 @@ func TestUpdate_OIDCDryRun(t *testing.T) {
|
||||
CreatedTime: am.GetCreateTime().GetTimestamp(),
|
||||
UpdatedTime: am.GetUpdateTime().GetTimestamp(),
|
||||
Version: am.GetVersion(),
|
||||
Type: globals.OidcSubtype.String(),
|
||||
Type: oidc.Subtype.String(),
|
||||
AuthorizedActions: oidcAuthorizedActions,
|
||||
AuthorizedCollectionActions: authorizedCollectionActions,
|
||||
Attrs: &pb.AuthMethod_OidcAuthMethodsAttributes{
|
||||
@@ -1289,7 +1289,7 @@ func TestChangeState_OIDC(t *testing.T) {
|
||||
ScopeId: oidcam.GetScopeId(),
|
||||
CreatedTime: oidcam.CreateTime.GetTimestamp(),
|
||||
UpdatedTime: oidcam.UpdateTime.GetTimestamp(),
|
||||
Type: globals.OidcSubtype.String(),
|
||||
Type: oidc.Subtype.String(),
|
||||
Attrs: &pb.AuthMethod_OidcAuthMethodsAttributes{
|
||||
OidcAuthMethodsAttributes: &pb.OidcAuthMethodAttributes{
|
||||
Issuer: wrapperspb.String(oidcam.GetIssuer()),
|
||||
|
||||
@@ -8,7 +8,6 @@ import (
|
||||
"fmt"
|
||||
"strings"
|
||||
|
||||
"github.com/hashicorp/boundary/globals"
|
||||
"github.com/hashicorp/boundary/internal/auth/password"
|
||||
pwstore "github.com/hashicorp/boundary/internal/auth/password/store"
|
||||
"github.com/hashicorp/boundary/internal/daemon/controller/auth"
|
||||
@@ -37,7 +36,7 @@ func init() {
|
||||
panic(err)
|
||||
}
|
||||
|
||||
IdActions[globals.PasswordSubtype] = action.ActionSet{
|
||||
IdActions[password.Subtype] = action.ActionSet{
|
||||
action.NoOp,
|
||||
action.Read,
|
||||
action.Update,
|
||||
|
||||
+27
-27
@@ -278,7 +278,7 @@ func (s Service) UpdateCredentialLibrary(ctx context.Context, req *pbs.UpdateCre
|
||||
var currentCredentialType globals.CredentialType
|
||||
var mo vault.MappingOverride
|
||||
switch subtypes.SubtypeFromId(domain, req.GetId()) {
|
||||
case globals.VaultSshCertificateLibrarySubtype:
|
||||
case vault.SSHCertificateLibrarySubtype:
|
||||
cur, err := repo.LookupSSHCertificateCredentialLibrary(ctx, req.Id)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
@@ -375,7 +375,7 @@ func (s Service) getFromRepo(ctx context.Context, id string) (credential.Library
|
||||
return nil, errors.Wrap(ctx, err, op)
|
||||
}
|
||||
switch subtypes.SubtypeFromId(domain, id) {
|
||||
case globals.VaultGenericLibrarySubtype:
|
||||
case vault.GenericLibrarySubtype:
|
||||
cs, err := repo.LookupCredentialLibrary(ctx, id)
|
||||
if err != nil && !errors.IsNotFoundError(err) {
|
||||
return nil, errors.Wrap(ctx, err, op)
|
||||
@@ -384,7 +384,7 @@ func (s Service) getFromRepo(ctx context.Context, id string) (credential.Library
|
||||
return nil, errors.New(ctx, errors.InvalidParameter, op, fmt.Sprintf("credential library %q not found", id))
|
||||
}
|
||||
return cs, err
|
||||
case globals.VaultSshCertificateLibrarySubtype:
|
||||
case vault.SSHCertificateLibrarySubtype:
|
||||
cs, err := repo.LookupSSHCertificateCredentialLibrary(ctx, id)
|
||||
if err != nil && !errors.IsNotFoundError(err) {
|
||||
return nil, errors.Wrap(ctx, err, op)
|
||||
@@ -401,7 +401,7 @@ func (s Service) createInRepo(ctx context.Context, scopeId string, item *pb.Cred
|
||||
const op = "credentiallibraries.(Service).createInRepo"
|
||||
var out credential.Library
|
||||
switch subtypes.SubtypeFromType(domain, item.GetType()) {
|
||||
case globals.VaultSshCertificateLibrarySubtype:
|
||||
case vault.SSHCertificateLibrarySubtype:
|
||||
cl, err := toStorageVaultSSHCertificateLibrary(ctx, item.GetCredentialStoreId(), item)
|
||||
if err != nil {
|
||||
return nil, errors.Wrap(ctx, err, op)
|
||||
@@ -471,7 +471,7 @@ func (s Service) updateInRepo(
|
||||
return nil, errors.Wrap(ctx, err, op)
|
||||
}
|
||||
switch subtypes.SubtypeFromId(domain, id) {
|
||||
case globals.VaultSshCertificateLibrarySubtype:
|
||||
case vault.SSHCertificateLibrarySubtype:
|
||||
dbMasks = append(dbMasks, sshCertMaskManager.Translate(masks)...)
|
||||
if getMapUpdate(criticalOptionsField, masks) {
|
||||
dbMasks = append(dbMasks, vault.CriticalOptionsField)
|
||||
@@ -523,7 +523,7 @@ func (s Service) deleteFromRepo(ctx context.Context, scopeId, id string) (bool,
|
||||
}
|
||||
rows := 0
|
||||
switch subtypes.SubtypeFromId(domain, id) {
|
||||
case globals.VaultSshCertificateLibrarySubtype:
|
||||
case vault.SSHCertificateLibrarySubtype:
|
||||
rows, err = repo.DeleteSSHCertificateCredentialLibrary(ctx, scopeId, id)
|
||||
default:
|
||||
rows, err = repo.DeleteCredentialLibrary(ctx, scopeId, id)
|
||||
@@ -555,7 +555,7 @@ func (s Service) authResult(ctx context.Context, id string, a action.Type) auth.
|
||||
opts = append(opts, auth.WithId(id))
|
||||
parentId = id
|
||||
switch subtypes.SubtypeFromId(domain, id) {
|
||||
case globals.VaultGenericLibrarySubtype:
|
||||
case vault.GenericLibrarySubtype:
|
||||
cl, err := repo.LookupCredentialLibrary(ctx, id)
|
||||
if err != nil {
|
||||
res.Error = err
|
||||
@@ -566,7 +566,7 @@ func (s Service) authResult(ctx context.Context, id string, a action.Type) auth.
|
||||
return res
|
||||
}
|
||||
parentId = cl.GetStoreId()
|
||||
case globals.VaultSshCertificateLibrarySubtype:
|
||||
case vault.SSHCertificateLibrarySubtype:
|
||||
cl, err := repo.LookupSSHCertificateCredentialLibrary(ctx, id)
|
||||
if err != nil {
|
||||
res.Error = err
|
||||
@@ -591,7 +591,7 @@ func (s Service) authResult(ctx context.Context, id string, a action.Type) auth.
|
||||
opts = append(opts, auth.WithPin(parentId))
|
||||
|
||||
switch subtypes.SubtypeFromId(domain, parentId) {
|
||||
case globals.VaultSubtype:
|
||||
case vault.Subtype:
|
||||
cs, err := repo.LookupCredentialStore(ctx, parentId)
|
||||
if err != nil {
|
||||
res.Error = err
|
||||
@@ -651,7 +651,7 @@ func toProto(ctx context.Context, in credential.Library, opt ...handlers.Option)
|
||||
out.AuthorizedActions = opts.WithAuthorizedActions
|
||||
}
|
||||
switch subtypes.SubtypeFromId(domain, in.GetPublicId()) {
|
||||
case globals.VaultGenericLibrarySubtype:
|
||||
case vault.GenericLibrarySubtype:
|
||||
vaultIn, ok := in.(*vault.CredentialLibrary)
|
||||
if !ok {
|
||||
return nil, errors.New(ctx, errors.Internal, op, "unable to cast to vault credential library")
|
||||
@@ -704,7 +704,7 @@ func toProto(ctx context.Context, in credential.Library, opt ...handlers.Option)
|
||||
VaultGenericCredentialLibraryAttributes: attrs,
|
||||
}
|
||||
}
|
||||
case globals.VaultSshCertificateLibrarySubtype:
|
||||
case vault.SSHCertificateLibrarySubtype:
|
||||
vaultIn, ok := in.(*vault.SSHCertificateCredentialLibrary)
|
||||
if !ok {
|
||||
return nil, errors.New(ctx, errors.Internal, op, "unable to cast to vault ssh certificate credential library")
|
||||
@@ -880,7 +880,7 @@ func toStorageVaultSSHCertificateLibrary(ctx context.Context, storeId string, in
|
||||
func validateGetRequest(req *pbs.GetCredentialLibraryRequest) error {
|
||||
prefix := ""
|
||||
switch subtypes.SubtypeFromId(domain, req.GetId()) {
|
||||
case globals.VaultSshCertificateLibrarySubtype:
|
||||
case vault.SSHCertificateLibrarySubtype:
|
||||
prefix = globals.VaultSshCertificateCredentialLibraryPrefix
|
||||
default:
|
||||
prefix = globals.VaultCredentialLibraryPrefix
|
||||
@@ -892,18 +892,18 @@ func validateCreateRequest(req *pbs.CreateCredentialLibraryRequest) error {
|
||||
return handlers.ValidateCreateRequest(req.GetItem(), func() map[string]string {
|
||||
badFields := map[string]string{}
|
||||
switch subtypes.SubtypeFromId(domain, req.GetItem().GetCredentialStoreId()) {
|
||||
case globals.VaultSubtype:
|
||||
case vault.Subtype:
|
||||
var t string
|
||||
if version.SupportsFeature(version.Binary, version.CredentialLibraryVaultSubtype) {
|
||||
t = req.GetItem().GetType()
|
||||
|
||||
// To support older cli's that do not send a `type`, assume
|
||||
// subtype of vault-generic based on the credential store's subtype.
|
||||
// To support the deprecated subtype 'globals.VaultSubtype', convert it
|
||||
// To support the deprecated subtype 'vault.Subtype', convert it
|
||||
// to vault-generic.
|
||||
if t == "" || subtypes.SubtypeFromType(domain, t) == globals.VaultSubtype {
|
||||
if t == "" || subtypes.SubtypeFromType(domain, t) == vault.Subtype {
|
||||
// fallback to assuming subtype from credential store.
|
||||
t = globals.VaultGenericLibrarySubtype.String()
|
||||
t = vault.GenericLibrarySubtype.String()
|
||||
req.GetItem().Type = t
|
||||
|
||||
switch req.GetItem().Attrs.(type) {
|
||||
@@ -927,13 +927,13 @@ func validateCreateRequest(req *pbs.CreateCredentialLibraryRequest) error {
|
||||
}
|
||||
}
|
||||
|
||||
if subtypes.SubtypeFromType(domain, t) != globals.VaultGenericLibrarySubtype &&
|
||||
subtypes.SubtypeFromType(domain, t) != globals.VaultSshCertificateLibrarySubtype {
|
||||
badFields[globals.CredentialStoreIdField] = fmt.Sprintf("Type must be a vault subtype %q or %q", globals.VaultGenericLibrarySubtype.String(), globals.VaultSshCertificateLibrarySubtype.String())
|
||||
if subtypes.SubtypeFromType(domain, t) != vault.GenericLibrarySubtype &&
|
||||
subtypes.SubtypeFromType(domain, t) != vault.SSHCertificateLibrarySubtype {
|
||||
badFields[globals.CredentialStoreIdField] = fmt.Sprintf("Type must be a vault subtype %q or %q", vault.GenericLibrarySubtype.String(), vault.SSHCertificateLibrarySubtype.String())
|
||||
}
|
||||
|
||||
switch subtypes.SubtypeFromType(domain, req.GetItem().GetType()) {
|
||||
case globals.VaultGenericLibrarySubtype:
|
||||
case vault.GenericLibrarySubtype:
|
||||
isValidCred := false
|
||||
ct := req.GetItem().GetCredentialType()
|
||||
for _, t := range validCredentialTypesVaultGeneric {
|
||||
@@ -964,7 +964,7 @@ func validateCreateRequest(req *pbs.CreateCredentialLibraryRequest) error {
|
||||
badFields[httpRequestBodyField] = fmt.Sprintf("Field can only be set if %q is set to the value 'POST'.", httpMethodField)
|
||||
}
|
||||
validateMapping(badFields, globals.CredentialType(req.GetItem().GetCredentialType()), req.GetItem().CredentialMappingOverrides.AsMap())
|
||||
case globals.VaultSshCertificateLibrarySubtype:
|
||||
case vault.SSHCertificateLibrarySubtype:
|
||||
if req.GetItem().GetCredentialType() != "" {
|
||||
badFields[globals.CredentialTypeField] = fmt.Sprintf("This field is read only and cannot be set.")
|
||||
}
|
||||
@@ -1003,16 +1003,16 @@ func validateUpdateRequest(req *pbs.UpdateCredentialLibraryRequest, currentCrede
|
||||
prefix := ""
|
||||
st := subtypes.SubtypeFromId(domain, req.GetId())
|
||||
switch st {
|
||||
case globals.VaultGenericLibrarySubtype:
|
||||
case vault.GenericLibrarySubtype:
|
||||
prefix = globals.VaultCredentialLibraryPrefix
|
||||
case globals.VaultSshCertificateLibrarySubtype:
|
||||
case vault.SSHCertificateLibrarySubtype:
|
||||
prefix = globals.VaultSshCertificateCredentialLibraryPrefix
|
||||
}
|
||||
return handlers.ValidateUpdateRequest(req, req.GetItem(), func() map[string]string {
|
||||
badFields := map[string]string{}
|
||||
switch st {
|
||||
case globals.VaultGenericLibrarySubtype:
|
||||
if req.GetItem().GetType() != "" && subtypes.SubtypeFromType(domain, req.GetItem().GetType()) != globals.VaultGenericLibrarySubtype {
|
||||
case vault.GenericLibrarySubtype:
|
||||
if req.GetItem().GetType() != "" && subtypes.SubtypeFromType(domain, req.GetItem().GetType()) != vault.GenericLibrarySubtype {
|
||||
badFields[globals.TypeField] = "Cannot modify resource type."
|
||||
}
|
||||
if req.GetItem().GetCredentialType() != "" && req.GetItem().GetCredentialType() != string(currentCredentialType) {
|
||||
@@ -1035,8 +1035,8 @@ func validateUpdateRequest(req *pbs.UpdateCredentialLibraryRequest, currentCrede
|
||||
}
|
||||
validateMapping(badFields, currentCredentialType, req.GetItem().CredentialMappingOverrides.AsMap())
|
||||
}
|
||||
case globals.VaultSshCertificateLibrarySubtype:
|
||||
if req.GetItem().GetType() != "" && subtypes.SubtypeFromType(domain, req.GetItem().GetType()) != globals.VaultSshCertificateLibrarySubtype {
|
||||
case vault.SSHCertificateLibrarySubtype:
|
||||
if req.GetItem().GetType() != "" && subtypes.SubtypeFromType(domain, req.GetItem().GetType()) != vault.SSHCertificateLibrarySubtype {
|
||||
badFields[globals.TypeField] = "Cannot modify resource type."
|
||||
}
|
||||
if req.GetItem().GetCredentialType() != "" && req.GetItem().GetCredentialType() != string(currentCredentialType) {
|
||||
|
||||
+58
-58
@@ -68,7 +68,7 @@ func TestList(t *testing.T) {
|
||||
CreatedTime: l.GetCreateTime().GetTimestamp(),
|
||||
UpdatedTime: l.GetUpdateTime().GetTimestamp(),
|
||||
Version: l.GetVersion(),
|
||||
Type: globals.VaultGenericLibrarySubtype.String(),
|
||||
Type: vault.GenericLibrarySubtype.String(),
|
||||
AuthorizedActions: testAuthorizedActions,
|
||||
Attrs: &pb.CredentialLibrary_VaultGenericCredentialLibraryAttributes{
|
||||
VaultGenericCredentialLibraryAttributes: &pb.VaultCredentialLibraryAttributes{
|
||||
@@ -87,7 +87,7 @@ func TestList(t *testing.T) {
|
||||
CreatedTime: l.GetCreateTime().GetTimestamp(),
|
||||
UpdatedTime: l.GetUpdateTime().GetTimestamp(),
|
||||
Version: l.GetVersion(),
|
||||
Type: globals.VaultSshCertificateLibrarySubtype.String(),
|
||||
Type: vault.SSHCertificateLibrarySubtype.String(),
|
||||
AuthorizedActions: testAuthorizedActions,
|
||||
Attrs: &pb.CredentialLibrary_VaultSshCertificateCredentialLibraryAttributes{
|
||||
VaultSshCertificateCredentialLibraryAttributes: &pb.VaultSSHCertificateCredentialLibraryAttributes{
|
||||
@@ -199,7 +199,7 @@ func TestList_Attributes(t *testing.T) {
|
||||
CreatedTime: l.GetCreateTime().GetTimestamp(),
|
||||
UpdatedTime: l.GetUpdateTime().GetTimestamp(),
|
||||
Version: l.GetVersion(),
|
||||
Type: globals.VaultGenericLibrarySubtype.String(),
|
||||
Type: vault.GenericLibrarySubtype.String(),
|
||||
AuthorizedActions: testAuthorizedActions,
|
||||
Attrs: &pb.CredentialLibrary_VaultGenericCredentialLibraryAttributes{
|
||||
VaultGenericCredentialLibraryAttributes: &pb.VaultCredentialLibraryAttributes{
|
||||
@@ -218,7 +218,7 @@ func TestList_Attributes(t *testing.T) {
|
||||
CreatedTime: l.GetCreateTime().GetTimestamp(),
|
||||
UpdatedTime: l.GetUpdateTime().GetTimestamp(),
|
||||
Version: l.GetVersion(),
|
||||
Type: globals.VaultSshCertificateLibrarySubtype.String(),
|
||||
Type: vault.SSHCertificateLibrarySubtype.String(),
|
||||
AuthorizedActions: testAuthorizedActions,
|
||||
Attrs: &pb.CredentialLibrary_VaultSshCertificateCredentialLibraryAttributes{
|
||||
VaultSshCertificateCredentialLibraryAttributes: &pb.VaultSSHCertificateCredentialLibraryAttributes{
|
||||
@@ -317,7 +317,7 @@ func TestCreate(t *testing.T) {
|
||||
name: "missing vault path",
|
||||
req: &pbs.CreateCredentialLibraryRequest{Item: &pb.CredentialLibrary{
|
||||
CredentialStoreId: store.GetPublicId(),
|
||||
Type: globals.VaultGenericLibrarySubtype.String(),
|
||||
Type: vault.GenericLibrarySubtype.String(),
|
||||
Attrs: &pb.CredentialLibrary_VaultGenericCredentialLibraryAttributes{
|
||||
VaultGenericCredentialLibraryAttributes: &pb.VaultCredentialLibraryAttributes{},
|
||||
},
|
||||
@@ -329,7 +329,7 @@ func TestCreate(t *testing.T) {
|
||||
name: "Can't specify Id",
|
||||
req: &pbs.CreateCredentialLibraryRequest{Item: &pb.CredentialLibrary{
|
||||
CredentialStoreId: store.GetPublicId(),
|
||||
Type: globals.VaultGenericLibrarySubtype.String(),
|
||||
Type: vault.GenericLibrarySubtype.String(),
|
||||
Id: globals.VaultCredentialLibraryPrefix + "_notallowed",
|
||||
Attrs: &pb.CredentialLibrary_VaultGenericCredentialLibraryAttributes{
|
||||
VaultGenericCredentialLibraryAttributes: &pb.VaultCredentialLibraryAttributes{
|
||||
@@ -344,7 +344,7 @@ func TestCreate(t *testing.T) {
|
||||
name: "Can't specify Created Time",
|
||||
req: &pbs.CreateCredentialLibraryRequest{Item: &pb.CredentialLibrary{
|
||||
CredentialStoreId: store.GetPublicId(),
|
||||
Type: globals.VaultGenericLibrarySubtype.String(),
|
||||
Type: vault.GenericLibrarySubtype.String(),
|
||||
CreatedTime: timestamppb.Now(),
|
||||
Attrs: &pb.CredentialLibrary_VaultGenericCredentialLibraryAttributes{
|
||||
VaultGenericCredentialLibraryAttributes: &pb.VaultCredentialLibraryAttributes{
|
||||
@@ -359,7 +359,7 @@ func TestCreate(t *testing.T) {
|
||||
name: "Can't specify Update Time",
|
||||
req: &pbs.CreateCredentialLibraryRequest{Item: &pb.CredentialLibrary{
|
||||
CredentialStoreId: store.GetPublicId(),
|
||||
Type: globals.VaultGenericLibrarySubtype.String(),
|
||||
Type: vault.GenericLibrarySubtype.String(),
|
||||
UpdatedTime: timestamppb.Now(),
|
||||
Attrs: &pb.CredentialLibrary_VaultGenericCredentialLibraryAttributes{
|
||||
VaultGenericCredentialLibraryAttributes: &pb.VaultCredentialLibraryAttributes{
|
||||
@@ -387,7 +387,7 @@ func TestCreate(t *testing.T) {
|
||||
{
|
||||
name: "parent id must be included",
|
||||
req: &pbs.CreateCredentialLibraryRequest{Item: &pb.CredentialLibrary{
|
||||
Type: globals.VaultGenericLibrarySubtype.String(),
|
||||
Type: vault.GenericLibrarySubtype.String(),
|
||||
Attrs: &pb.CredentialLibrary_VaultGenericCredentialLibraryAttributes{
|
||||
VaultGenericCredentialLibraryAttributes: &pb.VaultCredentialLibraryAttributes{
|
||||
Path: wrapperspb.String("something"),
|
||||
@@ -401,7 +401,7 @@ func TestCreate(t *testing.T) {
|
||||
name: "Cannot specify a http request body when http method is get",
|
||||
req: &pbs.CreateCredentialLibraryRequest{Item: &pb.CredentialLibrary{
|
||||
CredentialStoreId: store.GetPublicId(),
|
||||
Type: globals.VaultGenericLibrarySubtype.String(),
|
||||
Type: vault.GenericLibrarySubtype.String(),
|
||||
Attrs: &pb.CredentialLibrary_VaultGenericCredentialLibraryAttributes{
|
||||
VaultGenericCredentialLibraryAttributes: &pb.VaultCredentialLibraryAttributes{
|
||||
Path: wrapperspb.String("something"),
|
||||
@@ -416,7 +416,7 @@ func TestCreate(t *testing.T) {
|
||||
name: "Invalid Method",
|
||||
req: &pbs.CreateCredentialLibraryRequest{Item: &pb.CredentialLibrary{
|
||||
CredentialStoreId: store.GetPublicId(),
|
||||
Type: globals.VaultGenericLibrarySubtype.String(),
|
||||
Type: vault.GenericLibrarySubtype.String(),
|
||||
Attrs: &pb.CredentialLibrary_VaultGenericCredentialLibraryAttributes{
|
||||
VaultGenericCredentialLibraryAttributes: &pb.VaultCredentialLibraryAttributes{
|
||||
Path: wrapperspb.String("something"),
|
||||
@@ -431,7 +431,7 @@ func TestCreate(t *testing.T) {
|
||||
name: "Request Body With GET Method",
|
||||
req: &pbs.CreateCredentialLibraryRequest{Item: &pb.CredentialLibrary{
|
||||
CredentialStoreId: store.GetPublicId(),
|
||||
Type: globals.VaultGenericLibrarySubtype.String(),
|
||||
Type: vault.GenericLibrarySubtype.String(),
|
||||
Attrs: &pb.CredentialLibrary_VaultGenericCredentialLibraryAttributes{
|
||||
VaultGenericCredentialLibraryAttributes: &pb.VaultCredentialLibraryAttributes{
|
||||
Path: wrapperspb.String("something"),
|
||||
@@ -446,7 +446,7 @@ func TestCreate(t *testing.T) {
|
||||
name: "Invalid credential type",
|
||||
req: &pbs.CreateCredentialLibraryRequest{Item: &pb.CredentialLibrary{
|
||||
CredentialStoreId: store.GetPublicId(),
|
||||
Type: globals.VaultGenericLibrarySubtype.String(),
|
||||
Type: vault.GenericLibrarySubtype.String(),
|
||||
Attrs: &pb.CredentialLibrary_VaultGenericCredentialLibraryAttributes{
|
||||
VaultGenericCredentialLibraryAttributes: &pb.VaultCredentialLibraryAttributes{
|
||||
Path: wrapperspb.String("something"),
|
||||
@@ -461,7 +461,7 @@ func TestCreate(t *testing.T) {
|
||||
name: "Invalid username_password mapping",
|
||||
req: &pbs.CreateCredentialLibraryRequest{Item: &pb.CredentialLibrary{
|
||||
CredentialStoreId: store.GetPublicId(),
|
||||
Type: globals.VaultGenericLibrarySubtype.String(),
|
||||
Type: vault.GenericLibrarySubtype.String(),
|
||||
Attrs: &pb.CredentialLibrary_VaultGenericCredentialLibraryAttributes{
|
||||
VaultGenericCredentialLibraryAttributes: &pb.VaultCredentialLibraryAttributes{
|
||||
Path: wrapperspb.String("something"),
|
||||
@@ -485,7 +485,7 @@ func TestCreate(t *testing.T) {
|
||||
name: "Using POST method",
|
||||
req: &pbs.CreateCredentialLibraryRequest{Item: &pb.CredentialLibrary{
|
||||
CredentialStoreId: store.GetPublicId(),
|
||||
Type: globals.VaultGenericLibrarySubtype.String(),
|
||||
Type: vault.GenericLibrarySubtype.String(),
|
||||
Attrs: &pb.CredentialLibrary_VaultGenericCredentialLibraryAttributes{
|
||||
VaultGenericCredentialLibraryAttributes: &pb.VaultCredentialLibraryAttributes{
|
||||
Path: wrapperspb.String("something"),
|
||||
@@ -504,7 +504,7 @@ func TestCreate(t *testing.T) {
|
||||
UpdatedTime: store.GetUpdateTime().GetTimestamp(),
|
||||
Scope: &scopepb.ScopeInfo{Id: prj.GetPublicId(), Type: prj.GetType(), ParentScopeId: prj.GetParentId()},
|
||||
Version: 1,
|
||||
Type: globals.VaultGenericLibrarySubtype.String(),
|
||||
Type: vault.GenericLibrarySubtype.String(),
|
||||
Attrs: &pb.CredentialLibrary_VaultGenericCredentialLibraryAttributes{
|
||||
VaultGenericCredentialLibraryAttributes: &pb.VaultCredentialLibraryAttributes{
|
||||
Path: wrapperspb.String("something"),
|
||||
@@ -520,7 +520,7 @@ func TestCreate(t *testing.T) {
|
||||
name: "Create a valid vault CredentialLibrary",
|
||||
req: &pbs.CreateCredentialLibraryRequest{Item: &pb.CredentialLibrary{
|
||||
CredentialStoreId: store.GetPublicId(),
|
||||
Type: globals.VaultGenericLibrarySubtype.String(),
|
||||
Type: vault.GenericLibrarySubtype.String(),
|
||||
Name: &wrapperspb.StringValue{Value: "name"},
|
||||
Description: &wrapperspb.StringValue{Value: "desc"},
|
||||
Attrs: &pb.CredentialLibrary_VaultGenericCredentialLibraryAttributes{
|
||||
@@ -541,7 +541,7 @@ func TestCreate(t *testing.T) {
|
||||
Description: &wrapperspb.StringValue{Value: "desc"},
|
||||
Scope: &scopepb.ScopeInfo{Id: prj.GetPublicId(), Type: prj.GetType(), ParentScopeId: prj.GetParentId()},
|
||||
Version: 1,
|
||||
Type: globals.VaultGenericLibrarySubtype.String(),
|
||||
Type: vault.GenericLibrarySubtype.String(),
|
||||
Attrs: &pb.CredentialLibrary_VaultGenericCredentialLibraryAttributes{
|
||||
VaultGenericCredentialLibraryAttributes: &pb.VaultCredentialLibraryAttributes{
|
||||
Path: wrapperspb.String("something"),
|
||||
@@ -556,7 +556,7 @@ func TestCreate(t *testing.T) {
|
||||
name: "Create a valid vault CredentialLibrary username_password type",
|
||||
req: &pbs.CreateCredentialLibraryRequest{Item: &pb.CredentialLibrary{
|
||||
CredentialStoreId: store.GetPublicId(),
|
||||
Type: globals.VaultGenericLibrarySubtype.String(),
|
||||
Type: vault.GenericLibrarySubtype.String(),
|
||||
Attrs: &pb.CredentialLibrary_VaultGenericCredentialLibraryAttributes{
|
||||
VaultGenericCredentialLibraryAttributes: &pb.VaultCredentialLibraryAttributes{
|
||||
Path: wrapperspb.String("something"),
|
||||
@@ -574,7 +574,7 @@ func TestCreate(t *testing.T) {
|
||||
UpdatedTime: store.GetUpdateTime().GetTimestamp(),
|
||||
Scope: &scopepb.ScopeInfo{Id: prj.GetPublicId(), Type: prj.GetType(), ParentScopeId: prj.GetParentId()},
|
||||
Version: 1,
|
||||
Type: globals.VaultGenericLibrarySubtype.String(),
|
||||
Type: vault.GenericLibrarySubtype.String(),
|
||||
Attrs: &pb.CredentialLibrary_VaultGenericCredentialLibraryAttributes{
|
||||
VaultGenericCredentialLibraryAttributes: &pb.VaultCredentialLibraryAttributes{
|
||||
Path: wrapperspb.String("something"),
|
||||
@@ -590,7 +590,7 @@ func TestCreate(t *testing.T) {
|
||||
name: "Create a valid vault CredentialLibrary username_password type with username mapping",
|
||||
req: &pbs.CreateCredentialLibraryRequest{Item: &pb.CredentialLibrary{
|
||||
CredentialStoreId: store.GetPublicId(),
|
||||
Type: globals.VaultGenericLibrarySubtype.String(),
|
||||
Type: vault.GenericLibrarySubtype.String(),
|
||||
Attrs: &pb.CredentialLibrary_VaultGenericCredentialLibraryAttributes{
|
||||
VaultGenericCredentialLibraryAttributes: &pb.VaultCredentialLibraryAttributes{
|
||||
Path: wrapperspb.String("something"),
|
||||
@@ -616,7 +616,7 @@ func TestCreate(t *testing.T) {
|
||||
UpdatedTime: store.GetUpdateTime().GetTimestamp(),
|
||||
Scope: &scopepb.ScopeInfo{Id: prj.GetPublicId(), Type: prj.GetType(), ParentScopeId: prj.GetParentId()},
|
||||
Version: 1,
|
||||
Type: globals.VaultGenericLibrarySubtype.String(),
|
||||
Type: vault.GenericLibrarySubtype.String(),
|
||||
Attrs: &pb.CredentialLibrary_VaultGenericCredentialLibraryAttributes{
|
||||
VaultGenericCredentialLibraryAttributes: &pb.VaultCredentialLibraryAttributes{
|
||||
Path: wrapperspb.String("something"),
|
||||
@@ -640,7 +640,7 @@ func TestCreate(t *testing.T) {
|
||||
name: "Create a valid vault CredentialLibrary username_password type with username/password mapping",
|
||||
req: &pbs.CreateCredentialLibraryRequest{Item: &pb.CredentialLibrary{
|
||||
CredentialStoreId: store.GetPublicId(),
|
||||
Type: globals.VaultGenericLibrarySubtype.String(),
|
||||
Type: vault.GenericLibrarySubtype.String(),
|
||||
Attrs: &pb.CredentialLibrary_VaultGenericCredentialLibraryAttributes{
|
||||
VaultGenericCredentialLibraryAttributes: &pb.VaultCredentialLibraryAttributes{
|
||||
Path: wrapperspb.String("something"),
|
||||
@@ -667,7 +667,7 @@ func TestCreate(t *testing.T) {
|
||||
UpdatedTime: store.GetUpdateTime().GetTimestamp(),
|
||||
Scope: &scopepb.ScopeInfo{Id: prj.GetPublicId(), Type: prj.GetType(), ParentScopeId: prj.GetParentId()},
|
||||
Version: 1,
|
||||
Type: globals.VaultGenericLibrarySubtype.String(),
|
||||
Type: vault.GenericLibrarySubtype.String(),
|
||||
Attrs: &pb.CredentialLibrary_VaultGenericCredentialLibraryAttributes{
|
||||
VaultGenericCredentialLibraryAttributes: &pb.VaultCredentialLibraryAttributes{
|
||||
Path: wrapperspb.String("something"),
|
||||
@@ -692,7 +692,7 @@ func TestCreate(t *testing.T) {
|
||||
name: "Create a valid vault CredentialLibrary ssh_private_key type",
|
||||
req: &pbs.CreateCredentialLibraryRequest{Item: &pb.CredentialLibrary{
|
||||
CredentialStoreId: store.GetPublicId(),
|
||||
Type: globals.VaultGenericLibrarySubtype.String(),
|
||||
Type: vault.GenericLibrarySubtype.String(),
|
||||
Attrs: &pb.CredentialLibrary_VaultGenericCredentialLibraryAttributes{
|
||||
VaultGenericCredentialLibraryAttributes: &pb.VaultCredentialLibraryAttributes{
|
||||
Path: wrapperspb.String("something"),
|
||||
@@ -710,7 +710,7 @@ func TestCreate(t *testing.T) {
|
||||
UpdatedTime: store.GetUpdateTime().GetTimestamp(),
|
||||
Scope: &scopepb.ScopeInfo{Id: prj.GetPublicId(), Type: prj.GetType(), ParentScopeId: prj.GetParentId()},
|
||||
Version: 1,
|
||||
Type: globals.VaultGenericLibrarySubtype.String(),
|
||||
Type: vault.GenericLibrarySubtype.String(),
|
||||
Attrs: &pb.CredentialLibrary_VaultGenericCredentialLibraryAttributes{
|
||||
VaultGenericCredentialLibraryAttributes: &pb.VaultCredentialLibraryAttributes{
|
||||
Path: wrapperspb.String("something"),
|
||||
@@ -726,7 +726,7 @@ func TestCreate(t *testing.T) {
|
||||
name: "Create a valid vault CredentialLibrary ssh_private_key type with mapping",
|
||||
req: &pbs.CreateCredentialLibraryRequest{Item: &pb.CredentialLibrary{
|
||||
CredentialStoreId: store.GetPublicId(),
|
||||
Type: globals.VaultGenericLibrarySubtype.String(),
|
||||
Type: vault.GenericLibrarySubtype.String(),
|
||||
Attrs: &pb.CredentialLibrary_VaultGenericCredentialLibraryAttributes{
|
||||
VaultGenericCredentialLibraryAttributes: &pb.VaultCredentialLibraryAttributes{
|
||||
Path: wrapperspb.String("something"),
|
||||
@@ -754,7 +754,7 @@ func TestCreate(t *testing.T) {
|
||||
UpdatedTime: store.GetUpdateTime().GetTimestamp(),
|
||||
Scope: &scopepb.ScopeInfo{Id: prj.GetPublicId(), Type: prj.GetType(), ParentScopeId: prj.GetParentId()},
|
||||
Version: 1,
|
||||
Type: globals.VaultGenericLibrarySubtype.String(),
|
||||
Type: vault.GenericLibrarySubtype.String(),
|
||||
Attrs: &pb.CredentialLibrary_VaultGenericCredentialLibraryAttributes{
|
||||
VaultGenericCredentialLibraryAttributes: &pb.VaultCredentialLibraryAttributes{
|
||||
Path: wrapperspb.String("something"),
|
||||
@@ -780,7 +780,7 @@ func TestCreate(t *testing.T) {
|
||||
name: "Create a valid vault CredentialLibrary with the 'vault' subtype",
|
||||
req: &pbs.CreateCredentialLibraryRequest{Item: &pb.CredentialLibrary{
|
||||
CredentialStoreId: store.GetPublicId(),
|
||||
Type: globals.VaultGenericLibrarySubtype.String(),
|
||||
Type: vault.GenericLibrarySubtype.String(),
|
||||
Attrs: &pb.CredentialLibrary_VaultCredentialLibraryAttributes{
|
||||
VaultCredentialLibraryAttributes: &pb.VaultCredentialLibraryAttributes{
|
||||
Path: wrapperspb.String("something"),
|
||||
@@ -797,7 +797,7 @@ func TestCreate(t *testing.T) {
|
||||
UpdatedTime: store.GetUpdateTime().GetTimestamp(),
|
||||
Scope: &scopepb.ScopeInfo{Id: prj.GetPublicId(), Type: prj.GetType(), ParentScopeId: prj.GetParentId()},
|
||||
Version: 1,
|
||||
Type: globals.VaultGenericLibrarySubtype.String(),
|
||||
Type: vault.GenericLibrarySubtype.String(),
|
||||
Attrs: &pb.CredentialLibrary_VaultGenericCredentialLibraryAttributes{
|
||||
VaultGenericCredentialLibraryAttributes: &pb.VaultCredentialLibraryAttributes{
|
||||
Path: wrapperspb.String("something"),
|
||||
@@ -916,7 +916,7 @@ func TestGet(t *testing.T) {
|
||||
Id: unspecifiedLib.GetPublicId(),
|
||||
CredentialStoreId: unspecifiedLib.GetStoreId(),
|
||||
Scope: &scopepb.ScopeInfo{Id: store.GetProjectId(), Type: scope.Project.String(), ParentScopeId: prj.GetParentId()},
|
||||
Type: globals.VaultGenericLibrarySubtype.String(),
|
||||
Type: vault.GenericLibrarySubtype.String(),
|
||||
AuthorizedActions: testAuthorizedActions,
|
||||
CreatedTime: unspecifiedLib.CreateTime.GetTimestamp(),
|
||||
UpdatedTime: unspecifiedLib.UpdateTime.GetTimestamp(),
|
||||
@@ -938,7 +938,7 @@ func TestGet(t *testing.T) {
|
||||
Id: userPassLib.GetPublicId(),
|
||||
CredentialStoreId: userPassLib.GetStoreId(),
|
||||
Scope: &scopepb.ScopeInfo{Id: store.GetProjectId(), Type: scope.Project.String(), ParentScopeId: prj.GetParentId()},
|
||||
Type: globals.VaultGenericLibrarySubtype.String(),
|
||||
Type: vault.GenericLibrarySubtype.String(),
|
||||
AuthorizedActions: testAuthorizedActions,
|
||||
CreatedTime: userPassLib.CreateTime.GetTimestamp(),
|
||||
UpdatedTime: userPassLib.UpdateTime.GetTimestamp(),
|
||||
@@ -970,7 +970,7 @@ func TestGet(t *testing.T) {
|
||||
Id: sshPkLib.GetPublicId(),
|
||||
CredentialStoreId: sshPkLib.GetStoreId(),
|
||||
Scope: &scopepb.ScopeInfo{Id: store.GetProjectId(), Type: scope.Project.String(), ParentScopeId: prj.GetParentId()},
|
||||
Type: globals.VaultGenericLibrarySubtype.String(),
|
||||
Type: vault.GenericLibrarySubtype.String(),
|
||||
AuthorizedActions: testAuthorizedActions,
|
||||
CreatedTime: sshPkLib.CreateTime.GetTimestamp(),
|
||||
UpdatedTime: sshPkLib.UpdateTime.GetTimestamp(),
|
||||
@@ -1004,7 +1004,7 @@ func TestGet(t *testing.T) {
|
||||
CredentialStoreId: sshCertLib.GetStoreId(),
|
||||
CredentialType: sshCertLib.GetCredentialType(),
|
||||
Scope: &scopepb.ScopeInfo{Id: store.GetProjectId(), Type: scope.Project.String(), ParentScopeId: prj.GetParentId()},
|
||||
Type: globals.VaultSshCertificateLibrarySubtype.String(),
|
||||
Type: vault.SSHCertificateLibrarySubtype.String(),
|
||||
AuthorizedActions: testAuthorizedActions,
|
||||
CreatedTime: sshCertLib.CreateTime.GetTimestamp(),
|
||||
UpdatedTime: sshCertLib.UpdateTime.GetTimestamp(),
|
||||
@@ -1923,7 +1923,7 @@ func TestCreate_SSHCertificateCredentialLibrary(t *testing.T) {
|
||||
name: "missing vault path",
|
||||
req: &pbs.CreateCredentialLibraryRequest{Item: &pb.CredentialLibrary{
|
||||
CredentialStoreId: store.GetPublicId(),
|
||||
Type: globals.VaultSshCertificateLibrarySubtype.String(),
|
||||
Type: vault.SSHCertificateLibrarySubtype.String(),
|
||||
Attrs: &pb.CredentialLibrary_VaultSshCertificateCredentialLibraryAttributes{
|
||||
VaultSshCertificateCredentialLibraryAttributes: &pb.VaultSSHCertificateCredentialLibraryAttributes{
|
||||
Username: wrapperspb.String("username"),
|
||||
@@ -1937,7 +1937,7 @@ func TestCreate_SSHCertificateCredentialLibrary(t *testing.T) {
|
||||
name: "missing username",
|
||||
req: &pbs.CreateCredentialLibraryRequest{Item: &pb.CredentialLibrary{
|
||||
CredentialStoreId: store.GetPublicId(),
|
||||
Type: globals.VaultSshCertificateLibrarySubtype.String(),
|
||||
Type: vault.SSHCertificateLibrarySubtype.String(),
|
||||
Attrs: &pb.CredentialLibrary_VaultSshCertificateCredentialLibraryAttributes{
|
||||
VaultSshCertificateCredentialLibraryAttributes: &pb.VaultSSHCertificateCredentialLibraryAttributes{
|
||||
Path: wrapperspb.String("something"),
|
||||
@@ -1951,7 +1951,7 @@ func TestCreate_SSHCertificateCredentialLibrary(t *testing.T) {
|
||||
name: "Can't specify Id",
|
||||
req: &pbs.CreateCredentialLibraryRequest{Item: &pb.CredentialLibrary{
|
||||
CredentialStoreId: store.GetPublicId(),
|
||||
Type: globals.VaultSshCertificateLibrarySubtype.String(),
|
||||
Type: vault.SSHCertificateLibrarySubtype.String(),
|
||||
Id: globals.VaultSshCertificateCredentialLibraryPrefix + "_notallowed",
|
||||
Attrs: &pb.CredentialLibrary_VaultSshCertificateCredentialLibraryAttributes{
|
||||
VaultSshCertificateCredentialLibraryAttributes: &pb.VaultSSHCertificateCredentialLibraryAttributes{
|
||||
@@ -1967,7 +1967,7 @@ func TestCreate_SSHCertificateCredentialLibrary(t *testing.T) {
|
||||
name: "Can't specify Created Time",
|
||||
req: &pbs.CreateCredentialLibraryRequest{Item: &pb.CredentialLibrary{
|
||||
CredentialStoreId: store.GetPublicId(),
|
||||
Type: globals.VaultSshCertificateLibrarySubtype.String(),
|
||||
Type: vault.SSHCertificateLibrarySubtype.String(),
|
||||
CreatedTime: timestamppb.Now(),
|
||||
Attrs: &pb.CredentialLibrary_VaultSshCertificateCredentialLibraryAttributes{
|
||||
VaultSshCertificateCredentialLibraryAttributes: &pb.VaultSSHCertificateCredentialLibraryAttributes{
|
||||
@@ -1983,7 +1983,7 @@ func TestCreate_SSHCertificateCredentialLibrary(t *testing.T) {
|
||||
name: "Can't specify Update Time",
|
||||
req: &pbs.CreateCredentialLibraryRequest{Item: &pb.CredentialLibrary{
|
||||
CredentialStoreId: store.GetPublicId(),
|
||||
Type: globals.VaultSshCertificateLibrarySubtype.String(),
|
||||
Type: vault.SSHCertificateLibrarySubtype.String(),
|
||||
UpdatedTime: timestamppb.Now(),
|
||||
Attrs: &pb.CredentialLibrary_VaultSshCertificateCredentialLibraryAttributes{
|
||||
VaultSshCertificateCredentialLibraryAttributes: &pb.VaultSSHCertificateCredentialLibraryAttributes{
|
||||
@@ -2013,7 +2013,7 @@ func TestCreate_SSHCertificateCredentialLibrary(t *testing.T) {
|
||||
{
|
||||
name: "parent id must be included",
|
||||
req: &pbs.CreateCredentialLibraryRequest{Item: &pb.CredentialLibrary{
|
||||
Type: globals.VaultSshCertificateLibrarySubtype.String(),
|
||||
Type: vault.SSHCertificateLibrarySubtype.String(),
|
||||
Attrs: &pb.CredentialLibrary_VaultSshCertificateCredentialLibraryAttributes{
|
||||
VaultSshCertificateCredentialLibraryAttributes: &pb.VaultSSHCertificateCredentialLibraryAttributes{
|
||||
Path: wrapperspb.String("something"),
|
||||
@@ -2028,7 +2028,7 @@ func TestCreate_SSHCertificateCredentialLibrary(t *testing.T) {
|
||||
name: "Invalid credential type",
|
||||
req: &pbs.CreateCredentialLibraryRequest{Item: &pb.CredentialLibrary{
|
||||
CredentialStoreId: store.GetPublicId(),
|
||||
Type: globals.VaultSshCertificateLibrarySubtype.String(),
|
||||
Type: vault.SSHCertificateLibrarySubtype.String(),
|
||||
Attrs: &pb.CredentialLibrary_VaultSshCertificateCredentialLibraryAttributes{
|
||||
VaultSshCertificateCredentialLibraryAttributes: &pb.VaultSSHCertificateCredentialLibraryAttributes{
|
||||
Path: wrapperspb.String("something"),
|
||||
@@ -2044,7 +2044,7 @@ func TestCreate_SSHCertificateCredentialLibrary(t *testing.T) {
|
||||
name: "Invalid key type key bits combination",
|
||||
req: &pbs.CreateCredentialLibraryRequest{Item: &pb.CredentialLibrary{
|
||||
CredentialStoreId: store.GetPublicId(),
|
||||
Type: globals.VaultSshCertificateLibrarySubtype.String(),
|
||||
Type: vault.SSHCertificateLibrarySubtype.String(),
|
||||
Attrs: &pb.CredentialLibrary_VaultSshCertificateCredentialLibraryAttributes{
|
||||
VaultSshCertificateCredentialLibraryAttributes: &pb.VaultSSHCertificateCredentialLibraryAttributes{
|
||||
Path: wrapperspb.String("something"),
|
||||
@@ -2061,7 +2061,7 @@ func TestCreate_SSHCertificateCredentialLibrary(t *testing.T) {
|
||||
name: "Create a valid vault SSHCertificateCredentialLibrary",
|
||||
req: &pbs.CreateCredentialLibraryRequest{Item: &pb.CredentialLibrary{
|
||||
CredentialStoreId: store.GetPublicId(),
|
||||
Type: globals.VaultSshCertificateLibrarySubtype.String(),
|
||||
Type: vault.SSHCertificateLibrarySubtype.String(),
|
||||
Name: &wrapperspb.StringValue{Value: "name1"},
|
||||
Description: &wrapperspb.StringValue{Value: "desc"},
|
||||
Attrs: &pb.CredentialLibrary_VaultSshCertificateCredentialLibraryAttributes{
|
||||
@@ -2083,7 +2083,7 @@ func TestCreate_SSHCertificateCredentialLibrary(t *testing.T) {
|
||||
Description: &wrapperspb.StringValue{Value: "desc"},
|
||||
Scope: &scopepb.ScopeInfo{Id: prj.GetPublicId(), Type: prj.GetType(), ParentScopeId: prj.GetParentId()},
|
||||
Version: 1,
|
||||
Type: globals.VaultSshCertificateLibrarySubtype.String(),
|
||||
Type: vault.SSHCertificateLibrarySubtype.String(),
|
||||
Attrs: &pb.CredentialLibrary_VaultSshCertificateCredentialLibraryAttributes{
|
||||
VaultSshCertificateCredentialLibraryAttributes: &pb.VaultSSHCertificateCredentialLibraryAttributes{
|
||||
Path: wrapperspb.String("/ssh/sign/foo"),
|
||||
@@ -2100,7 +2100,7 @@ func TestCreate_SSHCertificateCredentialLibrary(t *testing.T) {
|
||||
name: "Seting key type ed25119 with key bits nil",
|
||||
req: &pbs.CreateCredentialLibraryRequest{Item: &pb.CredentialLibrary{
|
||||
CredentialStoreId: store.GetPublicId(),
|
||||
Type: globals.VaultSshCertificateLibrarySubtype.String(),
|
||||
Type: vault.SSHCertificateLibrarySubtype.String(),
|
||||
Name: &wrapperspb.StringValue{Value: "name2"},
|
||||
Attrs: &pb.CredentialLibrary_VaultSshCertificateCredentialLibraryAttributes{
|
||||
VaultSshCertificateCredentialLibraryAttributes: &pb.VaultSSHCertificateCredentialLibraryAttributes{
|
||||
@@ -2121,7 +2121,7 @@ func TestCreate_SSHCertificateCredentialLibrary(t *testing.T) {
|
||||
Name: &wrapperspb.StringValue{Value: "name2"},
|
||||
Scope: &scopepb.ScopeInfo{Id: prj.GetPublicId(), Type: prj.GetType(), ParentScopeId: prj.GetParentId()},
|
||||
Version: 1,
|
||||
Type: globals.VaultSshCertificateLibrarySubtype.String(),
|
||||
Type: vault.SSHCertificateLibrarySubtype.String(),
|
||||
Attrs: &pb.CredentialLibrary_VaultSshCertificateCredentialLibraryAttributes{
|
||||
VaultSshCertificateCredentialLibraryAttributes: &pb.VaultSSHCertificateCredentialLibraryAttributes{
|
||||
Path: wrapperspb.String("/ssh/sign/foo"),
|
||||
@@ -2138,7 +2138,7 @@ func TestCreate_SSHCertificateCredentialLibrary(t *testing.T) {
|
||||
name: "valid vault SSHCertificateCredentialLibrary with AdditionalValidPrincipals",
|
||||
req: &pbs.CreateCredentialLibraryRequest{Item: &pb.CredentialLibrary{
|
||||
CredentialStoreId: store.GetPublicId(),
|
||||
Type: globals.VaultSshCertificateLibrarySubtype.String(),
|
||||
Type: vault.SSHCertificateLibrarySubtype.String(),
|
||||
Name: &wrapperspb.StringValue{Value: "name"},
|
||||
Description: &wrapperspb.StringValue{Value: "desc"},
|
||||
Attrs: &pb.CredentialLibrary_VaultSshCertificateCredentialLibraryAttributes{
|
||||
@@ -2161,7 +2161,7 @@ func TestCreate_SSHCertificateCredentialLibrary(t *testing.T) {
|
||||
Description: &wrapperspb.StringValue{Value: "desc"},
|
||||
Scope: &scopepb.ScopeInfo{Id: prj.GetPublicId(), Type: prj.GetType(), ParentScopeId: prj.GetParentId()},
|
||||
Version: 1,
|
||||
Type: globals.VaultSshCertificateLibrarySubtype.String(),
|
||||
Type: vault.SSHCertificateLibrarySubtype.String(),
|
||||
Attrs: &pb.CredentialLibrary_VaultSshCertificateCredentialLibraryAttributes{
|
||||
VaultSshCertificateCredentialLibraryAttributes: &pb.VaultSSHCertificateCredentialLibraryAttributes{
|
||||
Path: wrapperspb.String("/ssh/sign/foo"),
|
||||
@@ -2292,7 +2292,7 @@ func TestUpdate_SSHCertificateCredentialLibrary(t *testing.T) {
|
||||
req: &pbs.UpdateCredentialLibraryRequest{
|
||||
UpdateMask: fieldmask(sshCertUsernameField),
|
||||
Item: &pb.CredentialLibrary{
|
||||
Type: globals.VaultSshCertificateLibrarySubtype.String(),
|
||||
Type: vault.SSHCertificateLibrarySubtype.String(),
|
||||
Attrs: &pb.CredentialLibrary_VaultSshCertificateCredentialLibraryAttributes{
|
||||
VaultSshCertificateCredentialLibraryAttributes: &pb.VaultSSHCertificateCredentialLibraryAttributes{
|
||||
Username: wrapperspb.String("changed-username"),
|
||||
@@ -2311,7 +2311,7 @@ func TestUpdate_SSHCertificateCredentialLibrary(t *testing.T) {
|
||||
req: &pbs.UpdateCredentialLibraryRequest{
|
||||
UpdateMask: fieldmask("attributes.key_type", "attributes.key_bits"),
|
||||
Item: &pb.CredentialLibrary{
|
||||
Type: globals.VaultSshCertificateLibrarySubtype.String(),
|
||||
Type: vault.SSHCertificateLibrarySubtype.String(),
|
||||
Attrs: &pb.CredentialLibrary_VaultSshCertificateCredentialLibraryAttributes{
|
||||
VaultSshCertificateCredentialLibraryAttributes: &pb.VaultSSHCertificateCredentialLibraryAttributes{
|
||||
KeyType: wrapperspb.String(vault.KeyTypeRsa),
|
||||
@@ -2332,7 +2332,7 @@ func TestUpdate_SSHCertificateCredentialLibrary(t *testing.T) {
|
||||
req: &pbs.UpdateCredentialLibraryRequest{
|
||||
UpdateMask: fieldmask(vaultPathField),
|
||||
Item: &pb.CredentialLibrary{
|
||||
Type: globals.VaultSshCertificateLibrarySubtype.String(),
|
||||
Type: vault.SSHCertificateLibrarySubtype.String(),
|
||||
Attrs: &pb.CredentialLibrary_VaultSshCertificateCredentialLibraryAttributes{
|
||||
VaultSshCertificateCredentialLibraryAttributes: &pb.VaultSSHCertificateCredentialLibraryAttributes{
|
||||
Path: wrapperspb.String("/ssh/issue/foo"),
|
||||
@@ -2351,7 +2351,7 @@ func TestUpdate_SSHCertificateCredentialLibrary(t *testing.T) {
|
||||
req: &pbs.UpdateCredentialLibraryRequest{
|
||||
UpdateMask: fieldmask("attributes.ttl", "attributes.key_id", "attributes.critical_options.some", "attributes.extensions.permity-pty"),
|
||||
Item: &pb.CredentialLibrary{
|
||||
Type: globals.VaultSshCertificateLibrarySubtype.String(),
|
||||
Type: vault.SSHCertificateLibrarySubtype.String(),
|
||||
Attrs: &pb.CredentialLibrary_VaultSshCertificateCredentialLibraryAttributes{
|
||||
VaultSshCertificateCredentialLibraryAttributes: &pb.VaultSSHCertificateCredentialLibraryAttributes{
|
||||
KeyId: wrapperspb.String("id"),
|
||||
@@ -2377,7 +2377,7 @@ func TestUpdate_SSHCertificateCredentialLibrary(t *testing.T) {
|
||||
req: &pbs.UpdateCredentialLibraryRequest{
|
||||
UpdateMask: fieldmask("attributes.critical_options", "attributes.extensions.permit-pty"),
|
||||
Item: &pb.CredentialLibrary{
|
||||
Type: globals.VaultSshCertificateLibrarySubtype.String(),
|
||||
Type: vault.SSHCertificateLibrarySubtype.String(),
|
||||
Attrs: &pb.CredentialLibrary_VaultSshCertificateCredentialLibraryAttributes{
|
||||
VaultSshCertificateCredentialLibraryAttributes: &pb.VaultSSHCertificateCredentialLibraryAttributes{
|
||||
CriticalOptions: nil,
|
||||
@@ -2399,7 +2399,7 @@ func TestUpdate_SSHCertificateCredentialLibrary(t *testing.T) {
|
||||
req: &pbs.UpdateCredentialLibraryRequest{
|
||||
UpdateMask: fieldmask("attributes.critical_options.option-b", "attributes.extensions"),
|
||||
Item: &pb.CredentialLibrary{
|
||||
Type: globals.VaultSshCertificateLibrarySubtype.String(),
|
||||
Type: vault.SSHCertificateLibrarySubtype.String(),
|
||||
Attrs: &pb.CredentialLibrary_VaultSshCertificateCredentialLibraryAttributes{
|
||||
VaultSshCertificateCredentialLibraryAttributes: &pb.VaultSSHCertificateCredentialLibraryAttributes{
|
||||
CriticalOptions: map[string]string{"option-b": "set-b"},
|
||||
@@ -2421,7 +2421,7 @@ func TestUpdate_SSHCertificateCredentialLibrary(t *testing.T) {
|
||||
UpdateMask: fieldmask("attributes.critical_options.option-a", "attributes.critical_options.option-b", "attributes.critical_options.option-c",
|
||||
"attributes.extensions.permit-pty", "attributes.extensions.permit-port-forwarding", "attributes.extensions.permit-X11-forwarding"),
|
||||
Item: &pb.CredentialLibrary{
|
||||
Type: globals.VaultSshCertificateLibrarySubtype.String(),
|
||||
Type: vault.SSHCertificateLibrarySubtype.String(),
|
||||
Attrs: &pb.CredentialLibrary_VaultSshCertificateCredentialLibraryAttributes{
|
||||
VaultSshCertificateCredentialLibraryAttributes: &pb.VaultSSHCertificateCredentialLibraryAttributes{
|
||||
CriticalOptions: map[string]string{"option-a": "set-a", "option-b": "set-b", "option-c": "set-c"},
|
||||
@@ -2536,7 +2536,7 @@ func TestUpdate_SSHCertificateCredentialLibrary(t *testing.T) {
|
||||
req: &pbs.UpdateCredentialLibraryRequest{
|
||||
UpdateMask: fieldmask(keyBitsField, keyTypeField),
|
||||
Item: &pb.CredentialLibrary{
|
||||
Type: globals.VaultSshCertificateLibrarySubtype.String(),
|
||||
Type: vault.SSHCertificateLibrarySubtype.String(),
|
||||
Attrs: &pb.CredentialLibrary_VaultSshCertificateCredentialLibraryAttributes{
|
||||
VaultSshCertificateCredentialLibraryAttributes: &pb.VaultSSHCertificateCredentialLibraryAttributes{
|
||||
KeyType: wrapperspb.String(vault.KeyTypeEcdsa),
|
||||
@@ -2552,7 +2552,7 @@ func TestUpdate_SSHCertificateCredentialLibrary(t *testing.T) {
|
||||
req: &pbs.UpdateCredentialLibraryRequest{
|
||||
UpdateMask: fieldmask(keyTypeField),
|
||||
Item: &pb.CredentialLibrary{
|
||||
Type: globals.VaultSshCertificateLibrarySubtype.String(),
|
||||
Type: vault.SSHCertificateLibrarySubtype.String(),
|
||||
Attrs: &pb.CredentialLibrary_VaultSshCertificateCredentialLibraryAttributes{
|
||||
VaultSshCertificateCredentialLibraryAttributes: &pb.VaultSSHCertificateCredentialLibraryAttributes{
|
||||
KeyType: wrapperspb.String("unknown-type"),
|
||||
@@ -2567,7 +2567,7 @@ func TestUpdate_SSHCertificateCredentialLibrary(t *testing.T) {
|
||||
req: &pbs.UpdateCredentialLibraryRequest{
|
||||
UpdateMask: fieldmask(keyBitsField),
|
||||
Item: &pb.CredentialLibrary{
|
||||
Type: globals.VaultSshCertificateLibrarySubtype.String(),
|
||||
Type: vault.SSHCertificateLibrarySubtype.String(),
|
||||
Attrs: &pb.CredentialLibrary_VaultSshCertificateCredentialLibraryAttributes{
|
||||
VaultSshCertificateCredentialLibraryAttributes: &pb.VaultSSHCertificateCredentialLibraryAttributes{
|
||||
KeyBits: wrapperspb.UInt32(1234),
|
||||
|
||||
@@ -346,7 +346,7 @@ func (s Service) getFromRepo(ctx context.Context, id string) (credential.Static,
|
||||
func (s Service) createInRepo(ctx context.Context, scopeId string, item *pb.Credential) (credential.Static, error) {
|
||||
const op = "credentials.(Service).createInRepo"
|
||||
switch item.GetType() {
|
||||
case globals.UsernamePasswordSubtype.String():
|
||||
case credential.UsernamePasswordSubtype.String():
|
||||
cred, err := toUsernamePasswordStorageCredential(ctx, item.GetCredentialStoreId(), item)
|
||||
if err != nil {
|
||||
return nil, errors.Wrap(ctx, err, op)
|
||||
@@ -363,7 +363,7 @@ func (s Service) createInRepo(ctx context.Context, scopeId string, item *pb.Cred
|
||||
return nil, handlers.ApiErrorWithCodeAndMessage(codes.Internal, "Unable to create credential but no error returned from repository.")
|
||||
}
|
||||
return out, nil
|
||||
case globals.SshPrivateKeySubtype.String():
|
||||
case credential.SshPrivateKeySubtype.String():
|
||||
cred, err := toSshPrivateKeyStorageCredential(ctx, item.GetCredentialStoreId(), item)
|
||||
if err != nil {
|
||||
return nil, errors.Wrap(ctx, err, op)
|
||||
@@ -380,7 +380,7 @@ func (s Service) createInRepo(ctx context.Context, scopeId string, item *pb.Cred
|
||||
return nil, handlers.ApiErrorWithCodeAndMessage(codes.Internal, "Unable to create credential but no error returned from repository.")
|
||||
}
|
||||
return out, nil
|
||||
case globals.JsonSubtype.String():
|
||||
case credential.JsonSubtype.String():
|
||||
cred, err := toJsonStorageCredential(ctx, item.GetCredentialStoreId(), item)
|
||||
if err != nil {
|
||||
return nil, errors.Wrap(ctx, err, op)
|
||||
@@ -414,7 +414,7 @@ func (s Service) updateInRepo(
|
||||
item := proto.Clone(in).(*pb.Credential)
|
||||
|
||||
switch subtypes.SubtypeFromId(domain, id) {
|
||||
case globals.UsernamePasswordSubtype:
|
||||
case credential.UsernamePasswordSubtype:
|
||||
dbMasks = append(dbMasks, upMaskManager.Translate(masks)...)
|
||||
if len(dbMasks) == 0 {
|
||||
return nil, handlers.InvalidArgumentErrorf("No valid fields included in the update mask.", map[string]string{"update_mask": "No valid fields provided in the update mask."})
|
||||
@@ -438,7 +438,7 @@ func (s Service) updateInRepo(
|
||||
}
|
||||
return out, nil
|
||||
|
||||
case globals.SshPrivateKeySubtype:
|
||||
case credential.SshPrivateKeySubtype:
|
||||
dbMasks = append(dbMasks, spkMaskManager.Translate(masks)...)
|
||||
if len(dbMasks) == 0 {
|
||||
return nil, handlers.InvalidArgumentErrorf("No valid fields included in the update mask.", map[string]string{"update_mask": "No valid fields provided in the update mask."})
|
||||
@@ -472,7 +472,7 @@ func (s Service) updateInRepo(
|
||||
}
|
||||
return out, nil
|
||||
|
||||
case globals.JsonSubtype:
|
||||
case credential.JsonSubtype:
|
||||
dbMasks = append(dbMasks, jsonMaskManager.Translate(masks, "attributes", "object")...)
|
||||
if len(dbMasks) == 0 {
|
||||
return nil, handlers.InvalidArgumentErrorf("No valid fields included in the update mask.", map[string]string{"update_mask": "No valid fields provided in the update mask."})
|
||||
@@ -585,11 +585,11 @@ func toProto(in credential.Static, opt ...handlers.Option) (*pb.Credential, erro
|
||||
if outputFields.Has(globals.TypeField) {
|
||||
switch in.(type) {
|
||||
case *static.UsernamePasswordCredential:
|
||||
out.Type = globals.UsernamePasswordSubtype.String()
|
||||
out.Type = credential.UsernamePasswordSubtype.String()
|
||||
case *static.SshPrivateKeyCredential:
|
||||
out.Type = globals.SshPrivateKeySubtype.String()
|
||||
out.Type = credential.SshPrivateKeySubtype.String()
|
||||
case *static.JsonCredential:
|
||||
out.Type = globals.JsonSubtype.String()
|
||||
out.Type = credential.JsonSubtype.String()
|
||||
}
|
||||
}
|
||||
if outputFields.Has(globals.DescriptionField) && in.GetDescription() != "" {
|
||||
@@ -752,7 +752,7 @@ func validateCreateRequest(req *pbs.CreateCredentialRequest) error {
|
||||
}
|
||||
|
||||
switch req.Item.GetType() {
|
||||
case globals.UsernamePasswordSubtype.String():
|
||||
case credential.UsernamePasswordSubtype.String():
|
||||
if req.Item.GetUsernamePasswordAttributes().GetUsername().GetValue() == "" {
|
||||
badFields[usernameField] = "Field required for creating a username-password credential."
|
||||
}
|
||||
@@ -760,7 +760,7 @@ func validateCreateRequest(req *pbs.CreateCredentialRequest) error {
|
||||
badFields[passwordField] = "Field required for creating a username-password credential."
|
||||
}
|
||||
|
||||
case globals.SshPrivateKeySubtype.String():
|
||||
case credential.SshPrivateKeySubtype.String():
|
||||
if req.Item.GetSshPrivateKeyAttributes().GetUsername().GetValue() == "" {
|
||||
badFields[usernameField] = "Field required for creating an SSH private key credential."
|
||||
}
|
||||
@@ -789,7 +789,7 @@ func validateCreateRequest(req *pbs.CreateCredentialRequest) error {
|
||||
}
|
||||
}
|
||||
|
||||
case globals.JsonSubtype.String():
|
||||
case credential.JsonSubtype.String():
|
||||
object := req.GetItem().GetJsonAttributes().GetObject()
|
||||
if object == nil || len(object.AsMap()) <= 0 {
|
||||
badFields[objectField] = "This is a required field and cannot be set to empty."
|
||||
@@ -809,7 +809,7 @@ func validateUpdateRequest(req *pbs.UpdateCredentialRequest) error {
|
||||
return handlers.ValidateUpdateRequest(req, req.GetItem(), func() map[string]string {
|
||||
badFields := map[string]string{}
|
||||
switch subtypes.SubtypeFromId(domain, req.GetId()) {
|
||||
case globals.UsernamePasswordSubtype:
|
||||
case credential.UsernamePasswordSubtype:
|
||||
attrs := req.GetItem().GetUsernamePasswordAttributes()
|
||||
if handlers.MaskContains(req.GetUpdateMask().GetPaths(), usernameField) && attrs.GetUsername().GetValue() == "" {
|
||||
badFields[usernameField] = "This is a required field and cannot be set to empty."
|
||||
@@ -818,7 +818,7 @@ func validateUpdateRequest(req *pbs.UpdateCredentialRequest) error {
|
||||
badFields[passwordField] = "This is a required field and cannot be set to empty."
|
||||
}
|
||||
|
||||
case globals.SshPrivateKeySubtype:
|
||||
case credential.SshPrivateKeySubtype:
|
||||
attrs := req.GetItem().GetSshPrivateKeyAttributes()
|
||||
if handlers.MaskContains(req.GetUpdateMask().GetPaths(), usernameField) && attrs.GetUsername().GetValue() == "" {
|
||||
badFields[usernameField] = "This is a required field and cannot be set to empty."
|
||||
@@ -850,7 +850,7 @@ func validateUpdateRequest(req *pbs.UpdateCredentialRequest) error {
|
||||
}
|
||||
}
|
||||
|
||||
case globals.JsonSubtype:
|
||||
case credential.JsonSubtype:
|
||||
if handlers.MaskContainsPrefix(req.GetUpdateMask().GetPaths(), objectField) {
|
||||
object := req.GetItem().GetJsonAttributes().GetObject()
|
||||
if object == nil || len(object.AsMap()) <= 0 {
|
||||
|
||||
@@ -78,7 +78,7 @@ func TestList(t *testing.T) {
|
||||
CreatedTime: c.GetCreateTime().GetTimestamp(),
|
||||
UpdatedTime: c.GetUpdateTime().GetTimestamp(),
|
||||
Version: c.GetVersion(),
|
||||
Type: globals.UsernamePasswordSubtype.String(),
|
||||
Type: credential.UsernamePasswordSubtype.String(),
|
||||
AuthorizedActions: testAuthorizedActions,
|
||||
Attrs: &pb.Credential_UsernamePasswordAttributes{
|
||||
UsernamePasswordAttributes: &pb.UsernamePasswordAttributes{
|
||||
@@ -98,7 +98,7 @@ func TestList(t *testing.T) {
|
||||
CreatedTime: spk.GetCreateTime().GetTimestamp(),
|
||||
UpdatedTime: spk.GetUpdateTime().GetTimestamp(),
|
||||
Version: spk.GetVersion(),
|
||||
Type: globals.SshPrivateKeySubtype.String(),
|
||||
Type: credential.SshPrivateKeySubtype.String(),
|
||||
AuthorizedActions: testAuthorizedActions,
|
||||
Attrs: &pb.Credential_SshPrivateKeyAttributes{
|
||||
SshPrivateKeyAttributes: &pb.SshPrivateKeyAttributes{
|
||||
@@ -120,7 +120,7 @@ func TestList(t *testing.T) {
|
||||
CreatedTime: credJson.GetCreateTime().GetTimestamp(),
|
||||
UpdatedTime: credJson.GetUpdateTime().GetTimestamp(),
|
||||
Version: credJson.GetVersion(),
|
||||
Type: globals.JsonSubtype.String(),
|
||||
Type: credential.JsonSubtype.String(),
|
||||
AuthorizedActions: testAuthorizedActions,
|
||||
Attrs: &pb.Credential_JsonAttributes{
|
||||
JsonAttributes: &pb.JsonAttributes{
|
||||
@@ -264,7 +264,7 @@ func TestGet(t *testing.T) {
|
||||
Id: upCred.GetPublicId(),
|
||||
CredentialStoreId: upCred.GetStoreId(),
|
||||
Scope: &scopepb.ScopeInfo{Id: store.GetProjectId(), Type: scope.Project.String(), ParentScopeId: prj.GetParentId()},
|
||||
Type: globals.UsernamePasswordSubtype.String(),
|
||||
Type: credential.UsernamePasswordSubtype.String(),
|
||||
AuthorizedActions: testAuthorizedActions,
|
||||
CreatedTime: upCred.CreateTime.GetTimestamp(),
|
||||
UpdatedTime: upCred.UpdateTime.GetTimestamp(),
|
||||
@@ -286,7 +286,7 @@ func TestGet(t *testing.T) {
|
||||
Id: upCredPrev.GetPublicId(),
|
||||
CredentialStoreId: upCred.GetStoreId(),
|
||||
Scope: &scopepb.ScopeInfo{Id: store.GetProjectId(), Type: scope.Project.String(), ParentScopeId: prj.GetParentId()},
|
||||
Type: globals.UsernamePasswordSubtype.String(),
|
||||
Type: credential.UsernamePasswordSubtype.String(),
|
||||
AuthorizedActions: testAuthorizedActions,
|
||||
CreatedTime: upCredPrev.CreateTime.GetTimestamp(),
|
||||
UpdatedTime: upCredPrev.UpdateTime.GetTimestamp(),
|
||||
@@ -308,7 +308,7 @@ func TestGet(t *testing.T) {
|
||||
Id: spkCred.GetPublicId(),
|
||||
CredentialStoreId: spkCred.GetStoreId(),
|
||||
Scope: &scopepb.ScopeInfo{Id: store.GetProjectId(), Type: scope.Project.String(), ParentScopeId: prj.GetParentId()},
|
||||
Type: globals.SshPrivateKeySubtype.String(),
|
||||
Type: credential.SshPrivateKeySubtype.String(),
|
||||
AuthorizedActions: testAuthorizedActions,
|
||||
CreatedTime: spkCred.CreateTime.GetTimestamp(),
|
||||
UpdatedTime: spkCred.UpdateTime.GetTimestamp(),
|
||||
@@ -330,7 +330,7 @@ func TestGet(t *testing.T) {
|
||||
Id: spkCredWithPass.GetPublicId(),
|
||||
CredentialStoreId: spkCredWithPass.GetStoreId(),
|
||||
Scope: &scopepb.ScopeInfo{Id: store.GetProjectId(), Type: scope.Project.String(), ParentScopeId: prj.GetParentId()},
|
||||
Type: globals.SshPrivateKeySubtype.String(),
|
||||
Type: credential.SshPrivateKeySubtype.String(),
|
||||
AuthorizedActions: testAuthorizedActions,
|
||||
CreatedTime: spkCredWithPass.CreateTime.GetTimestamp(),
|
||||
UpdatedTime: spkCredWithPass.UpdateTime.GetTimestamp(),
|
||||
@@ -353,7 +353,7 @@ func TestGet(t *testing.T) {
|
||||
Id: jsonCred.GetPublicId(),
|
||||
CredentialStoreId: jsonCred.GetStoreId(),
|
||||
Scope: &scopepb.ScopeInfo{Id: store.GetProjectId(), Type: scope.Project.String(), ParentScopeId: prj.GetParentId()},
|
||||
Type: globals.JsonSubtype.String(),
|
||||
Type: credential.JsonSubtype.String(),
|
||||
AuthorizedActions: testAuthorizedActions,
|
||||
CreatedTime: jsonCred.CreateTime.GetTimestamp(),
|
||||
UpdatedTime: jsonCred.UpdateTime.GetTimestamp(),
|
||||
@@ -511,7 +511,7 @@ func TestCreate(t *testing.T) {
|
||||
req: &pbs.CreateCredentialRequest{Item: &pb.Credential{
|
||||
CredentialStoreId: store.GetPublicId(),
|
||||
Id: globals.UsernamePasswordCredentialPrefix + "_notallowed",
|
||||
Type: globals.UsernamePasswordSubtype.String(),
|
||||
Type: credential.UsernamePasswordSubtype.String(),
|
||||
Attrs: &pb.Credential_UsernamePasswordAttributes{
|
||||
UsernamePasswordAttributes: &pb.UsernamePasswordAttributes{
|
||||
Username: wrapperspb.String("username"),
|
||||
@@ -526,7 +526,7 @@ func TestCreate(t *testing.T) {
|
||||
name: "Invalid Credential Store Id",
|
||||
req: &pbs.CreateCredentialRequest{Item: &pb.Credential{
|
||||
CredentialStoreId: "p_invalidid",
|
||||
Type: globals.UsernamePasswordSubtype.String(),
|
||||
Type: credential.UsernamePasswordSubtype.String(),
|
||||
Attrs: &pb.Credential_UsernamePasswordAttributes{
|
||||
UsernamePasswordAttributes: &pb.UsernamePasswordAttributes{
|
||||
Username: wrapperspb.String("username"),
|
||||
@@ -542,7 +542,7 @@ func TestCreate(t *testing.T) {
|
||||
req: &pbs.CreateCredentialRequest{Item: &pb.Credential{
|
||||
CredentialStoreId: store.GetPublicId(),
|
||||
CreatedTime: timestamppb.Now(),
|
||||
Type: globals.UsernamePasswordSubtype.String(),
|
||||
Type: credential.UsernamePasswordSubtype.String(),
|
||||
Attrs: &pb.Credential_UsernamePasswordAttributes{
|
||||
UsernamePasswordAttributes: &pb.UsernamePasswordAttributes{
|
||||
Username: wrapperspb.String("username"),
|
||||
@@ -557,7 +557,7 @@ func TestCreate(t *testing.T) {
|
||||
req: &pbs.CreateCredentialRequest{Item: &pb.Credential{
|
||||
CredentialStoreId: store.GetPublicId(),
|
||||
UpdatedTime: timestamppb.Now(),
|
||||
Type: globals.UsernamePasswordSubtype.String(),
|
||||
Type: credential.UsernamePasswordSubtype.String(),
|
||||
Attrs: &pb.Credential_UsernamePasswordAttributes{
|
||||
UsernamePasswordAttributes: &pb.UsernamePasswordAttributes{
|
||||
Username: wrapperspb.String("username"),
|
||||
@@ -586,7 +586,7 @@ func TestCreate(t *testing.T) {
|
||||
name: "Must provide username",
|
||||
req: &pbs.CreateCredentialRequest{Item: &pb.Credential{
|
||||
CredentialStoreId: store.GetPublicId(),
|
||||
Type: globals.UsernamePasswordSubtype.String(),
|
||||
Type: credential.UsernamePasswordSubtype.String(),
|
||||
Attrs: &pb.Credential_UsernamePasswordAttributes{
|
||||
UsernamePasswordAttributes: &pb.UsernamePasswordAttributes{
|
||||
Password: wrapperspb.String("password"),
|
||||
@@ -600,7 +600,7 @@ func TestCreate(t *testing.T) {
|
||||
name: "Must provide password",
|
||||
req: &pbs.CreateCredentialRequest{Item: &pb.Credential{
|
||||
CredentialStoreId: store.GetPublicId(),
|
||||
Type: globals.UsernamePasswordSubtype.String(),
|
||||
Type: credential.UsernamePasswordSubtype.String(),
|
||||
Attrs: &pb.Credential_UsernamePasswordAttributes{
|
||||
UsernamePasswordAttributes: &pb.UsernamePasswordAttributes{
|
||||
Username: wrapperspb.String("username"),
|
||||
@@ -614,7 +614,7 @@ func TestCreate(t *testing.T) {
|
||||
name: "Must provide private key",
|
||||
req: &pbs.CreateCredentialRequest{Item: &pb.Credential{
|
||||
CredentialStoreId: store.GetPublicId(),
|
||||
Type: globals.SshPrivateKeySubtype.String(),
|
||||
Type: credential.SshPrivateKeySubtype.String(),
|
||||
Attrs: &pb.Credential_SshPrivateKeyAttributes{
|
||||
SshPrivateKeyAttributes: &pb.SshPrivateKeyAttributes{
|
||||
Username: wrapperspb.String("username"),
|
||||
@@ -628,7 +628,7 @@ func TestCreate(t *testing.T) {
|
||||
name: "Must provide json secret",
|
||||
req: &pbs.CreateCredentialRequest{Item: &pb.Credential{
|
||||
CredentialStoreId: store.GetPublicId(),
|
||||
Type: globals.JsonSubtype.String(),
|
||||
Type: credential.JsonSubtype.String(),
|
||||
Attrs: &pb.Credential_JsonAttributes{
|
||||
JsonAttributes: &pb.JsonAttributes{},
|
||||
},
|
||||
@@ -640,7 +640,7 @@ func TestCreate(t *testing.T) {
|
||||
name: "valid-up",
|
||||
req: &pbs.CreateCredentialRequest{Item: &pb.Credential{
|
||||
CredentialStoreId: store.GetPublicId(),
|
||||
Type: globals.UsernamePasswordSubtype.String(),
|
||||
Type: credential.UsernamePasswordSubtype.String(),
|
||||
Attrs: &pb.Credential_UsernamePasswordAttributes{
|
||||
UsernamePasswordAttributes: &pb.UsernamePasswordAttributes{
|
||||
Username: wrapperspb.String("username"),
|
||||
@@ -658,7 +658,7 @@ func TestCreate(t *testing.T) {
|
||||
UpdatedTime: store.GetUpdateTime().GetTimestamp(),
|
||||
Scope: &scopepb.ScopeInfo{Id: prj.GetPublicId(), Type: prj.GetType(), ParentScopeId: prj.GetParentId()},
|
||||
Version: 1,
|
||||
Type: globals.UsernamePasswordSubtype.String(),
|
||||
Type: credential.UsernamePasswordSubtype.String(),
|
||||
AuthorizedActions: testAuthorizedActions,
|
||||
},
|
||||
},
|
||||
@@ -667,7 +667,7 @@ func TestCreate(t *testing.T) {
|
||||
name: "valid-spk",
|
||||
req: &pbs.CreateCredentialRequest{Item: &pb.Credential{
|
||||
CredentialStoreId: store.GetPublicId(),
|
||||
Type: globals.SshPrivateKeySubtype.String(),
|
||||
Type: credential.SshPrivateKeySubtype.String(),
|
||||
Attrs: &pb.Credential_SshPrivateKeyAttributes{
|
||||
SshPrivateKeyAttributes: &pb.SshPrivateKeyAttributes{
|
||||
Username: wrapperspb.String("username"),
|
||||
@@ -685,7 +685,7 @@ func TestCreate(t *testing.T) {
|
||||
UpdatedTime: store.GetUpdateTime().GetTimestamp(),
|
||||
Scope: &scopepb.ScopeInfo{Id: prj.GetPublicId(), Type: prj.GetType(), ParentScopeId: prj.GetParentId()},
|
||||
Version: 1,
|
||||
Type: globals.SshPrivateKeySubtype.String(),
|
||||
Type: credential.SshPrivateKeySubtype.String(),
|
||||
AuthorizedActions: testAuthorizedActions,
|
||||
},
|
||||
},
|
||||
@@ -694,7 +694,7 @@ func TestCreate(t *testing.T) {
|
||||
name: "valid-spk-with-passphrase",
|
||||
req: &pbs.CreateCredentialRequest{Item: &pb.Credential{
|
||||
CredentialStoreId: store.GetPublicId(),
|
||||
Type: globals.SshPrivateKeySubtype.String(),
|
||||
Type: credential.SshPrivateKeySubtype.String(),
|
||||
Attrs: &pb.Credential_SshPrivateKeyAttributes{
|
||||
SshPrivateKeyAttributes: &pb.SshPrivateKeyAttributes{
|
||||
Username: wrapperspb.String("username"),
|
||||
@@ -713,7 +713,7 @@ func TestCreate(t *testing.T) {
|
||||
UpdatedTime: store.GetUpdateTime().GetTimestamp(),
|
||||
Scope: &scopepb.ScopeInfo{Id: prj.GetPublicId(), Type: prj.GetType(), ParentScopeId: prj.GetParentId()},
|
||||
Version: 1,
|
||||
Type: globals.SshPrivateKeySubtype.String(),
|
||||
Type: credential.SshPrivateKeySubtype.String(),
|
||||
AuthorizedActions: testAuthorizedActions,
|
||||
},
|
||||
},
|
||||
@@ -722,7 +722,7 @@ func TestCreate(t *testing.T) {
|
||||
name: "valid-json",
|
||||
req: &pbs.CreateCredentialRequest{Item: &pb.Credential{
|
||||
CredentialStoreId: store.GetPublicId(),
|
||||
Type: globals.JsonSubtype.String(),
|
||||
Type: credential.JsonSubtype.String(),
|
||||
Attrs: &pb.Credential_JsonAttributes{
|
||||
JsonAttributes: &pb.JsonAttributes{
|
||||
Object: obj.Struct,
|
||||
@@ -739,7 +739,7 @@ func TestCreate(t *testing.T) {
|
||||
UpdatedTime: store.GetUpdateTime().GetTimestamp(),
|
||||
Scope: &scopepb.ScopeInfo{Id: prj.GetPublicId(), Type: prj.GetType(), ParentScopeId: prj.GetParentId()},
|
||||
Version: 1,
|
||||
Type: globals.JsonSubtype.String(),
|
||||
Type: credential.JsonSubtype.String(),
|
||||
AuthorizedActions: testAuthorizedActions,
|
||||
},
|
||||
},
|
||||
@@ -779,7 +779,7 @@ func TestCreate(t *testing.T) {
|
||||
require.NoError(err)
|
||||
|
||||
switch tc.req.Item.Type {
|
||||
case globals.UsernamePasswordSubtype.String():
|
||||
case credential.UsernamePasswordSubtype.String():
|
||||
password := tc.req.GetItem().GetUsernamePasswordAttributes().GetPassword().GetValue()
|
||||
hm, err := crypto.HmacSha256(ctx, []byte(password), databaseWrapper, []byte(store.GetPublicId()), nil, crypto.WithEd25519())
|
||||
require.NoError(err)
|
||||
@@ -790,7 +790,7 @@ func TestCreate(t *testing.T) {
|
||||
assert.Equal(base64.RawURLEncoding.EncodeToString([]byte(hm)), got.GetItem().GetUsernamePasswordAttributes().GetPasswordHmac())
|
||||
assert.Empty(got.GetItem().GetUsernamePasswordAttributes().GetPassword())
|
||||
|
||||
case globals.SshPrivateKeySubtype.String():
|
||||
case credential.SshPrivateKeySubtype.String():
|
||||
pk := tc.req.GetItem().GetSshPrivateKeyAttributes().GetPrivateKey().GetValue()
|
||||
hm, err := crypto.HmacSha256(ctx, []byte(pk), databaseWrapper, []byte(store.GetPublicId()), nil)
|
||||
require.NoError(err)
|
||||
@@ -809,7 +809,7 @@ func TestCreate(t *testing.T) {
|
||||
assert.Empty(got.GetItem().GetSshPrivateKeyAttributes().GetPrivateKeyPassphrase())
|
||||
}
|
||||
|
||||
case globals.JsonSubtype.String():
|
||||
case credential.JsonSubtype.String():
|
||||
hm, err := crypto.HmacSha256(ctx, objBytes, databaseWrapper, []byte(store.GetPublicId()), nil)
|
||||
require.NoError(err)
|
||||
|
||||
|
||||
@@ -395,7 +395,7 @@ func (s Service) getFromRepo(ctx context.Context, id string) (credential.Store,
|
||||
const op = "credentialstores.(Service).getFromRepo"
|
||||
|
||||
switch subtypes.SubtypeFromId(domain, id) {
|
||||
case globals.VaultSubtype:
|
||||
case vault.Subtype:
|
||||
repo, err := s.vaultRepoFn()
|
||||
if err != nil {
|
||||
return nil, errors.Wrap(ctx, err, op)
|
||||
@@ -408,7 +408,7 @@ func (s Service) getFromRepo(ctx context.Context, id string) (credential.Store,
|
||||
return cs, nil
|
||||
}
|
||||
|
||||
case globals.StaticSubtype:
|
||||
case static.Subtype:
|
||||
repo, err := s.staticRepoFn()
|
||||
if err != nil {
|
||||
return nil, errors.Wrap(ctx, err, op)
|
||||
@@ -429,7 +429,7 @@ func (s Service) createInRepo(ctx context.Context, projId string, item *pb.Crede
|
||||
const op = "credentialstores.(Service).createInRepo"
|
||||
|
||||
switch item.Type {
|
||||
case globals.VaultSubtype.String():
|
||||
case vault.Subtype.String():
|
||||
cs, err := toStorageVaultStore(ctx, projId, item)
|
||||
if err != nil {
|
||||
return nil, errors.Wrap(ctx, err, op)
|
||||
@@ -444,7 +444,7 @@ func (s Service) createInRepo(ctx context.Context, projId string, item *pb.Crede
|
||||
}
|
||||
return out, nil
|
||||
|
||||
case globals.StaticSubtype.String():
|
||||
case static.Subtype.String():
|
||||
cs, err := toStorageStaticStore(ctx, projId, item)
|
||||
if err != nil {
|
||||
return nil, errors.Wrap(ctx, err, op)
|
||||
@@ -476,7 +476,7 @@ func (s Service) updateInRepo(ctx context.Context, projId, id string, mask []str
|
||||
}
|
||||
|
||||
switch subtypes.SubtypeFromId(domain, id) {
|
||||
case globals.VaultSubtype:
|
||||
case vault.Subtype:
|
||||
cs, err := toStorageVaultStore(ctx, projId, item)
|
||||
if err != nil {
|
||||
return nil, errors.Wrap(ctx, err, op)
|
||||
@@ -492,7 +492,7 @@ func (s Service) updateInRepo(ctx context.Context, projId, id string, mask []str
|
||||
return nil, errors.Wrap(ctx, err, op, errors.WithMsg("unable to update credential store"))
|
||||
}
|
||||
|
||||
case globals.StaticSubtype:
|
||||
case static.Subtype:
|
||||
cs, err := toStorageStaticStore(ctx, projId, item)
|
||||
if err != nil {
|
||||
return nil, errors.Wrap(ctx, err, op)
|
||||
@@ -519,7 +519,7 @@ func (s Service) deleteFromRepo(ctx context.Context, id string) (bool, error) {
|
||||
var rows int
|
||||
|
||||
switch subtypes.SubtypeFromId(domain, id) {
|
||||
case globals.VaultSubtype:
|
||||
case vault.Subtype:
|
||||
repo, err := s.vaultRepoFn()
|
||||
if err != nil {
|
||||
return false, err
|
||||
@@ -532,7 +532,7 @@ func (s Service) deleteFromRepo(ctx context.Context, id string) (bool, error) {
|
||||
return false, errors.Wrap(ctx, err, op, errors.WithMsg("unable to delete credential store"))
|
||||
}
|
||||
|
||||
case globals.StaticSubtype:
|
||||
case static.Subtype:
|
||||
repo, err := s.staticRepoFn()
|
||||
if err != nil {
|
||||
return false, err
|
||||
@@ -582,7 +582,7 @@ func (s Service) authResult(ctx context.Context, id string, a action.Type) auth.
|
||||
}
|
||||
default:
|
||||
switch subtypes.SubtypeFromId(domain, id) {
|
||||
case globals.VaultSubtype:
|
||||
case vault.Subtype:
|
||||
cs, err := vaultRepo.LookupCredentialStore(ctx, id)
|
||||
if err != nil {
|
||||
res.Error = err
|
||||
@@ -594,7 +594,7 @@ func (s Service) authResult(ctx context.Context, id string, a action.Type) auth.
|
||||
}
|
||||
parentId = cs.GetProjectId()
|
||||
|
||||
case globals.StaticSubtype:
|
||||
case static.Subtype:
|
||||
var err error
|
||||
cs, err := staticRepo.LookupCredentialStore(ctx, id)
|
||||
if err != nil {
|
||||
@@ -658,7 +658,7 @@ func toProto(ctx context.Context, in credential.Store, opt ...handlers.Option) (
|
||||
}
|
||||
if outputFields.Has(globals.AttributesField) {
|
||||
switch subtypes.SubtypeFromId(domain, in.GetPublicId()) {
|
||||
case globals.VaultSubtype:
|
||||
case vault.Subtype:
|
||||
vaultIn, ok := in.(*vault.CredentialStore)
|
||||
if !ok {
|
||||
return nil, errors.New(ctx, errors.Internal, op, "unable to cast to vault credential store")
|
||||
@@ -791,7 +791,7 @@ func validateCreateRequest(ctx context.Context, req *pbs.CreateCredentialStoreRe
|
||||
badFields["scope_id"] = "This field must be a valid project scope id."
|
||||
}
|
||||
switch subtypes.SubtypeFromType(domain, req.GetItem().GetType()) {
|
||||
case globals.VaultSubtype:
|
||||
case vault.Subtype:
|
||||
attrs := req.GetItem().GetVaultCredentialStoreAttributes()
|
||||
if attrs == nil {
|
||||
badFields[globals.AttributesField] = "Attributes are required for creating a vault credential store"
|
||||
@@ -828,7 +828,7 @@ func validateCreateRequest(ctx context.Context, req *pbs.CreateCredentialStoreRe
|
||||
if len(cs) > 0 && pk == nil {
|
||||
badFields[clientCertField] = "Cannot set a client certificate without a private key."
|
||||
}
|
||||
case globals.StaticSubtype:
|
||||
case static.Subtype:
|
||||
// No additional validation required for static credential store
|
||||
default:
|
||||
badFields[globals.TypeField] = "This is a required field and must be a known credential store type."
|
||||
@@ -841,8 +841,8 @@ func validateUpdateRequest(ctx context.Context, req *pbs.UpdateCredentialStoreRe
|
||||
return handlers.ValidateUpdateRequest(req, req.GetItem(), func() map[string]string {
|
||||
badFields := map[string]string{}
|
||||
switch subtypes.SubtypeFromId(domain, req.GetId()) {
|
||||
case globals.VaultSubtype:
|
||||
if req.GetItem().GetType() != "" && subtypes.SubtypeFromType(domain, req.GetItem().GetType()) != globals.VaultSubtype {
|
||||
case vault.Subtype:
|
||||
if req.GetItem().GetType() != "" && subtypes.SubtypeFromType(domain, req.GetItem().GetType()) != vault.Subtype {
|
||||
badFields["type"] = "Cannot modify resource type."
|
||||
}
|
||||
attrs := req.GetItem().GetVaultCredentialStoreAttributes()
|
||||
@@ -904,10 +904,10 @@ func calculateAuthorizedCollectionActions(ctx context.Context, authResults auth.
|
||||
var collectionActions map[string]*structpb.ListValue
|
||||
var err error
|
||||
switch subtypes.SubtypeFromId(domain, id) {
|
||||
case globals.VaultSubtype:
|
||||
case vault.Subtype:
|
||||
collectionActions, err = auth.CalculateAuthorizedCollectionActions(ctx, authResults, vaultCollectionTypeMap, authResults.Scope.Id, id)
|
||||
|
||||
case globals.StaticSubtype:
|
||||
case static.Subtype:
|
||||
collectionActions, err = auth.CalculateAuthorizedCollectionActions(ctx, authResults, staticCollectionTypeMap, authResults.Scope.Id, id)
|
||||
}
|
||||
if err != nil {
|
||||
|
||||
+27
-27
@@ -92,7 +92,7 @@ func TestList(t *testing.T) {
|
||||
CreatedTime: s.GetCreateTime().GetTimestamp(),
|
||||
UpdatedTime: s.GetUpdateTime().GetTimestamp(),
|
||||
Version: s.GetVersion(),
|
||||
Type: globals.VaultSubtype.String(),
|
||||
Type: vault.Subtype.String(),
|
||||
AuthorizedActions: testAuthorizedActions,
|
||||
AuthorizedCollectionActions: testAuthorizedVaultCollectionActions,
|
||||
Attrs: &pb.CredentialStore_VaultCredentialStoreAttributes{
|
||||
@@ -116,7 +116,7 @@ func TestList(t *testing.T) {
|
||||
CreatedTime: s.GetCreateTime().GetTimestamp(),
|
||||
UpdatedTime: s.GetUpdateTime().GetTimestamp(),
|
||||
Version: s.GetVersion(),
|
||||
Type: globals.StaticSubtype.String(),
|
||||
Type: credstatic.Subtype.String(),
|
||||
AuthorizedActions: testAuthorizedActions,
|
||||
AuthorizedCollectionActions: testAuthorizedStaticCollectionActions,
|
||||
})
|
||||
@@ -257,7 +257,7 @@ func TestCreateVault(t *testing.T) {
|
||||
name: "missing ca certificate",
|
||||
req: &pbs.CreateCredentialStoreRequest{Item: &pb.CredentialStore{
|
||||
ScopeId: prj.GetPublicId(),
|
||||
Type: globals.VaultSubtype.String(),
|
||||
Type: vault.Subtype.String(),
|
||||
Attrs: &pb.CredentialStore_VaultCredentialStoreAttributes{
|
||||
VaultCredentialStoreAttributes: &pb.VaultCredentialStoreAttributes{
|
||||
Address: wrapperspb.String(v.Addr),
|
||||
@@ -274,7 +274,7 @@ func TestCreateVault(t *testing.T) {
|
||||
name: "Bad token",
|
||||
req: &pbs.CreateCredentialStoreRequest{Item: &pb.CredentialStore{
|
||||
ScopeId: prj.GetPublicId(),
|
||||
Type: globals.VaultSubtype.String(),
|
||||
Type: vault.Subtype.String(),
|
||||
Attrs: &pb.CredentialStore_VaultCredentialStoreAttributes{
|
||||
VaultCredentialStoreAttributes: &pb.VaultCredentialStoreAttributes{
|
||||
Address: wrapperspb.String(v.Addr),
|
||||
@@ -292,7 +292,7 @@ func TestCreateVault(t *testing.T) {
|
||||
name: "Define only client cert",
|
||||
req: &pbs.CreateCredentialStoreRequest{Item: &pb.CredentialStore{
|
||||
ScopeId: prj.GetPublicId(),
|
||||
Type: globals.VaultSubtype.String(),
|
||||
Type: vault.Subtype.String(),
|
||||
Attrs: &pb.CredentialStore_VaultCredentialStoreAttributes{
|
||||
VaultCredentialStoreAttributes: &pb.VaultCredentialStoreAttributes{
|
||||
Address: wrapperspb.String(v.Addr),
|
||||
@@ -309,7 +309,7 @@ func TestCreateVault(t *testing.T) {
|
||||
name: "Define only client cert key",
|
||||
req: &pbs.CreateCredentialStoreRequest{Item: &pb.CredentialStore{
|
||||
ScopeId: prj.GetPublicId(),
|
||||
Type: globals.VaultSubtype.String(),
|
||||
Type: vault.Subtype.String(),
|
||||
Attrs: &pb.CredentialStore_VaultCredentialStoreAttributes{
|
||||
VaultCredentialStoreAttributes: &pb.VaultCredentialStoreAttributes{
|
||||
Address: wrapperspb.String(v.Addr),
|
||||
@@ -326,7 +326,7 @@ func TestCreateVault(t *testing.T) {
|
||||
name: "Define key in both client cert payload and key field",
|
||||
req: &pbs.CreateCredentialStoreRequest{Item: &pb.CredentialStore{
|
||||
ScopeId: prj.GetPublicId(),
|
||||
Type: globals.VaultSubtype.String(),
|
||||
Type: vault.Subtype.String(),
|
||||
Attrs: &pb.CredentialStore_VaultCredentialStoreAttributes{
|
||||
VaultCredentialStoreAttributes: &pb.VaultCredentialStoreAttributes{
|
||||
Address: wrapperspb.String(v.Addr),
|
||||
@@ -345,7 +345,7 @@ func TestCreateVault(t *testing.T) {
|
||||
req: &pbs.CreateCredentialStoreRequest{Item: &pb.CredentialStore{
|
||||
ScopeId: prj.GetPublicId(),
|
||||
Id: globals.VaultCredentialStorePrefix + "_notallowed",
|
||||
Type: globals.VaultSubtype.String(),
|
||||
Type: vault.Subtype.String(),
|
||||
Attrs: &pb.CredentialStore_VaultCredentialStoreAttributes{
|
||||
VaultCredentialStoreAttributes: &pb.VaultCredentialStoreAttributes{
|
||||
Address: wrapperspb.String(v.Addr),
|
||||
@@ -361,7 +361,7 @@ func TestCreateVault(t *testing.T) {
|
||||
req: &pbs.CreateCredentialStoreRequest{Item: &pb.CredentialStore{
|
||||
ScopeId: prj.GetPublicId(),
|
||||
CreatedTime: timestamppb.Now(),
|
||||
Type: globals.VaultSubtype.String(),
|
||||
Type: vault.Subtype.String(),
|
||||
Attrs: &pb.CredentialStore_VaultCredentialStoreAttributes{
|
||||
VaultCredentialStoreAttributes: &pb.VaultCredentialStoreAttributes{
|
||||
Address: wrapperspb.String(v.Addr),
|
||||
@@ -377,7 +377,7 @@ func TestCreateVault(t *testing.T) {
|
||||
req: &pbs.CreateCredentialStoreRequest{Item: &pb.CredentialStore{
|
||||
ScopeId: prj.GetPublicId(),
|
||||
UpdatedTime: timestamppb.Now(),
|
||||
Type: globals.VaultSubtype.String(),
|
||||
Type: vault.Subtype.String(),
|
||||
Attrs: &pb.CredentialStore_VaultCredentialStoreAttributes{
|
||||
VaultCredentialStoreAttributes: &pb.VaultCredentialStoreAttributes{
|
||||
Address: wrapperspb.String(v.Addr),
|
||||
@@ -392,7 +392,7 @@ func TestCreateVault(t *testing.T) {
|
||||
name: "Can't specify worker filter",
|
||||
req: &pbs.CreateCredentialStoreRequest{Item: &pb.CredentialStore{
|
||||
ScopeId: prj.GetPublicId(),
|
||||
Type: globals.VaultSubtype.String(),
|
||||
Type: vault.Subtype.String(),
|
||||
Attrs: &pb.CredentialStore_VaultCredentialStoreAttributes{
|
||||
VaultCredentialStoreAttributes: &pb.VaultCredentialStoreAttributes{
|
||||
Address: wrapperspb.String(v.Addr),
|
||||
@@ -424,7 +424,7 @@ func TestCreateVault(t *testing.T) {
|
||||
name: "Must specify vault VaultAddress",
|
||||
req: &pbs.CreateCredentialStoreRequest{Item: &pb.CredentialStore{
|
||||
ScopeId: prj.GetPublicId(),
|
||||
Type: globals.VaultSubtype.String(),
|
||||
Type: vault.Subtype.String(),
|
||||
Attrs: &pb.CredentialStore_VaultCredentialStoreAttributes{
|
||||
VaultCredentialStoreAttributes: &pb.VaultCredentialStoreAttributes{
|
||||
Token: wrapperspb.String(newToken()),
|
||||
@@ -438,7 +438,7 @@ func TestCreateVault(t *testing.T) {
|
||||
name: "Must specify vault token",
|
||||
req: &pbs.CreateCredentialStoreRequest{Item: &pb.CredentialStore{
|
||||
ScopeId: prj.GetPublicId(),
|
||||
Type: globals.VaultSubtype.String(),
|
||||
Type: vault.Subtype.String(),
|
||||
Attrs: &pb.CredentialStore_VaultCredentialStoreAttributes{
|
||||
VaultCredentialStoreAttributes: &pb.VaultCredentialStoreAttributes{
|
||||
Address: wrapperspb.String(v.Addr),
|
||||
@@ -452,7 +452,7 @@ func TestCreateVault(t *testing.T) {
|
||||
name: "Create a valid vault CredentialStore with client cert and key in same field",
|
||||
req: &pbs.CreateCredentialStoreRequest{Item: &pb.CredentialStore{
|
||||
ScopeId: prj.GetPublicId(),
|
||||
Type: globals.VaultSubtype.String(),
|
||||
Type: vault.Subtype.String(),
|
||||
Attrs: &pb.CredentialStore_VaultCredentialStoreAttributes{
|
||||
VaultCredentialStoreAttributes: &pb.VaultCredentialStoreAttributes{
|
||||
Address: wrapperspb.String(v.Addr),
|
||||
@@ -469,7 +469,7 @@ func TestCreateVault(t *testing.T) {
|
||||
ScopeId: prj.GetPublicId(),
|
||||
Scope: &scopepb.ScopeInfo{Id: prj.GetPublicId(), Type: prj.GetType(), ParentScopeId: prj.GetParentId()},
|
||||
Version: 1,
|
||||
Type: globals.VaultSubtype.String(),
|
||||
Type: vault.Subtype.String(),
|
||||
Attrs: &pb.CredentialStore_VaultCredentialStoreAttributes{
|
||||
VaultCredentialStoreAttributes: &pb.VaultCredentialStoreAttributes{
|
||||
CaCert: wrapperspb.String(string(v.CaCert)),
|
||||
@@ -491,7 +491,7 @@ func TestCreateVault(t *testing.T) {
|
||||
ScopeId: prj.GetPublicId(),
|
||||
Name: &wrapperspb.StringValue{Value: "name"},
|
||||
Description: &wrapperspb.StringValue{Value: "desc"},
|
||||
Type: globals.VaultSubtype.String(),
|
||||
Type: vault.Subtype.String(),
|
||||
Attrs: &pb.CredentialStore_VaultCredentialStoreAttributes{
|
||||
VaultCredentialStoreAttributes: &pb.VaultCredentialStoreAttributes{
|
||||
Address: wrapperspb.String(v.Addr),
|
||||
@@ -511,7 +511,7 @@ func TestCreateVault(t *testing.T) {
|
||||
Description: &wrapperspb.StringValue{Value: "desc"},
|
||||
Scope: &scopepb.ScopeInfo{Id: prj.GetPublicId(), Type: prj.GetType(), ParentScopeId: prj.GetParentId()},
|
||||
Version: 1,
|
||||
Type: globals.VaultSubtype.String(),
|
||||
Type: vault.Subtype.String(),
|
||||
Attrs: &pb.CredentialStore_VaultCredentialStoreAttributes{
|
||||
VaultCredentialStoreAttributes: &pb.VaultCredentialStoreAttributes{
|
||||
CaCert: wrapperspb.String(string(v.CaCert)),
|
||||
@@ -629,7 +629,7 @@ func TestCreateStatic(t *testing.T) {
|
||||
req: &pbs.CreateCredentialStoreRequest{Item: &pb.CredentialStore{
|
||||
ScopeId: prj.GetPublicId(),
|
||||
Id: globals.StaticCredentialStorePrefix + "_notallowed",
|
||||
Type: globals.StaticSubtype.String(),
|
||||
Type: credstatic.Subtype.String(),
|
||||
}},
|
||||
res: nil,
|
||||
err: handlers.ApiErrorWithCode(codes.InvalidArgument),
|
||||
@@ -639,7 +639,7 @@ func TestCreateStatic(t *testing.T) {
|
||||
req: &pbs.CreateCredentialStoreRequest{Item: &pb.CredentialStore{
|
||||
ScopeId: prj.GetPublicId(),
|
||||
CreatedTime: timestamppb.Now(),
|
||||
Type: globals.StaticSubtype.String(),
|
||||
Type: credstatic.Subtype.String(),
|
||||
}},
|
||||
res: nil,
|
||||
err: handlers.ApiErrorWithCode(codes.InvalidArgument),
|
||||
@@ -649,7 +649,7 @@ func TestCreateStatic(t *testing.T) {
|
||||
req: &pbs.CreateCredentialStoreRequest{Item: &pb.CredentialStore{
|
||||
ScopeId: prj.GetPublicId(),
|
||||
UpdatedTime: timestamppb.Now(),
|
||||
Type: globals.StaticSubtype.String(),
|
||||
Type: credstatic.Subtype.String(),
|
||||
}},
|
||||
res: nil,
|
||||
err: handlers.ApiErrorWithCode(codes.InvalidArgument),
|
||||
@@ -666,7 +666,7 @@ func TestCreateStatic(t *testing.T) {
|
||||
name: "Create a valid static CredentialStore",
|
||||
req: &pbs.CreateCredentialStoreRequest{Item: &pb.CredentialStore{
|
||||
ScopeId: prj.GetPublicId(),
|
||||
Type: globals.StaticSubtype.String(),
|
||||
Type: credstatic.Subtype.String(),
|
||||
}},
|
||||
idPrefix: globals.StaticCredentialStorePrefix + "_",
|
||||
res: &pbs.CreateCredentialStoreResponse{
|
||||
@@ -675,7 +675,7 @@ func TestCreateStatic(t *testing.T) {
|
||||
ScopeId: prj.GetPublicId(),
|
||||
Scope: &scopepb.ScopeInfo{Id: prj.GetPublicId(), Type: prj.GetType(), ParentScopeId: prj.GetParentId()},
|
||||
Version: 1,
|
||||
Type: globals.StaticSubtype.String(),
|
||||
Type: credstatic.Subtype.String(),
|
||||
AuthorizedActions: testAuthorizedActions,
|
||||
AuthorizedCollectionActions: testAuthorizedStaticCollectionActions,
|
||||
},
|
||||
@@ -687,7 +687,7 @@ func TestCreateStatic(t *testing.T) {
|
||||
ScopeId: prj.GetPublicId(),
|
||||
Name: &wrapperspb.StringValue{Value: "name"},
|
||||
Description: &wrapperspb.StringValue{Value: "desc"},
|
||||
Type: globals.StaticSubtype.String(),
|
||||
Type: credstatic.Subtype.String(),
|
||||
}},
|
||||
idPrefix: globals.StaticCredentialStorePrefix + "_",
|
||||
res: &pbs.CreateCredentialStoreResponse{
|
||||
@@ -696,7 +696,7 @@ func TestCreateStatic(t *testing.T) {
|
||||
ScopeId: prj.GetPublicId(),
|
||||
Scope: &scopepb.ScopeInfo{Id: prj.GetPublicId(), Type: prj.GetType(), ParentScopeId: prj.GetParentId()},
|
||||
Version: 1,
|
||||
Type: globals.StaticSubtype.String(),
|
||||
Type: credstatic.Subtype.String(),
|
||||
AuthorizedActions: testAuthorizedActions,
|
||||
Name: &wrapperspb.StringValue{Value: "name"},
|
||||
Description: &wrapperspb.StringValue{Value: "desc"},
|
||||
@@ -791,7 +791,7 @@ func TestGet(t *testing.T) {
|
||||
Id: vaultStore.GetPublicId(),
|
||||
ScopeId: vaultStore.GetProjectId(),
|
||||
Scope: &scopepb.ScopeInfo{Id: vaultStore.GetProjectId(), Type: scope.Project.String(), ParentScopeId: prj.GetParentId()},
|
||||
Type: globals.VaultSubtype.String(),
|
||||
Type: vault.Subtype.String(),
|
||||
AuthorizedActions: testAuthorizedActions,
|
||||
AuthorizedCollectionActions: testAuthorizedVaultCollectionActions,
|
||||
CreatedTime: vaultStore.CreateTime.GetTimestamp(),
|
||||
@@ -817,7 +817,7 @@ func TestGet(t *testing.T) {
|
||||
Id: staticStore.GetPublicId(),
|
||||
ScopeId: staticStore.GetProjectId(),
|
||||
Scope: &scopepb.ScopeInfo{Id: staticStore.GetProjectId(), Type: scope.Project.String(), ParentScopeId: prj.GetParentId()},
|
||||
Type: globals.StaticSubtype.String(),
|
||||
Type: credstatic.Subtype.String(),
|
||||
AuthorizedActions: testAuthorizedActions,
|
||||
AuthorizedCollectionActions: testAuthorizedStaticCollectionActions,
|
||||
CreatedTime: staticStore.CreateTime.GetTimestamp(),
|
||||
@@ -834,7 +834,7 @@ func TestGet(t *testing.T) {
|
||||
Id: staticStorePrev.GetPublicId(),
|
||||
ScopeId: staticStorePrev.GetProjectId(),
|
||||
Scope: &scopepb.ScopeInfo{Id: staticStorePrev.GetProjectId(), Type: scope.Project.String(), ParentScopeId: prj.GetParentId()},
|
||||
Type: globals.StaticSubtype.String(),
|
||||
Type: credstatic.Subtype.String(),
|
||||
AuthorizedActions: testAuthorizedActions,
|
||||
AuthorizedCollectionActions: testAuthorizedStaticCollectionActions,
|
||||
CreatedTime: staticStorePrev.CreateTime.GetTimestamp(),
|
||||
|
||||
@@ -57,12 +57,12 @@ var (
|
||||
action.List,
|
||||
}
|
||||
|
||||
collectionTypeMap = map[globals.Subtype]map[resource.Type]action.ActionSet{
|
||||
globals.StaticSubtype: {
|
||||
collectionTypeMap = map[subtypes.Subtype]map[resource.Type]action.ActionSet{
|
||||
static.Subtype: {
|
||||
resource.HostSet: host_sets.CollectionActions,
|
||||
resource.Host: hosts.CollectionActions,
|
||||
},
|
||||
globals.PluginSubtype: {
|
||||
hostplugin.Subtype: {
|
||||
resource.HostSet: host_sets.CollectionActions,
|
||||
resource.Host: action.ActionSet{
|
||||
action.List,
|
||||
@@ -183,12 +183,12 @@ func (s Service) ListHostCatalogs(ctx context.Context, req *pbs.ListHostCatalogs
|
||||
outputOpts = append(outputOpts, handlers.WithAuthorizedActions(authorizedActions))
|
||||
}
|
||||
if outputFields.Has(globals.AuthorizedCollectionActionsField) {
|
||||
var subtype globals.Subtype
|
||||
var subtype subtypes.Subtype
|
||||
switch item.(type) {
|
||||
case *static.HostCatalog:
|
||||
subtype = globals.StaticSubtype
|
||||
subtype = static.Subtype
|
||||
case *hostplugin.HostCatalog:
|
||||
subtype = globals.PluginSubtype
|
||||
subtype = hostplugin.Subtype
|
||||
}
|
||||
if subtype != "" {
|
||||
collectionActions, err := auth.CalculateAuthorizedCollectionActions(ctx, authResults, collectionTypeMap[subtype], authResults.Scope.Id, item.GetPublicId())
|
||||
@@ -253,12 +253,12 @@ func (s Service) GetHostCatalog(ctx context.Context, req *pbs.GetHostCatalogRequ
|
||||
outputOpts = append(outputOpts, handlers.WithAuthorizedActions(authResults.FetchActionSetForId(ctx, hc.GetPublicId(), IdActions).Strings()))
|
||||
}
|
||||
if outputFields.Has(globals.AuthorizedCollectionActionsField) {
|
||||
var subtype globals.Subtype
|
||||
var subtype subtypes.Subtype
|
||||
switch hc.(type) {
|
||||
case *static.HostCatalog:
|
||||
subtype = globals.StaticSubtype
|
||||
subtype = static.Subtype
|
||||
case *hostplugin.HostCatalog:
|
||||
subtype = globals.PluginSubtype
|
||||
subtype = hostplugin.Subtype
|
||||
}
|
||||
if subtype != "" {
|
||||
collectionActions, err := auth.CalculateAuthorizedCollectionActions(ctx, authResults, collectionTypeMap[subtype], authResults.Scope.Id, hc.GetPublicId())
|
||||
@@ -310,12 +310,12 @@ func (s Service) CreateHostCatalog(ctx context.Context, req *pbs.CreateHostCatal
|
||||
outputOpts = append(outputOpts, handlers.WithAuthorizedActions(authResults.FetchActionSetForId(ctx, hc.GetPublicId(), IdActions).Strings()))
|
||||
}
|
||||
if outputFields.Has(globals.AuthorizedCollectionActionsField) {
|
||||
var subtype globals.Subtype
|
||||
var subtype subtypes.Subtype
|
||||
switch hc.(type) {
|
||||
case *static.HostCatalog:
|
||||
subtype = globals.StaticSubtype
|
||||
subtype = static.Subtype
|
||||
case *hostplugin.HostCatalog:
|
||||
subtype = globals.PluginSubtype
|
||||
subtype = hostplugin.Subtype
|
||||
}
|
||||
if subtype != "" {
|
||||
collectionActions, err := auth.CalculateAuthorizedCollectionActions(ctx, authResults, collectionTypeMap[subtype], authResults.Scope.Id, hc.GetPublicId())
|
||||
@@ -373,12 +373,12 @@ func (s Service) UpdateHostCatalog(ctx context.Context, req *pbs.UpdateHostCatal
|
||||
outputOpts = append(outputOpts, handlers.WithAuthorizedActions(authResults.FetchActionSetForId(ctx, hc.GetPublicId(), IdActions).Strings()))
|
||||
}
|
||||
if outputFields.Has(globals.AuthorizedCollectionActionsField) {
|
||||
var subtype globals.Subtype
|
||||
var subtype subtypes.Subtype
|
||||
switch hc.(type) {
|
||||
case *static.HostCatalog:
|
||||
subtype = globals.StaticSubtype
|
||||
subtype = static.Subtype
|
||||
case *hostplugin.HostCatalog:
|
||||
subtype = globals.PluginSubtype
|
||||
subtype = hostplugin.Subtype
|
||||
}
|
||||
if subtype != "" {
|
||||
collectionActions, err := auth.CalculateAuthorizedCollectionActions(ctx, authResults, collectionTypeMap[subtype], authResults.Scope.Id, hc.GetPublicId())
|
||||
@@ -416,7 +416,7 @@ func (s Service) getFromRepo(ctx context.Context, id string) (host.Catalog, *plu
|
||||
var plg *plugins.PluginInfo
|
||||
var cat host.Catalog
|
||||
switch subtypes.SubtypeFromId(domain, id) {
|
||||
case globals.StaticSubtype:
|
||||
case static.Subtype:
|
||||
repo, err := s.staticRepoFn()
|
||||
if err != nil {
|
||||
return nil, nil, err
|
||||
@@ -429,7 +429,7 @@ func (s Service) getFromRepo(ctx context.Context, id string) (host.Catalog, *plu
|
||||
return nil, nil, handlers.NotFoundErrorf("Host Catalog %q doesn't exist.", id)
|
||||
}
|
||||
cat = hc
|
||||
case globals.PluginSubtype:
|
||||
case hostplugin.Subtype:
|
||||
repo, err := s.pluginHostRepoFn()
|
||||
if err != nil {
|
||||
return nil, nil, err
|
||||
@@ -538,7 +538,7 @@ func (s Service) createPluginInRepo(ctx context.Context, projId string, req *pbs
|
||||
func (s Service) createInRepo(ctx context.Context, projId string, req *pbs.CreateHostCatalogRequest) (hc host.Catalog, info *plugins.PluginInfo, err error) {
|
||||
var plg *plugins.PluginInfo
|
||||
switch subtypes.SubtypeFromType(domain, req.GetItem().GetType()) {
|
||||
case globals.StaticSubtype:
|
||||
case static.Subtype:
|
||||
hc, err = s.createStaticInRepo(ctx, projId, req.GetItem())
|
||||
default:
|
||||
hc, plg, err = s.createPluginInRepo(ctx, projId, req)
|
||||
@@ -602,9 +602,9 @@ func (s Service) updatePluginInRepo(ctx context.Context, projId, id string, mask
|
||||
func (s Service) updateInRepo(ctx context.Context, projId string, req *pbs.UpdateHostCatalogRequest) (hc host.Catalog, plg *plugins.PluginInfo, err error) {
|
||||
const op = "host_catalogs.(Service).updateInRepo"
|
||||
switch subtypes.SubtypeFromId(domain, req.GetId()) {
|
||||
case globals.StaticSubtype:
|
||||
case static.Subtype:
|
||||
hc, err = s.updateStaticInRepo(ctx, projId, req.GetId(), req.GetUpdateMask().GetPaths(), req.GetItem())
|
||||
case globals.PluginSubtype:
|
||||
case hostplugin.Subtype:
|
||||
hc, plg, err = s.updatePluginInRepo(ctx, projId, req.GetId(), req.GetUpdateMask().GetPaths(), req.GetItem())
|
||||
}
|
||||
return
|
||||
@@ -614,7 +614,7 @@ func (s Service) deleteFromRepo(ctx context.Context, id string) (bool, error) {
|
||||
const op = "host_catalogs.(Service).deleteFromRepo"
|
||||
rows := 0
|
||||
switch subtypes.SubtypeFromId(domain, id) {
|
||||
case globals.StaticSubtype:
|
||||
case static.Subtype:
|
||||
repo, err := s.staticRepoFn()
|
||||
if err != nil {
|
||||
return false, errors.Wrap(ctx, err, op)
|
||||
@@ -623,7 +623,7 @@ func (s Service) deleteFromRepo(ctx context.Context, id string) (bool, error) {
|
||||
if err != nil {
|
||||
return false, errors.Wrap(ctx, err, op, errors.WithMsg("unable to delete host"))
|
||||
}
|
||||
case globals.PluginSubtype:
|
||||
case hostplugin.Subtype:
|
||||
repo, err := s.pluginHostRepoFn()
|
||||
if err != nil {
|
||||
return false, errors.Wrap(ctx, err, op)
|
||||
@@ -660,7 +660,7 @@ func (s Service) authResult(ctx context.Context, id string, a action.Type) auth.
|
||||
}
|
||||
default:
|
||||
switch subtypes.SubtypeFromId(domain, id) {
|
||||
case globals.StaticSubtype:
|
||||
case static.Subtype:
|
||||
repo, err := s.staticRepoFn()
|
||||
if err != nil {
|
||||
res.Error = err
|
||||
@@ -677,7 +677,7 @@ func (s Service) authResult(ctx context.Context, id string, a action.Type) auth.
|
||||
}
|
||||
parentId = cat.GetProjectId()
|
||||
opts = append(opts, auth.WithId(id))
|
||||
case globals.PluginSubtype:
|
||||
case hostplugin.Subtype:
|
||||
repo, err := s.pluginHostRepoFn()
|
||||
if err != nil {
|
||||
res.Error = err
|
||||
@@ -729,9 +729,9 @@ func toProto(ctx context.Context, in host.Catalog, opt ...handlers.Option) (*pb.
|
||||
if outputFields.Has(globals.TypeField) {
|
||||
switch in.(type) {
|
||||
case *static.HostCatalog:
|
||||
out.Type = globals.StaticSubtype.String()
|
||||
out.Type = static.Subtype.String()
|
||||
case *hostplugin.HostCatalog:
|
||||
out.Type = globals.PluginSubtype.String()
|
||||
out.Type = hostplugin.Subtype.String()
|
||||
}
|
||||
}
|
||||
if outputFields.Has(globals.DescriptionField) && in.GetDescription() != "" {
|
||||
@@ -844,8 +844,8 @@ func validateCreateRequest(req *pbs.CreateHostCatalogRequest) error {
|
||||
badFields[globals.SecretsHmacField] = "This is a read only field."
|
||||
}
|
||||
switch subtypes.SubtypeFromType(domain, req.GetItem().GetType()) {
|
||||
case globals.StaticSubtype:
|
||||
case globals.PluginSubtype:
|
||||
case static.Subtype:
|
||||
case hostplugin.Subtype:
|
||||
if req.GetItem().GetPlugin() != nil {
|
||||
badFields[globals.PluginField] = "This is a read only field."
|
||||
}
|
||||
@@ -858,7 +858,7 @@ func validateCreateRequest(req *pbs.CreateHostCatalogRequest) error {
|
||||
badFields[globals.PluginNameField] = "Can't set the plugin id field along with this field."
|
||||
}
|
||||
default:
|
||||
badFields[globals.TypeField] = fmt.Sprintf("This is a required field and must be either %q or %q.", globals.StaticSubtype.String(), globals.PluginSubtype.String())
|
||||
badFields[globals.TypeField] = fmt.Sprintf("This is a required field and must be either %q or %q.", static.Subtype.String(), hostplugin.Subtype.String())
|
||||
}
|
||||
return badFields
|
||||
})
|
||||
@@ -871,15 +871,15 @@ func validateUpdateRequest(req *pbs.UpdateHostCatalogRequest) error {
|
||||
badFields[globals.SecretsHmacField] = "This is a read only field."
|
||||
}
|
||||
switch subtypes.SubtypeFromId(domain, req.GetId()) {
|
||||
case globals.StaticSubtype:
|
||||
if req.GetItem().GetType() != "" && subtypes.SubtypeFromType(domain, req.GetItem().GetType()) != globals.StaticSubtype {
|
||||
case static.Subtype:
|
||||
if req.GetItem().GetType() != "" && subtypes.SubtypeFromType(domain, req.GetItem().GetType()) != static.Subtype {
|
||||
badFields[globals.TypeField] = "Cannot modify resource type."
|
||||
}
|
||||
if req.GetItem().GetPlugin() != nil {
|
||||
badFields[globals.PluginField] = "This field is unused for this type of host catalog."
|
||||
}
|
||||
case globals.PluginSubtype:
|
||||
if req.GetItem().GetType() != "" && subtypes.SubtypeFromType(domain, req.GetItem().GetType()) != globals.PluginSubtype {
|
||||
case hostplugin.Subtype:
|
||||
if req.GetItem().GetType() != "" && subtypes.SubtypeFromType(domain, req.GetItem().GetType()) != hostplugin.Subtype {
|
||||
badFields[globals.TypeField] = "Cannot modify resource type."
|
||||
}
|
||||
if req.GetItem().GetPlugin() != nil {
|
||||
|
||||
@@ -28,6 +28,7 @@ import (
|
||||
"github.com/hashicorp/boundary/internal/plugin/loopback"
|
||||
"github.com/hashicorp/boundary/internal/scheduler"
|
||||
"github.com/hashicorp/boundary/internal/types/scope"
|
||||
"github.com/hashicorp/boundary/internal/types/subtypes"
|
||||
pb "github.com/hashicorp/boundary/sdk/pbs/controller/api/resources/hostcatalogs"
|
||||
"github.com/hashicorp/boundary/sdk/pbs/controller/api/resources/plugins"
|
||||
scopepb "github.com/hashicorp/boundary/sdk/pbs/controller/api/resources/scopes"
|
||||
@@ -45,8 +46,8 @@ import (
|
||||
"github.com/stretchr/testify/require"
|
||||
)
|
||||
|
||||
var authorizedCollectionActions = map[globals.Subtype]map[string]*structpb.ListValue{
|
||||
globals.StaticSubtype: {
|
||||
var authorizedCollectionActions = map[subtypes.Subtype]map[string]*structpb.ListValue{
|
||||
static.Subtype: {
|
||||
"host-sets": {
|
||||
Values: []*structpb.Value{
|
||||
structpb.NewStringValue("create"),
|
||||
@@ -60,7 +61,7 @@ var authorizedCollectionActions = map[globals.Subtype]map[string]*structpb.ListV
|
||||
},
|
||||
},
|
||||
},
|
||||
globals.PluginSubtype: {
|
||||
hostplugin.Subtype: {
|
||||
"host-sets": {
|
||||
Values: []*structpb.Value{
|
||||
structpb.NewStringValue("create"),
|
||||
@@ -112,7 +113,7 @@ func TestGet_Static(t *testing.T) {
|
||||
UpdatedTime: hc.UpdateTime.GetTimestamp(),
|
||||
Type: "static",
|
||||
AuthorizedActions: testAuthorizedActions,
|
||||
AuthorizedCollectionActions: authorizedCollectionActions[globals.StaticSubtype],
|
||||
AuthorizedCollectionActions: authorizedCollectionActions[static.Subtype],
|
||||
}
|
||||
|
||||
cases := []struct {
|
||||
@@ -214,9 +215,9 @@ func TestGet_Plugin(t *testing.T) {
|
||||
},
|
||||
CreatedTime: hc.CreateTime.GetTimestamp(),
|
||||
UpdatedTime: hc.UpdateTime.GetTimestamp(),
|
||||
Type: globals.PluginSubtype.String(),
|
||||
Type: hostplugin.Subtype.String(),
|
||||
AuthorizedActions: testAuthorizedActions,
|
||||
AuthorizedCollectionActions: authorizedCollectionActions[globals.PluginSubtype],
|
||||
AuthorizedCollectionActions: authorizedCollectionActions[hostplugin.Subtype],
|
||||
SecretsHmac: base58.Encode([]byte("foobar")),
|
||||
}
|
||||
|
||||
@@ -320,7 +321,7 @@ func TestList(t *testing.T) {
|
||||
Version: 1,
|
||||
Type: "static",
|
||||
AuthorizedActions: testAuthorizedActions,
|
||||
AuthorizedCollectionActions: authorizedCollectionActions[globals.StaticSubtype],
|
||||
AuthorizedCollectionActions: authorizedCollectionActions[static.Subtype],
|
||||
})
|
||||
}
|
||||
|
||||
@@ -342,9 +343,9 @@ func TestList(t *testing.T) {
|
||||
Description: plg.GetDescription(),
|
||||
},
|
||||
Version: 1,
|
||||
Type: globals.PluginSubtype.String(),
|
||||
Type: hostplugin.Subtype.String(),
|
||||
AuthorizedActions: testAuthorizedActions,
|
||||
AuthorizedCollectionActions: authorizedCollectionActions[globals.PluginSubtype],
|
||||
AuthorizedCollectionActions: authorizedCollectionActions[hostplugin.Subtype],
|
||||
}
|
||||
wantSomeCatalogs = append(wantSomeCatalogs, cat)
|
||||
testPluginCatalogs = append(testPluginCatalogs, cat)
|
||||
@@ -361,7 +362,7 @@ func TestList(t *testing.T) {
|
||||
Version: 1,
|
||||
Type: "static",
|
||||
AuthorizedActions: testAuthorizedActions,
|
||||
AuthorizedCollectionActions: authorizedCollectionActions[globals.StaticSubtype],
|
||||
AuthorizedCollectionActions: authorizedCollectionActions[static.Subtype],
|
||||
})
|
||||
}
|
||||
|
||||
@@ -382,9 +383,9 @@ func TestList(t *testing.T) {
|
||||
Description: diffPlg.GetDescription(),
|
||||
},
|
||||
Version: 1,
|
||||
Type: globals.PluginSubtype.String(),
|
||||
Type: hostplugin.Subtype.String(),
|
||||
AuthorizedActions: testAuthorizedActions,
|
||||
AuthorizedCollectionActions: authorizedCollectionActions[globals.PluginSubtype],
|
||||
AuthorizedCollectionActions: authorizedCollectionActions[hostplugin.Subtype],
|
||||
})
|
||||
}
|
||||
|
||||
@@ -718,7 +719,7 @@ func TestCreate_Static(t *testing.T) {
|
||||
Description: &wrappers.StringValue{Value: "desc"},
|
||||
Type: "static",
|
||||
AuthorizedActions: testAuthorizedActions,
|
||||
AuthorizedCollectionActions: authorizedCollectionActions[globals.StaticSubtype],
|
||||
AuthorizedCollectionActions: authorizedCollectionActions[static.Subtype],
|
||||
},
|
||||
},
|
||||
},
|
||||
@@ -869,7 +870,7 @@ func TestCreate_Plugin(t *testing.T) {
|
||||
ScopeId: proj.GetPublicId(),
|
||||
Name: &wrappers.StringValue{Value: "name"},
|
||||
Description: &wrappers.StringValue{Value: "desc"},
|
||||
Type: globals.PluginSubtype.String(),
|
||||
Type: hostplugin.Subtype.String(),
|
||||
PluginId: plg.GetPublicId(),
|
||||
}},
|
||||
res: &pbs.CreateHostCatalogResponse{
|
||||
@@ -885,9 +886,9 @@ func TestCreate_Plugin(t *testing.T) {
|
||||
},
|
||||
Name: &wrappers.StringValue{Value: "name"},
|
||||
Description: &wrappers.StringValue{Value: "desc"},
|
||||
Type: globals.PluginSubtype.String(),
|
||||
Type: hostplugin.Subtype.String(),
|
||||
AuthorizedActions: testAuthorizedActions,
|
||||
AuthorizedCollectionActions: authorizedCollectionActions[globals.PluginSubtype],
|
||||
AuthorizedCollectionActions: authorizedCollectionActions[hostplugin.Subtype],
|
||||
},
|
||||
},
|
||||
},
|
||||
@@ -895,7 +896,7 @@ func TestCreate_Plugin(t *testing.T) {
|
||||
name: "Cant create in org",
|
||||
req: &pbs.CreateHostCatalogRequest{Item: &pb.HostCatalog{
|
||||
ScopeId: org.GetParentId(),
|
||||
Type: globals.PluginSubtype.String(),
|
||||
Type: hostplugin.Subtype.String(),
|
||||
PluginId: plg.GetPublicId(),
|
||||
}},
|
||||
err: handlers.ApiErrorWithCode(codes.InvalidArgument),
|
||||
@@ -904,7 +905,7 @@ func TestCreate_Plugin(t *testing.T) {
|
||||
name: "Cant create in global",
|
||||
req: &pbs.CreateHostCatalogRequest{Item: &pb.HostCatalog{
|
||||
ScopeId: scope.Global.String(),
|
||||
Type: globals.PluginSubtype.String(),
|
||||
Type: hostplugin.Subtype.String(),
|
||||
PluginId: plg.GetPublicId(),
|
||||
}},
|
||||
err: handlers.ApiErrorWithCode(codes.InvalidArgument),
|
||||
@@ -931,7 +932,7 @@ func TestCreate_Plugin(t *testing.T) {
|
||||
req: &pbs.CreateHostCatalogRequest{Item: &pb.HostCatalog{
|
||||
Id: "not allowed to be set",
|
||||
ScopeId: proj.GetPublicId(),
|
||||
Type: globals.PluginSubtype.String(),
|
||||
Type: hostplugin.Subtype.String(),
|
||||
PluginId: plg.GetPublicId(),
|
||||
}},
|
||||
res: nil,
|
||||
@@ -942,7 +943,7 @@ func TestCreate_Plugin(t *testing.T) {
|
||||
req: &pbs.CreateHostCatalogRequest{Item: &pb.HostCatalog{
|
||||
CreatedTime: timestamppb.Now(),
|
||||
ScopeId: proj.GetPublicId(),
|
||||
Type: globals.PluginSubtype.String(),
|
||||
Type: hostplugin.Subtype.String(),
|
||||
PluginId: plg.GetPublicId(),
|
||||
}},
|
||||
res: nil,
|
||||
@@ -953,7 +954,7 @@ func TestCreate_Plugin(t *testing.T) {
|
||||
req: &pbs.CreateHostCatalogRequest{Item: &pb.HostCatalog{
|
||||
UpdatedTime: timestamppb.Now(),
|
||||
ScopeId: proj.GetPublicId(),
|
||||
Type: globals.PluginSubtype.String(),
|
||||
Type: hostplugin.Subtype.String(),
|
||||
PluginId: plg.GetPublicId(),
|
||||
}},
|
||||
res: nil,
|
||||
@@ -1076,7 +1077,7 @@ func TestUpdate_Static(t *testing.T) {
|
||||
CreatedTime: hc.GetCreateTime().GetTimestamp(),
|
||||
Type: "static",
|
||||
AuthorizedActions: testAuthorizedActions,
|
||||
AuthorizedCollectionActions: authorizedCollectionActions[globals.StaticSubtype],
|
||||
AuthorizedCollectionActions: authorizedCollectionActions[static.Subtype],
|
||||
},
|
||||
},
|
||||
},
|
||||
@@ -1102,7 +1103,7 @@ func TestUpdate_Static(t *testing.T) {
|
||||
CreatedTime: hc.GetCreateTime().GetTimestamp(),
|
||||
Type: "static",
|
||||
AuthorizedActions: testAuthorizedActions,
|
||||
AuthorizedCollectionActions: authorizedCollectionActions[globals.StaticSubtype],
|
||||
AuthorizedCollectionActions: authorizedCollectionActions[static.Subtype],
|
||||
},
|
||||
},
|
||||
},
|
||||
@@ -1157,7 +1158,7 @@ func TestUpdate_Static(t *testing.T) {
|
||||
CreatedTime: hc.GetCreateTime().GetTimestamp(),
|
||||
Type: "static",
|
||||
AuthorizedActions: testAuthorizedActions,
|
||||
AuthorizedCollectionActions: authorizedCollectionActions[globals.StaticSubtype],
|
||||
AuthorizedCollectionActions: authorizedCollectionActions[static.Subtype],
|
||||
},
|
||||
},
|
||||
},
|
||||
@@ -1180,7 +1181,7 @@ func TestUpdate_Static(t *testing.T) {
|
||||
CreatedTime: hc.GetCreateTime().GetTimestamp(),
|
||||
Type: "static",
|
||||
AuthorizedActions: testAuthorizedActions,
|
||||
AuthorizedCollectionActions: authorizedCollectionActions[globals.StaticSubtype],
|
||||
AuthorizedCollectionActions: authorizedCollectionActions[static.Subtype],
|
||||
},
|
||||
},
|
||||
},
|
||||
@@ -1205,7 +1206,7 @@ func TestUpdate_Static(t *testing.T) {
|
||||
CreatedTime: hc.GetCreateTime().GetTimestamp(),
|
||||
Type: "static",
|
||||
AuthorizedActions: testAuthorizedActions,
|
||||
AuthorizedCollectionActions: authorizedCollectionActions[globals.StaticSubtype],
|
||||
AuthorizedCollectionActions: authorizedCollectionActions[static.Subtype],
|
||||
},
|
||||
},
|
||||
},
|
||||
@@ -1230,7 +1231,7 @@ func TestUpdate_Static(t *testing.T) {
|
||||
CreatedTime: hc.GetCreateTime().GetTimestamp(),
|
||||
Type: "static",
|
||||
AuthorizedActions: testAuthorizedActions,
|
||||
AuthorizedCollectionActions: authorizedCollectionActions[globals.StaticSubtype],
|
||||
AuthorizedCollectionActions: authorizedCollectionActions[static.Subtype],
|
||||
},
|
||||
},
|
||||
},
|
||||
@@ -1481,7 +1482,7 @@ func TestUpdate_Plugin(t *testing.T) {
|
||||
check: func(t *testing.T, in *pb.HostCatalog) {
|
||||
assert.Equal(t, "new", in.Name.GetValue())
|
||||
assert.Equal(t, "desc", in.Description.GetValue())
|
||||
assert.Empty(t, cmp.Diff(authorizedCollectionActions[globals.PluginSubtype], in.GetAuthorizedCollectionActions(), cmpopts.IgnoreUnexported(structpb.ListValue{}, structpb.Value{})))
|
||||
assert.Empty(t, cmp.Diff(authorizedCollectionActions[hostplugin.Subtype], in.GetAuthorizedCollectionActions(), cmpopts.IgnoreUnexported(structpb.ListValue{}, structpb.Value{})))
|
||||
},
|
||||
},
|
||||
{
|
||||
|
||||
@@ -35,12 +35,12 @@ import (
|
||||
)
|
||||
|
||||
var (
|
||||
maskManager = map[globals.Subtype]handlers.MaskManager{}
|
||||
maskManager = map[subtypes.Subtype]handlers.MaskManager{}
|
||||
|
||||
// IdActions contains the set of actions that can be performed on
|
||||
// individual resources
|
||||
idActionsTypeMap = map[globals.Subtype]action.ActionSet{
|
||||
globals.StaticSubtype: {
|
||||
idActionsTypeMap = map[subtypes.Subtype]action.ActionSet{
|
||||
static.Subtype: {
|
||||
action.NoOp,
|
||||
action.Read,
|
||||
action.Update,
|
||||
@@ -49,7 +49,7 @@ var (
|
||||
action.SetHosts,
|
||||
action.RemoveHosts,
|
||||
},
|
||||
globals.PluginSubtype: {
|
||||
hostplugin.Subtype: {
|
||||
action.NoOp,
|
||||
action.Read,
|
||||
action.Update,
|
||||
@@ -69,14 +69,14 @@ const domain = "host"
|
||||
|
||||
func init() {
|
||||
var err error
|
||||
if maskManager[globals.StaticSubtype], err = handlers.NewMaskManager(
|
||||
if maskManager[static.Subtype], err = handlers.NewMaskManager(
|
||||
context.Background(),
|
||||
handlers.MaskDestination{&staticstore.HostSet{}, &staticstore.UnimplementedSetFields{}},
|
||||
handlers.MaskSource{&pb.HostSet{}},
|
||||
); err != nil {
|
||||
panic(err)
|
||||
}
|
||||
if maskManager[globals.PluginSubtype], err = handlers.NewMaskManager(
|
||||
if maskManager[hostplugin.Subtype], err = handlers.NewMaskManager(
|
||||
context.Background(),
|
||||
handlers.MaskDestination{&plugstore.HostSet{}},
|
||||
handlers.MaskSource{&pb.HostSet{}},
|
||||
@@ -443,7 +443,7 @@ func (s Service) getFromRepo(ctx context.Context, id string) (host.Set, []host.H
|
||||
var hl []host.Host
|
||||
var plg *plugins.PluginInfo
|
||||
switch subtypes.SubtypeFromId(domain, id) {
|
||||
case globals.StaticSubtype:
|
||||
case static.Subtype:
|
||||
repo, err := s.staticRepoFn()
|
||||
if err != nil {
|
||||
return nil, nil, nil, err
|
||||
@@ -459,7 +459,7 @@ func (s Service) getFromRepo(ctx context.Context, id string) (host.Set, []host.H
|
||||
hl = append(hl, h)
|
||||
}
|
||||
hs = hset
|
||||
case globals.PluginSubtype:
|
||||
case hostplugin.Subtype:
|
||||
repo, err := s.pluginRepoFn()
|
||||
if err != nil {
|
||||
return nil, nil, nil, err
|
||||
@@ -493,7 +493,7 @@ func (s Service) createInRepo(ctx context.Context, projectId, catalogId string,
|
||||
var hSet host.Set
|
||||
var plg *plugins.PluginInfo
|
||||
switch subtypes.SubtypeFromId(domain, catalogId) {
|
||||
case globals.StaticSubtype:
|
||||
case static.Subtype:
|
||||
h, err := toStorageStaticSet(ctx, catalogId, item)
|
||||
if err != nil {
|
||||
return nil, nil, err
|
||||
@@ -510,7 +510,7 @@ func (s Service) createInRepo(ctx context.Context, projectId, catalogId string,
|
||||
return nil, nil, handlers.ApiErrorWithCodeAndMessage(codes.Internal, "Unable to create host set but no error returned from repository.")
|
||||
}
|
||||
hSet = out
|
||||
case globals.PluginSubtype:
|
||||
case hostplugin.Subtype:
|
||||
h, err := toStoragePluginSet(ctx, catalogId, item)
|
||||
if err != nil {
|
||||
return nil, nil, err
|
||||
@@ -542,7 +542,7 @@ func (s Service) updateStaticInRepo(ctx context.Context, projectId, catalogId st
|
||||
return nil, nil, errors.Wrap(ctx, err, op, errors.WithMsg("Unable to build host set for update"))
|
||||
}
|
||||
h.PublicId = req.GetId()
|
||||
dbMask := maskManager[globals.StaticSubtype].Translate(req.GetUpdateMask().GetPaths())
|
||||
dbMask := maskManager[static.Subtype].Translate(req.GetUpdateMask().GetPaths())
|
||||
if len(dbMask) == 0 {
|
||||
return nil, nil, handlers.InvalidArgumentErrorf("No valid fields included in the update mask.", map[string]string{"update_mask": "No valid fields provided in the update mask."})
|
||||
}
|
||||
@@ -572,7 +572,7 @@ func (s Service) updatePluginInRepo(ctx context.Context, projectId string, req *
|
||||
return nil, nil, nil, errors.Wrap(ctx, err, op, errors.WithMsg("Unable to build host set for update"))
|
||||
}
|
||||
h.PublicId = req.GetId()
|
||||
dbMask := maskManager[globals.PluginSubtype].Translate(req.GetUpdateMask().GetPaths(), "attributes")
|
||||
dbMask := maskManager[hostplugin.Subtype].Translate(req.GetUpdateMask().GetPaths(), "attributes")
|
||||
if len(dbMask) == 0 {
|
||||
return nil, nil, nil, handlers.InvalidArgumentErrorf("No valid fields included in the update mask.", map[string]string{"update_mask": "No valid fields provided in the update mask."})
|
||||
}
|
||||
@@ -597,9 +597,9 @@ func (s Service) updatePluginInRepo(ctx context.Context, projectId string, req *
|
||||
func (s Service) updateInRepo(ctx context.Context, projectId, catalogId string, req *pbs.UpdateHostSetRequest) (hs host.Set, hosts []host.Host, plg *plugins.PluginInfo, err error) {
|
||||
const op = "host_sets.(Service).updateInRepo"
|
||||
switch subtypes.SubtypeFromId(domain, req.GetId()) {
|
||||
case globals.StaticSubtype:
|
||||
case static.Subtype:
|
||||
hs, hosts, err = s.updateStaticInRepo(ctx, projectId, catalogId, req)
|
||||
case globals.PluginSubtype:
|
||||
case hostplugin.Subtype:
|
||||
hs, hosts, plg, err = s.updatePluginInRepo(ctx, projectId, req)
|
||||
}
|
||||
return
|
||||
@@ -609,7 +609,7 @@ func (s Service) deleteFromRepo(ctx context.Context, projectId, id string) (bool
|
||||
const op = "host_sets.(Service).deleteFromRepo"
|
||||
rows := 0
|
||||
switch subtypes.SubtypeFromId(domain, id) {
|
||||
case globals.StaticSubtype:
|
||||
case static.Subtype:
|
||||
repo, err := s.staticRepoFn()
|
||||
if err != nil {
|
||||
return false, err
|
||||
@@ -618,7 +618,7 @@ func (s Service) deleteFromRepo(ctx context.Context, projectId, id string) (bool
|
||||
if err != nil {
|
||||
return false, errors.Wrap(ctx, err, op, errors.WithMsg("unable to delete host"))
|
||||
}
|
||||
case globals.PluginSubtype:
|
||||
case hostplugin.Subtype:
|
||||
repo, err := s.pluginRepoFn()
|
||||
if err != nil {
|
||||
return false, err
|
||||
@@ -636,7 +636,7 @@ func (s Service) listFromRepo(ctx context.Context, catalogId string, opt ...host
|
||||
var plg *plugins.PluginInfo
|
||||
var sets []host.Set
|
||||
switch subtypes.SubtypeFromId(domain, catalogId) {
|
||||
case globals.StaticSubtype:
|
||||
case static.Subtype:
|
||||
repo, err := s.staticRepoFn()
|
||||
if err != nil {
|
||||
return nil, nil, err
|
||||
@@ -648,7 +648,7 @@ func (s Service) listFromRepo(ctx context.Context, catalogId string, opt ...host
|
||||
for _, a := range sl {
|
||||
sets = append(sets, a)
|
||||
}
|
||||
case globals.PluginSubtype:
|
||||
case hostplugin.Subtype:
|
||||
repo, err := s.pluginRepoFn()
|
||||
if err != nil {
|
||||
return nil, nil, err
|
||||
@@ -761,7 +761,7 @@ func (s Service) parentAndAuthResult(ctx context.Context, id string, a action.Ty
|
||||
default:
|
||||
var set host.Set
|
||||
switch subtypes.SubtypeFromId(domain, id) {
|
||||
case globals.StaticSubtype:
|
||||
case static.Subtype:
|
||||
ss, _, err := staticRepo.LookupSet(ctx, id)
|
||||
if err != nil {
|
||||
res.Error = err
|
||||
@@ -772,7 +772,7 @@ func (s Service) parentAndAuthResult(ctx context.Context, id string, a action.Ty
|
||||
return nil, res
|
||||
}
|
||||
set = ss
|
||||
case globals.PluginSubtype:
|
||||
case hostplugin.Subtype:
|
||||
ps, _, err := pluginRepo.LookupSet(ctx, id)
|
||||
if err != nil {
|
||||
res.Error = err
|
||||
@@ -790,7 +790,7 @@ func (s Service) parentAndAuthResult(ctx context.Context, id string, a action.Ty
|
||||
|
||||
var cat host.Catalog
|
||||
switch subtypes.SubtypeFromId(domain, id) {
|
||||
case globals.StaticSubtype:
|
||||
case static.Subtype:
|
||||
cs, err := staticRepo.LookupCatalog(ctx, parentId)
|
||||
if err != nil {
|
||||
res.Error = err
|
||||
@@ -801,7 +801,7 @@ func (s Service) parentAndAuthResult(ctx context.Context, id string, a action.Ty
|
||||
return nil, res
|
||||
}
|
||||
cat = cs
|
||||
case globals.PluginSubtype:
|
||||
case hostplugin.Subtype:
|
||||
pc, _, err := pluginRepo.LookupCatalog(ctx, parentId)
|
||||
if err != nil {
|
||||
res.Error = err
|
||||
@@ -846,9 +846,9 @@ func toProto(ctx context.Context, in host.Set, hosts []host.Host, opt ...handler
|
||||
if outputFields.Has(globals.TypeField) {
|
||||
switch in.(type) {
|
||||
case *static.HostSet:
|
||||
out.Type = globals.StaticSubtype.String()
|
||||
out.Type = static.Subtype.String()
|
||||
case *hostplugin.HostSet:
|
||||
out.Type = globals.PluginSubtype.String()
|
||||
out.Type = hostplugin.Subtype.String()
|
||||
}
|
||||
}
|
||||
if outputFields.Has(globals.DescriptionField) && in.GetDescription() != "" {
|
||||
@@ -971,15 +971,15 @@ func validateCreateRequest(ctx context.Context, req *pbs.CreateHostSetRequest) e
|
||||
}
|
||||
}
|
||||
switch subtypes.SubtypeFromId(domain, req.GetItem().GetHostCatalogId()) {
|
||||
case globals.StaticSubtype:
|
||||
if req.GetItem().GetType() != "" && req.GetItem().GetType() != globals.StaticSubtype.String() {
|
||||
case static.Subtype:
|
||||
if req.GetItem().GetType() != "" && req.GetItem().GetType() != static.Subtype.String() {
|
||||
badFields[globals.TypeField] = "Doesn't match the parent resource's type."
|
||||
}
|
||||
if len(req.GetItem().PreferredEndpoints) > 0 {
|
||||
badFields[globals.PreferredEndpointsField] = "This field is not yet supported for static host sets."
|
||||
}
|
||||
case globals.PluginSubtype:
|
||||
if req.GetItem().GetType() != "" && req.GetItem().GetType() != globals.PluginSubtype.String() {
|
||||
case hostplugin.Subtype:
|
||||
if req.GetItem().GetType() != "" && req.GetItem().GetType() != hostplugin.Subtype.String() {
|
||||
badFields[globals.TypeField] = "Doesn't match the parent resource's type."
|
||||
}
|
||||
if val := req.GetItem().GetSyncIntervalSeconds(); val != nil {
|
||||
@@ -1002,11 +1002,11 @@ func validateUpdateRequest(ctx context.Context, req *pbs.UpdateHostSetRequest) e
|
||||
}
|
||||
}
|
||||
switch subtypes.SubtypeFromId(domain, req.GetId()) {
|
||||
case globals.StaticSubtype:
|
||||
if req.GetItem().GetType() != "" && req.GetItem().GetType() != globals.StaticSubtype.String() {
|
||||
case static.Subtype:
|
||||
if req.GetItem().GetType() != "" && req.GetItem().GetType() != static.Subtype.String() {
|
||||
badFields[globals.TypeField] = "Cannot modify the resource type."
|
||||
}
|
||||
case globals.PluginSubtype:
|
||||
case hostplugin.Subtype:
|
||||
if val := req.GetItem().GetSyncIntervalSeconds(); val != nil {
|
||||
if val.GetValue() == 0 || val.GetValue() < -1 {
|
||||
badFields[globals.SyncIntervalSecondsField] = "Must be -1 or a positive integer."
|
||||
|
||||
@@ -28,6 +28,7 @@ import (
|
||||
"github.com/hashicorp/boundary/internal/plugin/loopback"
|
||||
"github.com/hashicorp/boundary/internal/scheduler"
|
||||
"github.com/hashicorp/boundary/internal/types/scope"
|
||||
"github.com/hashicorp/boundary/internal/types/subtypes"
|
||||
pb "github.com/hashicorp/boundary/sdk/pbs/controller/api/resources/hostsets"
|
||||
"github.com/hashicorp/boundary/sdk/pbs/controller/api/resources/plugins"
|
||||
"github.com/hashicorp/boundary/sdk/pbs/controller/api/resources/scopes"
|
||||
@@ -44,9 +45,9 @@ import (
|
||||
"google.golang.org/protobuf/types/known/wrapperspb"
|
||||
)
|
||||
|
||||
var testAuthorizedActions = map[globals.Subtype][]string{
|
||||
globals.StaticSubtype: {"no-op", "read", "update", "delete", "add-hosts", "set-hosts", "remove-hosts"},
|
||||
globals.PluginSubtype: {"no-op", "read", "update", "delete"},
|
||||
var testAuthorizedActions = map[subtypes.Subtype][]string{
|
||||
static.Subtype: {"no-op", "read", "update", "delete", "add-hosts", "set-hosts", "remove-hosts"},
|
||||
hostplugin.Subtype: {"no-op", "read", "update", "delete"},
|
||||
}
|
||||
|
||||
func TestGet_Static(t *testing.T) {
|
||||
@@ -88,7 +89,7 @@ func TestGet_Static(t *testing.T) {
|
||||
Scope: &scopes.ScopeInfo{Id: proj.GetPublicId(), Type: scope.Project.String(), ParentScopeId: org.GetPublicId()},
|
||||
Type: "static",
|
||||
HostIds: hIds,
|
||||
AuthorizedActions: testAuthorizedActions[globals.StaticSubtype],
|
||||
AuthorizedActions: testAuthorizedActions[static.Subtype],
|
||||
}
|
||||
|
||||
cases := []struct {
|
||||
@@ -185,7 +186,7 @@ func TestGet_Plugin(t *testing.T) {
|
||||
Id: hs.GetPublicId(),
|
||||
CreatedTime: hs.CreateTime.GetTimestamp(),
|
||||
UpdatedTime: hs.UpdateTime.GetTimestamp(),
|
||||
Type: globals.PluginSubtype.String(),
|
||||
Type: hostplugin.Subtype.String(),
|
||||
Scope: &scopes.ScopeInfo{Id: proj.GetPublicId(), Type: scope.Project.String(), ParentScopeId: org.GetPublicId()},
|
||||
Plugin: &plugins.PluginInfo{
|
||||
Id: plg.GetPublicId(),
|
||||
@@ -194,7 +195,7 @@ func TestGet_Plugin(t *testing.T) {
|
||||
},
|
||||
PreferredEndpoints: prefEndpoints,
|
||||
SyncIntervalSeconds: &wrappers.Int32Value{Value: -1},
|
||||
AuthorizedActions: testAuthorizedActions[globals.PluginSubtype],
|
||||
AuthorizedActions: testAuthorizedActions[hostplugin.Subtype],
|
||||
}
|
||||
|
||||
cases := []struct {
|
||||
@@ -296,8 +297,8 @@ func TestList_Static(t *testing.T) {
|
||||
CreatedTime: h.GetCreateTime().GetTimestamp(),
|
||||
UpdatedTime: h.GetUpdateTime().GetTimestamp(),
|
||||
Version: h.GetVersion(),
|
||||
Type: globals.StaticSubtype.String(),
|
||||
AuthorizedActions: testAuthorizedActions[globals.StaticSubtype],
|
||||
Type: static.Subtype.String(),
|
||||
AuthorizedActions: testAuthorizedActions[static.Subtype],
|
||||
})
|
||||
}
|
||||
|
||||
@@ -408,8 +409,8 @@ func TestList_Plugin(t *testing.T) {
|
||||
CreatedTime: h.GetCreateTime().GetTimestamp(),
|
||||
UpdatedTime: h.GetUpdateTime().GetTimestamp(),
|
||||
Version: h.GetVersion(),
|
||||
Type: globals.PluginSubtype.String(),
|
||||
AuthorizedActions: testAuthorizedActions[globals.PluginSubtype],
|
||||
Type: hostplugin.Subtype.String(),
|
||||
AuthorizedActions: testAuthorizedActions[hostplugin.Subtype],
|
||||
PreferredEndpoints: preferredEndpoints,
|
||||
SyncIntervalSeconds: &wrappers.Int32Value{Value: 5},
|
||||
})
|
||||
@@ -715,7 +716,7 @@ func TestCreate_Static(t *testing.T) {
|
||||
Name: &wrappers.StringValue{Value: "name"},
|
||||
Description: &wrappers.StringValue{Value: "desc"},
|
||||
Type: "static",
|
||||
AuthorizedActions: testAuthorizedActions[globals.StaticSubtype],
|
||||
AuthorizedActions: testAuthorizedActions[static.Subtype],
|
||||
},
|
||||
},
|
||||
},
|
||||
@@ -725,7 +726,7 @@ func TestCreate_Static(t *testing.T) {
|
||||
HostCatalogId: hc.GetPublicId(),
|
||||
Name: &wrappers.StringValue{Value: "name"},
|
||||
Description: &wrappers.StringValue{Value: "desc"},
|
||||
Type: globals.StaticSubtype.String(),
|
||||
Type: static.Subtype.String(),
|
||||
PreferredEndpoints: prefEndpoints,
|
||||
}},
|
||||
err: handlers.ApiErrorWithCode(codes.InvalidArgument),
|
||||
@@ -755,7 +756,7 @@ func TestCreate_Static(t *testing.T) {
|
||||
Name: &wrappers.StringValue{Value: "no type name"},
|
||||
Description: &wrappers.StringValue{Value: "no type desc"},
|
||||
Type: "static",
|
||||
AuthorizedActions: testAuthorizedActions[globals.StaticSubtype],
|
||||
AuthorizedActions: testAuthorizedActions[static.Subtype],
|
||||
},
|
||||
},
|
||||
},
|
||||
@@ -899,7 +900,7 @@ func TestCreate_Plugin(t *testing.T) {
|
||||
HostCatalogId: hc.GetPublicId(),
|
||||
Name: &wrappers.StringValue{Value: "No Attributes"},
|
||||
Description: &wrappers.StringValue{Value: "desc"},
|
||||
Type: globals.PluginSubtype.String(),
|
||||
Type: hostplugin.Subtype.String(),
|
||||
SyncIntervalSeconds: &wrapperspb.Int32Value{Value: -1},
|
||||
}},
|
||||
res: &pbs.CreateHostSetResponse{
|
||||
@@ -914,8 +915,8 @@ func TestCreate_Plugin(t *testing.T) {
|
||||
},
|
||||
Name: &wrappers.StringValue{Value: "No Attributes"},
|
||||
Description: &wrappers.StringValue{Value: "desc"},
|
||||
Type: globals.PluginSubtype.String(),
|
||||
AuthorizedActions: testAuthorizedActions[globals.PluginSubtype],
|
||||
Type: hostplugin.Subtype.String(),
|
||||
AuthorizedActions: testAuthorizedActions[hostplugin.Subtype],
|
||||
SyncIntervalSeconds: &wrapperspb.Int32Value{Value: -1},
|
||||
},
|
||||
},
|
||||
@@ -926,7 +927,7 @@ func TestCreate_Plugin(t *testing.T) {
|
||||
HostCatalogId: hc.GetPublicId(),
|
||||
Name: &wrappers.StringValue{Value: "With Attributes"},
|
||||
Description: &wrappers.StringValue{Value: "desc"},
|
||||
Type: globals.PluginSubtype.String(),
|
||||
Type: hostplugin.Subtype.String(),
|
||||
SyncIntervalSeconds: &wrapperspb.Int32Value{Value: 90},
|
||||
Attrs: &pb.HostSet_Attributes{
|
||||
Attributes: testInputAttrs,
|
||||
@@ -944,9 +945,9 @@ func TestCreate_Plugin(t *testing.T) {
|
||||
},
|
||||
Name: &wrappers.StringValue{Value: "With Attributes"},
|
||||
Description: &wrappers.StringValue{Value: "desc"},
|
||||
Type: globals.PluginSubtype.String(),
|
||||
Type: hostplugin.Subtype.String(),
|
||||
SyncIntervalSeconds: &wrapperspb.Int32Value{Value: 90},
|
||||
AuthorizedActions: testAuthorizedActions[globals.PluginSubtype],
|
||||
AuthorizedActions: testAuthorizedActions[hostplugin.Subtype],
|
||||
Attrs: &pb.HostSet_Attributes{
|
||||
Attributes: testOutputAttrs,
|
||||
},
|
||||
@@ -959,7 +960,7 @@ func TestCreate_Plugin(t *testing.T) {
|
||||
HostCatalogId: hc.GetPublicId(),
|
||||
Name: &wrappers.StringValue{Value: "name"},
|
||||
Description: &wrappers.StringValue{Value: "desc"},
|
||||
Type: globals.PluginSubtype.String(),
|
||||
Type: hostplugin.Subtype.String(),
|
||||
PreferredEndpoints: prefEndpoints,
|
||||
}},
|
||||
res: &pbs.CreateHostSetResponse{
|
||||
@@ -974,9 +975,9 @@ func TestCreate_Plugin(t *testing.T) {
|
||||
},
|
||||
Name: &wrappers.StringValue{Value: "name"},
|
||||
Description: &wrappers.StringValue{Value: "desc"},
|
||||
Type: globals.PluginSubtype.String(),
|
||||
Type: hostplugin.Subtype.String(),
|
||||
PreferredEndpoints: prefEndpoints,
|
||||
AuthorizedActions: testAuthorizedActions[globals.PluginSubtype],
|
||||
AuthorizedActions: testAuthorizedActions[hostplugin.Subtype],
|
||||
},
|
||||
},
|
||||
},
|
||||
@@ -986,7 +987,7 @@ func TestCreate_Plugin(t *testing.T) {
|
||||
HostCatalogId: hc.GetPublicId(),
|
||||
Name: &wrappers.StringValue{Value: "name"},
|
||||
Description: &wrappers.StringValue{Value: "desc"},
|
||||
Type: globals.PluginSubtype.String(),
|
||||
Type: hostplugin.Subtype.String(),
|
||||
PreferredEndpoints: append(prefEndpoints, "foobar:1.2.3.4"),
|
||||
}},
|
||||
err: handlers.ApiErrorWithCode(codes.InvalidArgument),
|
||||
@@ -1020,8 +1021,8 @@ func TestCreate_Plugin(t *testing.T) {
|
||||
},
|
||||
Name: &wrappers.StringValue{Value: "no type name"},
|
||||
Description: &wrappers.StringValue{Value: "no type desc"},
|
||||
Type: globals.PluginSubtype.String(),
|
||||
AuthorizedActions: testAuthorizedActions[globals.PluginSubtype],
|
||||
Type: hostplugin.Subtype.String(),
|
||||
AuthorizedActions: testAuthorizedActions[hostplugin.Subtype],
|
||||
},
|
||||
},
|
||||
},
|
||||
@@ -1173,7 +1174,7 @@ func TestUpdate_Static(t *testing.T) {
|
||||
CreatedTime: hs.GetCreateTime().GetTimestamp(),
|
||||
Type: "static",
|
||||
HostIds: hIds,
|
||||
AuthorizedActions: testAuthorizedActions[globals.StaticSubtype],
|
||||
AuthorizedActions: testAuthorizedActions[static.Subtype],
|
||||
},
|
||||
},
|
||||
},
|
||||
@@ -1199,7 +1200,7 @@ func TestUpdate_Static(t *testing.T) {
|
||||
CreatedTime: hs.GetCreateTime().GetTimestamp(),
|
||||
Type: "static",
|
||||
HostIds: hIds,
|
||||
AuthorizedActions: testAuthorizedActions[globals.StaticSubtype],
|
||||
AuthorizedActions: testAuthorizedActions[static.Subtype],
|
||||
},
|
||||
},
|
||||
},
|
||||
@@ -1268,7 +1269,7 @@ func TestUpdate_Static(t *testing.T) {
|
||||
CreatedTime: hs.GetCreateTime().GetTimestamp(),
|
||||
Type: "static",
|
||||
HostIds: hIds,
|
||||
AuthorizedActions: testAuthorizedActions[globals.StaticSubtype],
|
||||
AuthorizedActions: testAuthorizedActions[static.Subtype],
|
||||
},
|
||||
},
|
||||
},
|
||||
@@ -1291,7 +1292,7 @@ func TestUpdate_Static(t *testing.T) {
|
||||
CreatedTime: hs.GetCreateTime().GetTimestamp(),
|
||||
Type: "static",
|
||||
HostIds: hIds,
|
||||
AuthorizedActions: testAuthorizedActions[globals.StaticSubtype],
|
||||
AuthorizedActions: testAuthorizedActions[static.Subtype],
|
||||
},
|
||||
},
|
||||
},
|
||||
@@ -1316,7 +1317,7 @@ func TestUpdate_Static(t *testing.T) {
|
||||
CreatedTime: hs.GetCreateTime().GetTimestamp(),
|
||||
Type: "static",
|
||||
HostIds: hIds,
|
||||
AuthorizedActions: testAuthorizedActions[globals.StaticSubtype],
|
||||
AuthorizedActions: testAuthorizedActions[static.Subtype],
|
||||
},
|
||||
},
|
||||
},
|
||||
@@ -1341,7 +1342,7 @@ func TestUpdate_Static(t *testing.T) {
|
||||
CreatedTime: hs.GetCreateTime().GetTimestamp(),
|
||||
Type: "static",
|
||||
HostIds: hIds,
|
||||
AuthorizedActions: testAuthorizedActions[globals.StaticSubtype],
|
||||
AuthorizedActions: testAuthorizedActions[static.Subtype],
|
||||
},
|
||||
},
|
||||
},
|
||||
@@ -1514,7 +1515,7 @@ func TestUpdate_Plugin(t *testing.T) {
|
||||
HostCatalogId: hc.GetPublicId(),
|
||||
Name: wrapperspb.String("default"),
|
||||
Description: wrapperspb.String("default"),
|
||||
Type: globals.PluginSubtype.String(),
|
||||
Type: hostplugin.Subtype.String(),
|
||||
Attrs: &pb.HostSet_Attributes{
|
||||
Attributes: attr,
|
||||
},
|
||||
|
||||
@@ -36,14 +36,14 @@ var (
|
||||
|
||||
// IdActions contains the set of actions that can be performed on
|
||||
// individual resources
|
||||
idActionsTypeMap = map[globals.Subtype]action.ActionSet{
|
||||
globals.StaticSubtype: {
|
||||
idActionsTypeMap = map[subtypes.Subtype]action.ActionSet{
|
||||
static.Subtype: {
|
||||
action.NoOp,
|
||||
action.Read,
|
||||
action.Update,
|
||||
action.Delete,
|
||||
},
|
||||
globals.PluginSubtype: {
|
||||
hostplugin.Subtype: {
|
||||
action.NoOp,
|
||||
action.Read,
|
||||
},
|
||||
@@ -302,7 +302,7 @@ func (s Service) getFromRepo(ctx context.Context, id string) (host.Host, *plugin
|
||||
var h host.Host
|
||||
var plg *plugins.PluginInfo
|
||||
switch subtypes.SubtypeFromId(domain, id) {
|
||||
case globals.StaticSubtype:
|
||||
case static.Subtype:
|
||||
repo, err := s.staticRepoFn()
|
||||
if err != nil {
|
||||
return nil, nil, err
|
||||
@@ -314,7 +314,7 @@ func (s Service) getFromRepo(ctx context.Context, id string) (host.Host, *plugin
|
||||
if h == nil {
|
||||
return nil, nil, handlers.NotFoundErrorf("Host %q doesn't exist.", id)
|
||||
}
|
||||
case globals.PluginSubtype:
|
||||
case hostplugin.Subtype:
|
||||
repo, err := s.pluginRepoFn()
|
||||
if err != nil {
|
||||
return nil, nil, err
|
||||
@@ -417,7 +417,7 @@ func (s Service) listFromRepo(ctx context.Context, catalogId string) ([]host.Hos
|
||||
var hosts []host.Host
|
||||
var plg *plugins.PluginInfo
|
||||
switch subtypes.SubtypeFromId(domain, catalogId) {
|
||||
case globals.StaticSubtype:
|
||||
case static.Subtype:
|
||||
repo, err := s.staticRepoFn()
|
||||
if err != nil {
|
||||
return nil, nil, err
|
||||
@@ -429,7 +429,7 @@ func (s Service) listFromRepo(ctx context.Context, catalogId string) ([]host.Hos
|
||||
for _, h := range hl {
|
||||
hosts = append(hosts, h)
|
||||
}
|
||||
case globals.PluginSubtype:
|
||||
case hostplugin.Subtype:
|
||||
repo, err := s.pluginRepoFn()
|
||||
if err != nil {
|
||||
return nil, nil, err
|
||||
@@ -466,7 +466,7 @@ func (s Service) parentAndAuthResult(ctx context.Context, id string, a action.Ty
|
||||
parentId = id
|
||||
default:
|
||||
switch subtypes.SubtypeFromId(domain, id) {
|
||||
case globals.StaticSubtype:
|
||||
case static.Subtype:
|
||||
h, err := staticRepo.LookupHost(ctx, id)
|
||||
if err != nil {
|
||||
res.Error = err
|
||||
@@ -477,7 +477,7 @@ func (s Service) parentAndAuthResult(ctx context.Context, id string, a action.Ty
|
||||
return nil, res
|
||||
}
|
||||
parentId = h.GetCatalogId()
|
||||
case globals.PluginSubtype:
|
||||
case hostplugin.Subtype:
|
||||
h, _, err := pluginRepo.LookupHost(ctx, id)
|
||||
if err != nil {
|
||||
res.Error = err
|
||||
@@ -494,7 +494,7 @@ func (s Service) parentAndAuthResult(ctx context.Context, id string, a action.Ty
|
||||
|
||||
var cat host.Catalog
|
||||
switch subtypes.SubtypeFromId(domain, id) {
|
||||
case globals.StaticSubtype:
|
||||
case static.Subtype:
|
||||
stcat, err := staticRepo.LookupCatalog(ctx, parentId)
|
||||
if err != nil {
|
||||
res.Error = err
|
||||
@@ -505,7 +505,7 @@ func (s Service) parentAndAuthResult(ctx context.Context, id string, a action.Ty
|
||||
return nil, res
|
||||
}
|
||||
cat = stcat
|
||||
case globals.PluginSubtype:
|
||||
case hostplugin.Subtype:
|
||||
plcat, _, err := pluginRepo.LookupCatalog(ctx, parentId)
|
||||
if err != nil {
|
||||
res.Error = err
|
||||
@@ -549,9 +549,9 @@ func toProto(ctx context.Context, in host.Host, opt ...handlers.Option) (*pb.Hos
|
||||
if outputFields.Has(globals.TypeField) {
|
||||
switch in.(type) {
|
||||
case *static.Host:
|
||||
out.Type = globals.StaticSubtype.String()
|
||||
out.Type = static.Subtype.String()
|
||||
case *hostplugin.Host:
|
||||
out.Type = globals.PluginSubtype.String()
|
||||
out.Type = hostplugin.Subtype.String()
|
||||
}
|
||||
}
|
||||
if outputFields.Has(globals.DescriptionField) && in.GetDescription() != "" {
|
||||
@@ -620,7 +620,7 @@ func validateGetRequest(req *pbs.GetHostRequest) error {
|
||||
return handlers.ValidateGetRequest(func() map[string]string {
|
||||
badFields := map[string]string{}
|
||||
ct := subtypes.SubtypeFromId(domain, req.GetId())
|
||||
if ct == globals.UnknownSubtype {
|
||||
if ct == subtypes.UnknownSubtype {
|
||||
badFields["id"] = "Improperly formatted identifier used."
|
||||
}
|
||||
return badFields
|
||||
@@ -634,8 +634,8 @@ func validateCreateRequest(req *pbs.CreateHostRequest) error {
|
||||
badFields["host_catalog_id"] = "The field is incorrectly formatted."
|
||||
}
|
||||
switch subtypes.SubtypeFromId(domain, req.GetItem().GetHostCatalogId()) {
|
||||
case globals.StaticSubtype:
|
||||
if req.GetItem().GetType() != "" && req.GetItem().GetType() != globals.StaticSubtype.String() {
|
||||
case static.Subtype:
|
||||
if req.GetItem().GetType() != "" && req.GetItem().GetType() != static.Subtype.String() {
|
||||
badFields[globals.TypeField] = "Doesn't match the parent resource's type."
|
||||
}
|
||||
if len(req.GetItem().GetIpAddresses()) > 0 {
|
||||
@@ -665,7 +665,7 @@ func validateCreateRequest(req *pbs.CreateHostRequest) error {
|
||||
}
|
||||
}
|
||||
}
|
||||
case globals.PluginSubtype:
|
||||
case hostplugin.Subtype:
|
||||
badFields[globals.HostCatalogIdField] = "Cannot manually create hosts for this type of catalog."
|
||||
}
|
||||
return badFields
|
||||
@@ -676,8 +676,8 @@ func validateUpdateRequest(req *pbs.UpdateHostRequest) error {
|
||||
return handlers.ValidateUpdateRequest(req, req.GetItem(), func() map[string]string {
|
||||
badFields := map[string]string{}
|
||||
switch subtypes.SubtypeFromId(domain, req.GetId()) {
|
||||
case globals.StaticSubtype:
|
||||
if req.GetItem().GetType() != "" && req.GetItem().GetType() != globals.StaticSubtype.String() {
|
||||
case static.Subtype:
|
||||
if req.GetItem().GetType() != "" && req.GetItem().GetType() != static.Subtype.String() {
|
||||
badFields[globals.TypeField] = "Cannot modify the resource type."
|
||||
}
|
||||
if handlers.MaskContains(req.GetUpdateMask().GetPaths(), globals.AttributesAddressField) {
|
||||
@@ -703,7 +703,7 @@ func validateUpdateRequest(req *pbs.UpdateHostRequest) error {
|
||||
}
|
||||
}
|
||||
}
|
||||
case globals.PluginSubtype:
|
||||
case hostplugin.Subtype:
|
||||
badFields[globals.IdField] = "Cannot modify this type of host."
|
||||
default:
|
||||
badFields["id"] = "Improperly formatted identifier used."
|
||||
@@ -716,7 +716,7 @@ func validateDeleteRequest(req *pbs.DeleteHostRequest) error {
|
||||
return handlers.ValidateDeleteRequest(func() map[string]string {
|
||||
badFields := map[string]string{}
|
||||
switch subtypes.SubtypeFromId(domain, req.GetId()) {
|
||||
case globals.PluginSubtype:
|
||||
case hostplugin.Subtype:
|
||||
badFields[globals.IdField] = "Cannot manually delete this type of host."
|
||||
}
|
||||
return badFields
|
||||
|
||||
@@ -27,6 +27,7 @@ import (
|
||||
"github.com/hashicorp/boundary/internal/plugin/loopback"
|
||||
"github.com/hashicorp/boundary/internal/scheduler"
|
||||
"github.com/hashicorp/boundary/internal/types/scope"
|
||||
"github.com/hashicorp/boundary/internal/types/subtypes"
|
||||
pb "github.com/hashicorp/boundary/sdk/pbs/controller/api/resources/hosts"
|
||||
"github.com/hashicorp/boundary/sdk/pbs/controller/api/resources/plugins"
|
||||
"github.com/hashicorp/boundary/sdk/pbs/controller/api/resources/scopes"
|
||||
@@ -41,9 +42,9 @@ import (
|
||||
"google.golang.org/protobuf/types/known/wrapperspb"
|
||||
)
|
||||
|
||||
var testAuthorizedActions = map[globals.Subtype][]string{
|
||||
globals.StaticSubtype: {"no-op", "read", "update", "delete"},
|
||||
globals.PluginSubtype: {"no-op", "read"},
|
||||
var testAuthorizedActions = map[subtypes.Subtype][]string{
|
||||
static.Subtype: {"no-op", "read", "update", "delete"},
|
||||
hostplugin.Subtype: {"no-op", "read"},
|
||||
}
|
||||
|
||||
func TestGet_Static(t *testing.T) {
|
||||
@@ -85,7 +86,7 @@ func TestGet_Static(t *testing.T) {
|
||||
Address: wrapperspb.String(h.GetAddress()),
|
||||
},
|
||||
},
|
||||
AuthorizedActions: testAuthorizedActions[globals.StaticSubtype],
|
||||
AuthorizedActions: testAuthorizedActions[static.Subtype],
|
||||
HostSetIds: []string{s.GetPublicId()},
|
||||
}
|
||||
|
||||
@@ -181,7 +182,7 @@ func TestGet_Plugin(t *testing.T) {
|
||||
CreatedTime: h.CreateTime.GetTimestamp(),
|
||||
UpdatedTime: h.UpdateTime.GetTimestamp(),
|
||||
Scope: &scopes.ScopeInfo{Id: proj.GetPublicId(), Type: scope.Project.String(), ParentScopeId: org.GetPublicId()},
|
||||
Type: globals.PluginSubtype.String(),
|
||||
Type: hostplugin.Subtype.String(),
|
||||
Plugin: &plugins.PluginInfo{
|
||||
Id: plg.GetPublicId(),
|
||||
Name: plg.GetName(),
|
||||
@@ -190,7 +191,7 @@ func TestGet_Plugin(t *testing.T) {
|
||||
HostSetIds: []string{hs.GetPublicId()},
|
||||
ExternalId: "test",
|
||||
ExternalName: "test-ext-name",
|
||||
AuthorizedActions: testAuthorizedActions[globals.PluginSubtype],
|
||||
AuthorizedActions: testAuthorizedActions[hostplugin.Subtype],
|
||||
}
|
||||
|
||||
cases := []struct {
|
||||
@@ -294,13 +295,13 @@ func TestList_Static(t *testing.T) {
|
||||
CreatedTime: h.GetCreateTime().GetTimestamp(),
|
||||
UpdatedTime: h.GetUpdateTime().GetTimestamp(),
|
||||
Version: h.GetVersion(),
|
||||
Type: globals.StaticSubtype.String(),
|
||||
Type: static.Subtype.String(),
|
||||
Attrs: &pb.Host_StaticHostAttributes{
|
||||
StaticHostAttributes: &pb.StaticHostAttributes{
|
||||
Address: wrapperspb.String(h.GetAddress()),
|
||||
},
|
||||
},
|
||||
AuthorizedActions: testAuthorizedActions[globals.StaticSubtype],
|
||||
AuthorizedActions: testAuthorizedActions[static.Subtype],
|
||||
HostSetIds: []string{hset.GetPublicId()},
|
||||
})
|
||||
}
|
||||
@@ -423,8 +424,8 @@ func TestList_Plugin(t *testing.T) {
|
||||
Version: 1,
|
||||
ExternalId: extId,
|
||||
ExternalName: fmt.Sprintf("ext-name-%d", i),
|
||||
Type: globals.PluginSubtype.String(),
|
||||
AuthorizedActions: testAuthorizedActions[globals.PluginSubtype],
|
||||
Type: hostplugin.Subtype.String(),
|
||||
AuthorizedActions: testAuthorizedActions[hostplugin.Subtype],
|
||||
})
|
||||
}
|
||||
sort.Slice(wantHs, func(i, j int) bool {
|
||||
@@ -686,7 +687,7 @@ func TestCreate(t *testing.T) {
|
||||
Address: wrapperspb.String("123.456.789"),
|
||||
},
|
||||
},
|
||||
AuthorizedActions: testAuthorizedActions[globals.StaticSubtype],
|
||||
AuthorizedActions: testAuthorizedActions[static.Subtype],
|
||||
},
|
||||
},
|
||||
},
|
||||
@@ -774,7 +775,7 @@ func TestCreate(t *testing.T) {
|
||||
Address: wrapperspb.String("123.456.789"),
|
||||
},
|
||||
},
|
||||
AuthorizedActions: testAuthorizedActions[globals.StaticSubtype],
|
||||
AuthorizedActions: testAuthorizedActions[static.Subtype],
|
||||
},
|
||||
},
|
||||
},
|
||||
@@ -943,7 +944,7 @@ func TestUpdate_Static(t *testing.T) {
|
||||
Address: wrapperspb.String("defaultaddress"),
|
||||
},
|
||||
},
|
||||
AuthorizedActions: testAuthorizedActions[globals.StaticSubtype],
|
||||
AuthorizedActions: testAuthorizedActions[static.Subtype],
|
||||
HostSetIds: []string{s.GetPublicId()},
|
||||
},
|
||||
},
|
||||
@@ -975,7 +976,7 @@ func TestUpdate_Static(t *testing.T) {
|
||||
Address: wrapperspb.String("defaultaddress"),
|
||||
},
|
||||
},
|
||||
AuthorizedActions: testAuthorizedActions[globals.StaticSubtype],
|
||||
AuthorizedActions: testAuthorizedActions[static.Subtype],
|
||||
HostSetIds: []string{s.GetPublicId()},
|
||||
},
|
||||
},
|
||||
@@ -1057,7 +1058,7 @@ func TestUpdate_Static(t *testing.T) {
|
||||
Address: wrapperspb.String("defaultaddress"),
|
||||
},
|
||||
},
|
||||
AuthorizedActions: testAuthorizedActions[globals.StaticSubtype],
|
||||
AuthorizedActions: testAuthorizedActions[static.Subtype],
|
||||
HostSetIds: []string{s.GetPublicId()},
|
||||
},
|
||||
},
|
||||
@@ -1086,7 +1087,7 @@ func TestUpdate_Static(t *testing.T) {
|
||||
Address: wrapperspb.String("defaultaddress"),
|
||||
},
|
||||
},
|
||||
AuthorizedActions: testAuthorizedActions[globals.StaticSubtype],
|
||||
AuthorizedActions: testAuthorizedActions[static.Subtype],
|
||||
HostSetIds: []string{s.GetPublicId()},
|
||||
},
|
||||
},
|
||||
@@ -1117,7 +1118,7 @@ func TestUpdate_Static(t *testing.T) {
|
||||
Address: wrapperspb.String("defaultaddress"),
|
||||
},
|
||||
},
|
||||
AuthorizedActions: testAuthorizedActions[globals.StaticSubtype],
|
||||
AuthorizedActions: testAuthorizedActions[static.Subtype],
|
||||
HostSetIds: []string{s.GetPublicId()},
|
||||
},
|
||||
},
|
||||
@@ -1148,7 +1149,7 @@ func TestUpdate_Static(t *testing.T) {
|
||||
Address: wrapperspb.String("defaultaddress"),
|
||||
},
|
||||
},
|
||||
AuthorizedActions: testAuthorizedActions[globals.StaticSubtype],
|
||||
AuthorizedActions: testAuthorizedActions[static.Subtype],
|
||||
HostSetIds: []string{s.GetPublicId()},
|
||||
},
|
||||
},
|
||||
|
||||
@@ -44,14 +44,14 @@ var (
|
||||
|
||||
// IdActions contains the set of actions that can be performed on
|
||||
// individual resources
|
||||
IdActions = map[globals.Subtype]action.ActionSet{
|
||||
globals.OidcSubtype: {
|
||||
IdActions = map[subtypes.Subtype]action.ActionSet{
|
||||
oidc.Subtype: {
|
||||
action.NoOp,
|
||||
action.Read,
|
||||
action.Update,
|
||||
action.Delete,
|
||||
},
|
||||
globals.LdapSubtype: {
|
||||
ldap.Subtype: {
|
||||
action.NoOp,
|
||||
action.Read,
|
||||
action.Update,
|
||||
@@ -310,7 +310,7 @@ func (s Service) getFromRepo(ctx context.Context, id string) (auth.ManagedGroup,
|
||||
var out auth.ManagedGroup
|
||||
var memberIds []string
|
||||
switch subtypes.SubtypeFromId(domain, id) {
|
||||
case globals.OidcSubtype:
|
||||
case oidc.Subtype:
|
||||
repo, err := s.oidcRepoFn()
|
||||
if err != nil {
|
||||
return nil, nil, err
|
||||
@@ -333,7 +333,7 @@ func (s Service) getFromRepo(ctx context.Context, id string) (auth.ManagedGroup,
|
||||
}
|
||||
}
|
||||
out = mg
|
||||
case globals.LdapSubtype:
|
||||
case ldap.Subtype:
|
||||
repo, err := s.ldapRepoFn()
|
||||
if err != nil {
|
||||
return nil, nil, err
|
||||
@@ -433,7 +433,7 @@ func (s Service) createInRepo(ctx context.Context, am auth.AuthMethod, item *pb.
|
||||
}
|
||||
var out auth.ManagedGroup
|
||||
switch subtypes.SubtypeFromId(domain, am.GetPublicId()) {
|
||||
case globals.OidcSubtype:
|
||||
case oidc.Subtype:
|
||||
am, err := s.createOidcInRepo(ctx, am, item)
|
||||
if err != nil {
|
||||
return nil, errors.Wrap(ctx, err, op)
|
||||
@@ -442,7 +442,7 @@ func (s Service) createInRepo(ctx context.Context, am auth.AuthMethod, item *pb.
|
||||
return nil, handlers.ApiErrorWithCodeAndMessage(codes.Internal, "Unable to create managed group but no error returned from repository.")
|
||||
}
|
||||
out = am
|
||||
case globals.LdapSubtype:
|
||||
case ldap.Subtype:
|
||||
am, err := s.createLdapInRepo(ctx, am, item)
|
||||
if err != nil {
|
||||
return nil, errors.Wrap(ctx, err, op)
|
||||
@@ -535,7 +535,7 @@ func (s Service) updateInRepo(ctx context.Context, scopeId, authMethodId string,
|
||||
const op = "managed_groups.(Service).updateInRepo"
|
||||
var out auth.ManagedGroup
|
||||
switch subtypes.SubtypeFromId(domain, req.GetId()) {
|
||||
case globals.OidcSubtype:
|
||||
case oidc.Subtype:
|
||||
mg, err := s.updateOidcInRepo(ctx, scopeId, authMethodId, req.GetId(), req.GetUpdateMask().GetPaths(), req.GetItem())
|
||||
if err != nil {
|
||||
return nil, errors.Wrap(ctx, err, op)
|
||||
@@ -544,7 +544,7 @@ func (s Service) updateInRepo(ctx context.Context, scopeId, authMethodId string,
|
||||
return nil, handlers.ApiErrorWithCodeAndMessage(codes.Internal, "Unable to update managed group but no error returned from repository.")
|
||||
}
|
||||
out = mg
|
||||
case globals.LdapSubtype:
|
||||
case ldap.Subtype:
|
||||
mg, err := s.updateLdapInRepo(ctx, scopeId, authMethodId, req.GetId(), req.GetUpdateMask().GetPaths(), req.GetItem())
|
||||
if err != nil {
|
||||
return nil, errors.Wrap(ctx, err, op)
|
||||
@@ -562,13 +562,13 @@ func (s Service) deleteFromRepo(ctx context.Context, scopeId, id string) (bool,
|
||||
var rows int
|
||||
var err error
|
||||
switch subtypes.SubtypeFromId(domain, id) {
|
||||
case globals.OidcSubtype:
|
||||
case oidc.Subtype:
|
||||
repo, iErr := s.oidcRepoFn()
|
||||
if iErr != nil {
|
||||
return false, iErr
|
||||
}
|
||||
rows, err = repo.DeleteManagedGroup(ctx, scopeId, id)
|
||||
case globals.LdapSubtype:
|
||||
case ldap.Subtype:
|
||||
repo, iErr := s.ldapRepoFn()
|
||||
if iErr != nil {
|
||||
return false, iErr
|
||||
@@ -589,7 +589,7 @@ func (s Service) listFromRepo(ctx context.Context, authMethodId string) ([]auth.
|
||||
|
||||
var outUl []auth.ManagedGroup
|
||||
switch subtypes.SubtypeFromId(domain, authMethodId) {
|
||||
case globals.OidcSubtype:
|
||||
case oidc.Subtype:
|
||||
oidcRepo, err := s.oidcRepoFn()
|
||||
if err != nil {
|
||||
return nil, errors.Wrap(ctx, err, op)
|
||||
@@ -601,7 +601,7 @@ func (s Service) listFromRepo(ctx context.Context, authMethodId string) ([]auth.
|
||||
for _, a := range oidcl {
|
||||
outUl = append(outUl, a)
|
||||
}
|
||||
case globals.LdapSubtype:
|
||||
case ldap.Subtype:
|
||||
ldapRepo, err := s.ldapRepoFn()
|
||||
if err != nil {
|
||||
return nil, errors.Wrap(ctx, err, op)
|
||||
@@ -638,7 +638,7 @@ func (s Service) parentAndAuthResult(ctx context.Context, id string, a action.Ty
|
||||
parentId = id
|
||||
default:
|
||||
switch subtypes.SubtypeFromId(domain, id) {
|
||||
case globals.OidcSubtype:
|
||||
case oidc.Subtype:
|
||||
grp, err := oidcRepo.LookupManagedGroup(ctx, id)
|
||||
if err != nil {
|
||||
res.Error = err
|
||||
@@ -649,7 +649,7 @@ func (s Service) parentAndAuthResult(ctx context.Context, id string, a action.Ty
|
||||
return nil, res
|
||||
}
|
||||
parentId = grp.GetAuthMethodId()
|
||||
case globals.LdapSubtype:
|
||||
case ldap.Subtype:
|
||||
grp, err := ldapRepo.LookupManagedGroup(ctx, id)
|
||||
if err != nil {
|
||||
res.Error = err
|
||||
@@ -669,7 +669,7 @@ func (s Service) parentAndAuthResult(ctx context.Context, id string, a action.Ty
|
||||
|
||||
var authMeth auth.AuthMethod
|
||||
switch subtypes.SubtypeFromId(domain, parentId) {
|
||||
case globals.OidcSubtype:
|
||||
case oidc.Subtype:
|
||||
am, err := oidcRepo.LookupAuthMethod(ctx, parentId)
|
||||
if err != nil {
|
||||
res.Error = err
|
||||
@@ -681,7 +681,7 @@ func (s Service) parentAndAuthResult(ctx context.Context, id string, a action.Ty
|
||||
}
|
||||
authMeth = am
|
||||
opts = append(opts, requestauth.WithScopeId(am.GetScopeId()))
|
||||
case globals.LdapSubtype:
|
||||
case ldap.Subtype:
|
||||
am, err := ldapRepo.LookupAuthMethod(ctx, parentId)
|
||||
if err != nil {
|
||||
res.Error = err
|
||||
@@ -742,7 +742,7 @@ func toProto(ctx context.Context, in auth.ManagedGroup, opt ...handlers.Option)
|
||||
switch i := in.(type) {
|
||||
case *oidc.ManagedGroup:
|
||||
if outputFields.Has(globals.TypeField) {
|
||||
out.Type = globals.OidcSubtype.String()
|
||||
out.Type = oidc.Subtype.String()
|
||||
}
|
||||
if !outputFields.Has(globals.AttributesField) {
|
||||
break
|
||||
@@ -755,7 +755,7 @@ func toProto(ctx context.Context, in auth.ManagedGroup, opt ...handlers.Option)
|
||||
}
|
||||
case *ldap.ManagedGroup:
|
||||
if outputFields.Has(globals.TypeField) {
|
||||
out.Type = globals.LdapSubtype.String()
|
||||
out.Type = ldap.Subtype.String()
|
||||
}
|
||||
if !outputFields.Has(globals.AttributesField) {
|
||||
break
|
||||
@@ -800,8 +800,8 @@ func validateCreateRequest(ctx context.Context, req *pbs.CreateManagedGroupReque
|
||||
badFields[globals.AuthMethodIdField] = "This field is required."
|
||||
}
|
||||
switch subtypes.SubtypeFromId(domain, req.GetItem().GetAuthMethodId()) {
|
||||
case globals.OidcSubtype:
|
||||
if req.GetItem().GetType() != "" && req.GetItem().GetType() != globals.OidcSubtype.String() {
|
||||
case oidc.Subtype:
|
||||
if req.GetItem().GetType() != "" && req.GetItem().GetType() != oidc.Subtype.String() {
|
||||
badFields[globals.TypeField] = "Doesn't match the parent resource's type."
|
||||
}
|
||||
attrs := req.GetItem().GetOidcManagedGroupAttributes()
|
||||
@@ -816,8 +816,8 @@ func validateCreateRequest(ctx context.Context, req *pbs.CreateManagedGroupReque
|
||||
}
|
||||
}
|
||||
}
|
||||
case globals.LdapSubtype:
|
||||
if req.GetItem().GetType() != "" && req.GetItem().GetType() != globals.LdapSubtype.String() {
|
||||
case ldap.Subtype:
|
||||
if req.GetItem().GetType() != "" && req.GetItem().GetType() != ldap.Subtype.String() {
|
||||
badFields[globals.TypeField] = "Doesn't match the parent resource's type."
|
||||
}
|
||||
attrs := req.GetItem().GetLdapManagedGroupAttributes()
|
||||
@@ -843,8 +843,8 @@ func validateUpdateRequest(ctx context.Context, req *pbs.UpdateManagedGroupReque
|
||||
return handlers.ValidateUpdateRequest(req, req.GetItem(), func() map[string]string {
|
||||
badFields := map[string]string{}
|
||||
switch subtypes.SubtypeFromId(domain, req.GetId()) {
|
||||
case globals.OidcSubtype:
|
||||
if req.GetItem().GetType() != "" && req.GetItem().GetType() != globals.OidcSubtype.String() {
|
||||
case oidc.Subtype:
|
||||
if req.GetItem().GetType() != "" && req.GetItem().GetType() != oidc.Subtype.String() {
|
||||
badFields[globals.TypeField] = "Cannot modify the resource type."
|
||||
}
|
||||
attrs := req.GetItem().GetOidcManagedGroupAttributes()
|
||||
@@ -862,8 +862,8 @@ func validateUpdateRequest(ctx context.Context, req *pbs.UpdateManagedGroupReque
|
||||
}
|
||||
}
|
||||
}
|
||||
case globals.LdapSubtype:
|
||||
if req.GetItem().GetType() != "" && req.GetItem().GetType() != globals.LdapSubtype.String() {
|
||||
case ldap.Subtype:
|
||||
if req.GetItem().GetType() != "" && req.GetItem().GetType() != ldap.Subtype.String() {
|
||||
badFields[globals.TypeField] = "Cannot modify the resource type."
|
||||
}
|
||||
attrs := req.GetItem().GetLdapManagedGroupAttributes()
|
||||
|
||||
@@ -16,6 +16,7 @@ import (
|
||||
"github.com/hashicorp/boundary/globals"
|
||||
"github.com/hashicorp/boundary/internal/auth/ldap"
|
||||
"github.com/hashicorp/boundary/internal/auth/oidc"
|
||||
"github.com/hashicorp/boundary/internal/auth/password"
|
||||
"github.com/hashicorp/boundary/internal/daemon/controller/auth"
|
||||
"github.com/hashicorp/boundary/internal/daemon/controller/common"
|
||||
"github.com/hashicorp/boundary/internal/daemon/controller/handlers"
|
||||
@@ -293,7 +294,7 @@ func TestListOidc(t *testing.T) {
|
||||
UpdatedTime: mg.GetUpdateTime().GetTimestamp(),
|
||||
Scope: &scopepb.ScopeInfo{Id: o.GetPublicId(), Type: scope.Org.String(), ParentScopeId: scope.Global.String()},
|
||||
Version: 1,
|
||||
Type: globals.OidcSubtype.String(),
|
||||
Type: oidc.Subtype.String(),
|
||||
Attrs: &pb.ManagedGroup_OidcManagedGroupAttributes{
|
||||
OidcManagedGroupAttributes: &pb.OidcManagedGroupAttributes{
|
||||
Filter: oidc.TestFakeManagedGroupFilter,
|
||||
@@ -314,7 +315,7 @@ func TestListOidc(t *testing.T) {
|
||||
UpdatedTime: mg.GetUpdateTime().GetTimestamp(),
|
||||
Scope: &scopepb.ScopeInfo{Id: o.GetPublicId(), Type: scope.Org.String(), ParentScopeId: scope.Global.String()},
|
||||
Version: 1,
|
||||
Type: globals.OidcSubtype.String(),
|
||||
Type: oidc.Subtype.String(),
|
||||
Attrs: &pb.ManagedGroup_OidcManagedGroupAttributes{
|
||||
OidcManagedGroupAttributes: &pb.OidcManagedGroupAttributes{
|
||||
Filter: oidc.TestFakeManagedGroupFilter,
|
||||
@@ -446,7 +447,7 @@ func TestListLdap(t *testing.T) {
|
||||
UpdatedTime: mg.GetUpdateTime().GetTimestamp(),
|
||||
Scope: &scopepb.ScopeInfo{Id: o.GetPublicId(), Type: scope.Org.String(), ParentScopeId: scope.Global.String()},
|
||||
Version: 1,
|
||||
Type: globals.LdapSubtype.String(),
|
||||
Type: ldap.Subtype.String(),
|
||||
Attrs: &pb.ManagedGroup_LdapManagedGroupAttributes{
|
||||
LdapManagedGroupAttributes: &pb.LdapManagedGroupAttributes{
|
||||
GroupNames: testGroups,
|
||||
@@ -467,7 +468,7 @@ func TestListLdap(t *testing.T) {
|
||||
UpdatedTime: mg.GetUpdateTime().GetTimestamp(),
|
||||
Scope: &scopepb.ScopeInfo{Id: o.GetPublicId(), Type: scope.Org.String(), ParentScopeId: scope.Global.String()},
|
||||
Version: 1,
|
||||
Type: globals.LdapSubtype.String(),
|
||||
Type: ldap.Subtype.String(),
|
||||
Attrs: &pb.ManagedGroup_LdapManagedGroupAttributes{
|
||||
LdapManagedGroupAttributes: &pb.LdapManagedGroupAttributes{
|
||||
GroupNames: testGroups,
|
||||
@@ -751,7 +752,7 @@ func TestCreateOidc(t *testing.T) {
|
||||
AuthMethodId: am.GetPublicId(),
|
||||
Name: &wrapperspb.StringValue{Value: "name"},
|
||||
Description: &wrapperspb.StringValue{Value: "desc"},
|
||||
Type: globals.OidcSubtype.String(),
|
||||
Type: oidc.Subtype.String(),
|
||||
Attrs: &pb.ManagedGroup_OidcManagedGroupAttributes{
|
||||
OidcManagedGroupAttributes: &pb.OidcManagedGroupAttributes{
|
||||
Filter: oidc.TestFakeManagedGroupFilter,
|
||||
@@ -767,7 +768,7 @@ func TestCreateOidc(t *testing.T) {
|
||||
Description: &wrapperspb.StringValue{Value: "desc"},
|
||||
Scope: &scopepb.ScopeInfo{Id: o.GetPublicId(), Type: scope.Org.String(), ParentScopeId: scope.Global.String()},
|
||||
Version: 1,
|
||||
Type: globals.OidcSubtype.String(),
|
||||
Type: oidc.Subtype.String(),
|
||||
Attrs: &pb.ManagedGroup_OidcManagedGroupAttributes{
|
||||
OidcManagedGroupAttributes: &pb.OidcManagedGroupAttributes{
|
||||
Filter: oidc.TestFakeManagedGroupFilter,
|
||||
@@ -795,7 +796,7 @@ func TestCreateOidc(t *testing.T) {
|
||||
AuthMethodId: am.GetPublicId(),
|
||||
Scope: &scopepb.ScopeInfo{Id: o.GetPublicId(), Type: scope.Org.String(), ParentScopeId: scope.Global.String()},
|
||||
Version: 1,
|
||||
Type: globals.OidcSubtype.String(),
|
||||
Type: oidc.Subtype.String(),
|
||||
Attrs: &pb.ManagedGroup_OidcManagedGroupAttributes{
|
||||
OidcManagedGroupAttributes: &pb.OidcManagedGroupAttributes{
|
||||
Filter: oidc.TestFakeManagedGroupFilter,
|
||||
@@ -810,7 +811,7 @@ func TestCreateOidc(t *testing.T) {
|
||||
req: &pbs.CreateManagedGroupRequest{
|
||||
Item: &pb.ManagedGroup{
|
||||
AuthMethodId: am.GetPublicId(),
|
||||
Type: globals.PasswordSubtype.String(),
|
||||
Type: password.Subtype.String(),
|
||||
Attrs: &pb.ManagedGroup_OidcManagedGroupAttributes{
|
||||
OidcManagedGroupAttributes: &pb.OidcManagedGroupAttributes{
|
||||
Filter: oidc.TestFakeManagedGroupFilter,
|
||||
@@ -827,7 +828,7 @@ func TestCreateOidc(t *testing.T) {
|
||||
Item: &pb.ManagedGroup{
|
||||
AuthMethodId: am.GetPublicId(),
|
||||
Id: globals.OidcManagedGroupPrefix + "_notallowed",
|
||||
Type: globals.OidcSubtype.String(),
|
||||
Type: oidc.Subtype.String(),
|
||||
Attrs: &pb.ManagedGroup_OidcManagedGroupAttributes{
|
||||
OidcManagedGroupAttributes: &pb.OidcManagedGroupAttributes{
|
||||
Filter: oidc.TestFakeManagedGroupFilter,
|
||||
@@ -844,7 +845,7 @@ func TestCreateOidc(t *testing.T) {
|
||||
Item: &pb.ManagedGroup{
|
||||
AuthMethodId: am.GetPublicId(),
|
||||
CreatedTime: timestamppb.Now(),
|
||||
Type: globals.OidcSubtype.String(),
|
||||
Type: oidc.Subtype.String(),
|
||||
Attrs: &pb.ManagedGroup_OidcManagedGroupAttributes{
|
||||
OidcManagedGroupAttributes: &pb.OidcManagedGroupAttributes{
|
||||
Filter: oidc.TestFakeManagedGroupFilter,
|
||||
@@ -861,7 +862,7 @@ func TestCreateOidc(t *testing.T) {
|
||||
Item: &pb.ManagedGroup{
|
||||
AuthMethodId: am.GetPublicId(),
|
||||
UpdatedTime: timestamppb.Now(),
|
||||
Type: globals.OidcSubtype.String(),
|
||||
Type: oidc.Subtype.String(),
|
||||
Attrs: &pb.ManagedGroup_OidcManagedGroupAttributes{
|
||||
OidcManagedGroupAttributes: &pb.OidcManagedGroupAttributes{
|
||||
Filter: oidc.TestFakeManagedGroupFilter,
|
||||
@@ -878,7 +879,7 @@ func TestCreateOidc(t *testing.T) {
|
||||
Item: &pb.ManagedGroup{
|
||||
AuthMethodId: am.GetPublicId(),
|
||||
UpdatedTime: timestamppb.Now(),
|
||||
Type: globals.OidcSubtype.String(),
|
||||
Type: oidc.Subtype.String(),
|
||||
Attrs: &pb.ManagedGroup_OidcManagedGroupAttributes{
|
||||
OidcManagedGroupAttributes: &pb.OidcManagedGroupAttributes{
|
||||
Filter: "foobar",
|
||||
@@ -951,7 +952,7 @@ func TestCreateLdap(t *testing.T) {
|
||||
AuthMethodId: am.GetPublicId(),
|
||||
Name: &wrapperspb.StringValue{Value: "name"},
|
||||
Description: &wrapperspb.StringValue{Value: "desc"},
|
||||
Type: globals.LdapSubtype.String(),
|
||||
Type: ldap.Subtype.String(),
|
||||
Attrs: &pb.ManagedGroup_LdapManagedGroupAttributes{
|
||||
LdapManagedGroupAttributes: &pb.LdapManagedGroupAttributes{
|
||||
GroupNames: []string{"admin", "users"},
|
||||
@@ -967,7 +968,7 @@ func TestCreateLdap(t *testing.T) {
|
||||
Description: &wrapperspb.StringValue{Value: "desc"},
|
||||
Scope: &scopepb.ScopeInfo{Id: o.GetPublicId(), Type: scope.Org.String(), ParentScopeId: scope.Global.String()},
|
||||
Version: 1,
|
||||
Type: globals.LdapSubtype.String(),
|
||||
Type: ldap.Subtype.String(),
|
||||
Attrs: &pb.ManagedGroup_LdapManagedGroupAttributes{
|
||||
LdapManagedGroupAttributes: &pb.LdapManagedGroupAttributes{
|
||||
GroupNames: []string{"admin", "users"},
|
||||
@@ -995,7 +996,7 @@ func TestCreateLdap(t *testing.T) {
|
||||
AuthMethodId: am.GetPublicId(),
|
||||
Scope: &scopepb.ScopeInfo{Id: o.GetPublicId(), Type: scope.Org.String(), ParentScopeId: scope.Global.String()},
|
||||
Version: 1,
|
||||
Type: globals.LdapSubtype.String(),
|
||||
Type: ldap.Subtype.String(),
|
||||
Attrs: &pb.ManagedGroup_LdapManagedGroupAttributes{
|
||||
LdapManagedGroupAttributes: &pb.LdapManagedGroupAttributes{
|
||||
GroupNames: []string{"admin", "users"},
|
||||
@@ -1010,7 +1011,7 @@ func TestCreateLdap(t *testing.T) {
|
||||
req: &pbs.CreateManagedGroupRequest{
|
||||
Item: &pb.ManagedGroup{
|
||||
AuthMethodId: am.GetPublicId(),
|
||||
Type: globals.PasswordSubtype.String(),
|
||||
Type: password.Subtype.String(),
|
||||
Attrs: &pb.ManagedGroup_LdapManagedGroupAttributes{
|
||||
LdapManagedGroupAttributes: &pb.LdapManagedGroupAttributes{
|
||||
GroupNames: []string{"admin", "users"},
|
||||
@@ -1028,7 +1029,7 @@ func TestCreateLdap(t *testing.T) {
|
||||
Item: &pb.ManagedGroup{
|
||||
AuthMethodId: am.GetPublicId(),
|
||||
Id: globals.LdapManagedGroupPrefix + "_notallowed",
|
||||
Type: globals.OidcSubtype.String(),
|
||||
Type: oidc.Subtype.String(),
|
||||
Attrs: &pb.ManagedGroup_LdapManagedGroupAttributes{
|
||||
LdapManagedGroupAttributes: &pb.LdapManagedGroupAttributes{
|
||||
GroupNames: []string{"admin", "users"},
|
||||
@@ -1046,7 +1047,7 @@ func TestCreateLdap(t *testing.T) {
|
||||
Item: &pb.ManagedGroup{
|
||||
AuthMethodId: am.GetPublicId(),
|
||||
CreatedTime: timestamppb.Now(),
|
||||
Type: globals.LdapSubtype.String(),
|
||||
Type: ldap.Subtype.String(),
|
||||
Attrs: &pb.ManagedGroup_LdapManagedGroupAttributes{
|
||||
LdapManagedGroupAttributes: &pb.LdapManagedGroupAttributes{
|
||||
GroupNames: []string{"admin", "users"},
|
||||
@@ -1064,7 +1065,7 @@ func TestCreateLdap(t *testing.T) {
|
||||
Item: &pb.ManagedGroup{
|
||||
AuthMethodId: am.GetPublicId(),
|
||||
UpdatedTime: timestamppb.Now(),
|
||||
Type: globals.LdapSubtype.String(),
|
||||
Type: ldap.Subtype.String(),
|
||||
Attrs: &pb.ManagedGroup_LdapManagedGroupAttributes{
|
||||
LdapManagedGroupAttributes: &pb.LdapManagedGroupAttributes{
|
||||
GroupNames: []string{"admin", "users"},
|
||||
@@ -1081,7 +1082,7 @@ func TestCreateLdap(t *testing.T) {
|
||||
req: &pbs.CreateManagedGroupRequest{
|
||||
Item: &pb.ManagedGroup{
|
||||
AuthMethodId: am.GetPublicId(),
|
||||
Type: globals.OidcSubtype.String(),
|
||||
Type: oidc.Subtype.String(),
|
||||
Attrs: &pb.ManagedGroup_LdapManagedGroupAttributes{
|
||||
LdapManagedGroupAttributes: &pb.LdapManagedGroupAttributes{
|
||||
GroupNames: []string{},
|
||||
@@ -1196,7 +1197,7 @@ func TestUpdateOidc(t *testing.T) {
|
||||
Item: &pb.ManagedGroup{
|
||||
Name: &wrapperspb.StringValue{Value: "new"},
|
||||
Description: &wrapperspb.StringValue{Value: "desc"},
|
||||
Type: globals.OidcSubtype.String(),
|
||||
Type: oidc.Subtype.String(),
|
||||
},
|
||||
},
|
||||
res: &pbs.UpdateManagedGroupResponse{
|
||||
@@ -1204,7 +1205,7 @@ func TestUpdateOidc(t *testing.T) {
|
||||
AuthMethodId: am.GetPublicId(),
|
||||
Name: &wrapperspb.StringValue{Value: "new"},
|
||||
Description: &wrapperspb.StringValue{Value: "desc"},
|
||||
Type: globals.OidcSubtype.String(),
|
||||
Type: oidc.Subtype.String(),
|
||||
Attrs: defaultAttributes,
|
||||
Scope: defaultScopeInfo,
|
||||
AuthorizedActions: oidcAuthorizedActions,
|
||||
@@ -1220,7 +1221,7 @@ func TestUpdateOidc(t *testing.T) {
|
||||
Item: &pb.ManagedGroup{
|
||||
Name: &wrapperspb.StringValue{Value: "new"},
|
||||
Description: &wrapperspb.StringValue{Value: "desc"},
|
||||
Type: globals.OidcSubtype.String(),
|
||||
Type: oidc.Subtype.String(),
|
||||
},
|
||||
},
|
||||
res: &pbs.UpdateManagedGroupResponse{
|
||||
@@ -1228,7 +1229,7 @@ func TestUpdateOidc(t *testing.T) {
|
||||
AuthMethodId: am.GetPublicId(),
|
||||
Name: &wrapperspb.StringValue{Value: "new"},
|
||||
Description: &wrapperspb.StringValue{Value: "desc"},
|
||||
Type: globals.OidcSubtype.String(),
|
||||
Type: oidc.Subtype.String(),
|
||||
Attrs: defaultAttributes,
|
||||
Scope: defaultScopeInfo,
|
||||
AuthorizedActions: oidcAuthorizedActions,
|
||||
@@ -1298,7 +1299,7 @@ func TestUpdateOidc(t *testing.T) {
|
||||
Item: &pb.ManagedGroup{
|
||||
AuthMethodId: am.GetPublicId(),
|
||||
Description: &wrapperspb.StringValue{Value: "default"},
|
||||
Type: globals.OidcSubtype.String(),
|
||||
Type: oidc.Subtype.String(),
|
||||
Attrs: defaultAttributes,
|
||||
Scope: defaultScopeInfo,
|
||||
AuthorizedActions: oidcAuthorizedActions,
|
||||
@@ -1322,7 +1323,7 @@ func TestUpdateOidc(t *testing.T) {
|
||||
AuthMethodId: am.GetPublicId(),
|
||||
Name: &wrapperspb.StringValue{Value: "updated"},
|
||||
Description: &wrapperspb.StringValue{Value: "default"},
|
||||
Type: globals.OidcSubtype.String(),
|
||||
Type: oidc.Subtype.String(),
|
||||
Attrs: defaultAttributes,
|
||||
Scope: defaultScopeInfo,
|
||||
AuthorizedActions: oidcAuthorizedActions,
|
||||
@@ -1346,7 +1347,7 @@ func TestUpdateOidc(t *testing.T) {
|
||||
AuthMethodId: am.GetPublicId(),
|
||||
Name: &wrapperspb.StringValue{Value: "default"},
|
||||
Description: &wrapperspb.StringValue{Value: "notignored"},
|
||||
Type: globals.OidcSubtype.String(),
|
||||
Type: oidc.Subtype.String(),
|
||||
Attrs: defaultAttributes,
|
||||
Scope: defaultScopeInfo,
|
||||
AuthorizedActions: oidcAuthorizedActions,
|
||||
@@ -1448,7 +1449,7 @@ func TestUpdateOidc(t *testing.T) {
|
||||
AuthMethodId: am.GetPublicId(),
|
||||
Name: &wrapperspb.StringValue{Value: "default"},
|
||||
Description: &wrapperspb.StringValue{Value: "default"},
|
||||
Type: globals.OidcSubtype.String(),
|
||||
Type: oidc.Subtype.String(),
|
||||
Attrs: modifiedAttributes,
|
||||
Scope: defaultScopeInfo,
|
||||
AuthorizedActions: oidcAuthorizedActions,
|
||||
@@ -1581,7 +1582,7 @@ func TestUpdateLdap(t *testing.T) {
|
||||
Item: &pb.ManagedGroup{
|
||||
Name: &wrapperspb.StringValue{Value: "new"},
|
||||
Description: &wrapperspb.StringValue{Value: "desc"},
|
||||
Type: globals.LdapSubtype.String(),
|
||||
Type: ldap.Subtype.String(),
|
||||
},
|
||||
},
|
||||
res: &pbs.UpdateManagedGroupResponse{
|
||||
@@ -1589,7 +1590,7 @@ func TestUpdateLdap(t *testing.T) {
|
||||
AuthMethodId: am.GetPublicId(),
|
||||
Name: &wrapperspb.StringValue{Value: "new"},
|
||||
Description: &wrapperspb.StringValue{Value: "desc"},
|
||||
Type: globals.LdapSubtype.String(),
|
||||
Type: ldap.Subtype.String(),
|
||||
Attrs: defaultAttributes,
|
||||
Scope: defaultScopeInfo,
|
||||
AuthorizedActions: ldapAuthorizedActions,
|
||||
@@ -1605,7 +1606,7 @@ func TestUpdateLdap(t *testing.T) {
|
||||
Item: &pb.ManagedGroup{
|
||||
Name: &wrapperspb.StringValue{Value: "new"},
|
||||
Description: &wrapperspb.StringValue{Value: "desc"},
|
||||
Type: globals.LdapSubtype.String(),
|
||||
Type: ldap.Subtype.String(),
|
||||
},
|
||||
},
|
||||
res: &pbs.UpdateManagedGroupResponse{
|
||||
@@ -1613,7 +1614,7 @@ func TestUpdateLdap(t *testing.T) {
|
||||
AuthMethodId: am.GetPublicId(),
|
||||
Name: &wrapperspb.StringValue{Value: "new"},
|
||||
Description: &wrapperspb.StringValue{Value: "desc"},
|
||||
Type: globals.LdapSubtype.String(),
|
||||
Type: ldap.Subtype.String(),
|
||||
Attrs: defaultAttributes,
|
||||
Scope: defaultScopeInfo,
|
||||
AuthorizedActions: ldapAuthorizedActions,
|
||||
@@ -1684,7 +1685,7 @@ func TestUpdateLdap(t *testing.T) {
|
||||
Item: &pb.ManagedGroup{
|
||||
AuthMethodId: am.GetPublicId(),
|
||||
Description: &wrapperspb.StringValue{Value: "default"},
|
||||
Type: globals.LdapSubtype.String(),
|
||||
Type: ldap.Subtype.String(),
|
||||
Attrs: defaultAttributes,
|
||||
Scope: defaultScopeInfo,
|
||||
AuthorizedActions: ldapAuthorizedActions,
|
||||
@@ -1708,7 +1709,7 @@ func TestUpdateLdap(t *testing.T) {
|
||||
AuthMethodId: am.GetPublicId(),
|
||||
Name: &wrapperspb.StringValue{Value: "updated"},
|
||||
Description: &wrapperspb.StringValue{Value: "default"},
|
||||
Type: globals.LdapSubtype.String(),
|
||||
Type: ldap.Subtype.String(),
|
||||
Attrs: defaultAttributes,
|
||||
Scope: defaultScopeInfo,
|
||||
AuthorizedActions: ldapAuthorizedActions,
|
||||
@@ -1732,7 +1733,7 @@ func TestUpdateLdap(t *testing.T) {
|
||||
AuthMethodId: am.GetPublicId(),
|
||||
Name: &wrapperspb.StringValue{Value: "default"},
|
||||
Description: &wrapperspb.StringValue{Value: "notignored"},
|
||||
Type: globals.LdapSubtype.String(),
|
||||
Type: ldap.Subtype.String(),
|
||||
Attrs: defaultAttributes,
|
||||
Scope: defaultScopeInfo,
|
||||
AuthorizedActions: ldapAuthorizedActions,
|
||||
@@ -1840,7 +1841,7 @@ func TestUpdateLdap(t *testing.T) {
|
||||
AuthMethodId: am.GetPublicId(),
|
||||
Name: &wrapperspb.StringValue{Value: "default"},
|
||||
Description: &wrapperspb.StringValue{Value: "default"},
|
||||
Type: globals.LdapSubtype.String(),
|
||||
Type: ldap.Subtype.String(),
|
||||
Attrs: modifiedAttributes,
|
||||
Scope: defaultScopeInfo,
|
||||
AuthorizedActions: ldapAuthorizedActions,
|
||||
|
||||
@@ -10,6 +10,9 @@ import (
|
||||
"testing"
|
||||
|
||||
"github.com/hashicorp/boundary/globals"
|
||||
"github.com/hashicorp/boundary/internal/auth/ldap"
|
||||
"github.com/hashicorp/boundary/internal/auth/oidc"
|
||||
"github.com/hashicorp/boundary/internal/auth/password"
|
||||
pbs "github.com/hashicorp/boundary/internal/gen/controller/api/services"
|
||||
pb "github.com/hashicorp/boundary/sdk/pbs/controller/api/resources/managedgroups"
|
||||
"github.com/stretchr/testify/assert"
|
||||
@@ -46,7 +49,7 @@ func TestValidateCreateRequest(t *testing.T) {
|
||||
{
|
||||
name: "missing oidc attributes",
|
||||
item: &pb.ManagedGroup{
|
||||
Type: globals.OidcSubtype.String(),
|
||||
Type: oidc.Subtype.String(),
|
||||
AuthMethodId: globals.OidcAuthMethodPrefix + "_1234567890",
|
||||
Attrs: nil,
|
||||
},
|
||||
@@ -55,7 +58,7 @@ func TestValidateCreateRequest(t *testing.T) {
|
||||
{
|
||||
name: "bad oidc attributes",
|
||||
item: &pb.ManagedGroup{
|
||||
Type: globals.OidcSubtype.String(),
|
||||
Type: oidc.Subtype.String(),
|
||||
AuthMethodId: globals.OidcAuthMethodPrefix + "_1234567890",
|
||||
Attrs: &pb.ManagedGroup_OidcManagedGroupAttributes{
|
||||
OidcManagedGroupAttributes: &pb.OidcManagedGroupAttributes{
|
||||
@@ -68,7 +71,7 @@ func TestValidateCreateRequest(t *testing.T) {
|
||||
{
|
||||
name: "no oidc errors",
|
||||
item: &pb.ManagedGroup{
|
||||
Type: globals.OidcSubtype.String(),
|
||||
Type: oidc.Subtype.String(),
|
||||
AuthMethodId: globals.OidcAuthMethodPrefix + "_1234567890",
|
||||
Attrs: &pb.ManagedGroup_OidcManagedGroupAttributes{
|
||||
OidcManagedGroupAttributes: &pb.OidcManagedGroupAttributes{
|
||||
@@ -88,7 +91,7 @@ func TestValidateCreateRequest(t *testing.T) {
|
||||
{
|
||||
name: "missing ldap attributes",
|
||||
item: &pb.ManagedGroup{
|
||||
Type: globals.LdapSubtype.String(),
|
||||
Type: ldap.Subtype.String(),
|
||||
AuthMethodId: globals.LdapAuthMethodPrefix + "_1234567890",
|
||||
Attrs: nil,
|
||||
},
|
||||
@@ -97,7 +100,7 @@ func TestValidateCreateRequest(t *testing.T) {
|
||||
{
|
||||
name: "bad ldap attributes",
|
||||
item: &pb.ManagedGroup{
|
||||
Type: globals.LdapSubtype.String(),
|
||||
Type: ldap.Subtype.String(),
|
||||
AuthMethodId: globals.LdapAuthMethodPrefix + "_1234567890",
|
||||
Attrs: &pb.ManagedGroup_LdapManagedGroupAttributes{
|
||||
LdapManagedGroupAttributes: &pb.LdapManagedGroupAttributes{
|
||||
@@ -110,7 +113,7 @@ func TestValidateCreateRequest(t *testing.T) {
|
||||
{
|
||||
name: "no ldap errors",
|
||||
item: &pb.ManagedGroup{
|
||||
Type: globals.LdapSubtype.String(),
|
||||
Type: ldap.Subtype.String(),
|
||||
AuthMethodId: globals.LdapAuthMethodPrefix + "_1234567890",
|
||||
Attrs: &pb.ManagedGroup_LdapManagedGroupAttributes{
|
||||
LdapManagedGroupAttributes: &pb.LdapManagedGroupAttributes{
|
||||
@@ -148,7 +151,7 @@ func TestValidateUpdateRequest(t *testing.T) {
|
||||
req: &pbs.UpdateManagedGroupRequest{
|
||||
Id: globals.OidcManagedGroupPrefix + "_1234567890",
|
||||
Item: &pb.ManagedGroup{
|
||||
Type: globals.PasswordSubtype.String(),
|
||||
Type: password.Subtype.String(),
|
||||
},
|
||||
},
|
||||
errContains: fieldError(globals.TypeField, "Cannot modify the resource type."),
|
||||
@@ -173,7 +176,7 @@ func TestValidateUpdateRequest(t *testing.T) {
|
||||
req: &pbs.UpdateManagedGroupRequest{
|
||||
Id: globals.LdapManagedGroupPrefix + "_1234567890",
|
||||
Item: &pb.ManagedGroup{
|
||||
Type: globals.PasswordSubtype.String(),
|
||||
Type: password.Subtype.String(),
|
||||
},
|
||||
},
|
||||
errContains: fieldError(globals.TypeField, "Cannot modify the resource type."),
|
||||
|
||||
@@ -98,7 +98,7 @@ func TestGetSession(t *testing.T) {
|
||||
Scope: &scopes.ScopeInfo{Id: p.GetPublicId(), Type: scope.Project.String(), ParentScopeId: o.GetPublicId()},
|
||||
States: []*pb.SessionState{{Status: session.StatusPending.String(), StartTime: sess.CreateTime.GetTimestamp()}},
|
||||
Certificate: sess.Certificate,
|
||||
Type: globals.TcpSubtype.String(),
|
||||
Type: tcp.Subtype.String(),
|
||||
AuthorizedActions: testAuthorizedActions,
|
||||
}
|
||||
|
||||
@@ -352,7 +352,7 @@ func TestList(t *testing.T) {
|
||||
Status: status,
|
||||
States: states,
|
||||
Certificate: sess.Certificate,
|
||||
Type: globals.TcpSubtype.String(),
|
||||
Type: tcp.Subtype.String(),
|
||||
AuthorizedActions: testAuthorizedActions,
|
||||
Connections: []*pb.Connection{}, // connections should not be returned for list
|
||||
}
|
||||
@@ -392,7 +392,7 @@ func TestList(t *testing.T) {
|
||||
Status: status,
|
||||
States: states,
|
||||
Certificate: sess.Certificate,
|
||||
Type: globals.TcpSubtype.String(),
|
||||
Type: tcp.Subtype.String(),
|
||||
AuthorizedActions: testAuthorizedActions,
|
||||
Connections: []*pb.Connection{}, // connections should not be returned for list
|
||||
}
|
||||
@@ -440,7 +440,7 @@ func TestList(t *testing.T) {
|
||||
States: states,
|
||||
Certificate: sess.Certificate,
|
||||
TerminationReason: sess.TerminationReason,
|
||||
Type: globals.TcpSubtype.String(),
|
||||
Type: tcp.Subtype.String(),
|
||||
AuthorizedActions: testAuthorizedActions,
|
||||
Connections: []*pb.Connection{}, // connections should not be returned for list
|
||||
}
|
||||
@@ -664,7 +664,7 @@ func TestCancel(t *testing.T) {
|
||||
Scope: &scopes.ScopeInfo{Id: p.GetPublicId(), Type: scope.Project.String(), ParentScopeId: o.GetPublicId()},
|
||||
Status: session.StatusCanceling.String(),
|
||||
Certificate: sess.Certificate,
|
||||
Type: globals.TcpSubtype.String(),
|
||||
Type: tcp.Subtype.String(),
|
||||
AuthorizedActions: testAuthorizedActions,
|
||||
}
|
||||
|
||||
|
||||
@@ -265,7 +265,7 @@ func staticToSessionCredential(ctx context.Context, cred credential.Static) (*pb
|
||||
Name: cred.GetName(),
|
||||
Description: cred.GetDescription(),
|
||||
CredentialStoreId: cred.GetStoreId(),
|
||||
Type: globals.StaticSubtype.String(),
|
||||
Type: credstatic.Subtype.String(),
|
||||
CredentialType: credType,
|
||||
},
|
||||
Secret: &pb.SessionSecret{
|
||||
|
||||
@@ -8,10 +8,10 @@ import (
|
||||
"fmt"
|
||||
"sync"
|
||||
|
||||
"github.com/hashicorp/boundary/globals"
|
||||
"github.com/hashicorp/boundary/internal/daemon/controller/handlers"
|
||||
"github.com/hashicorp/boundary/internal/session"
|
||||
"github.com/hashicorp/boundary/internal/target"
|
||||
"github.com/hashicorp/boundary/internal/types/subtypes"
|
||||
pb "github.com/hashicorp/boundary/sdk/pbs/controller/api/resources/targets"
|
||||
"google.golang.org/protobuf/proto"
|
||||
)
|
||||
@@ -52,7 +52,7 @@ type registry struct {
|
||||
*sync.Map
|
||||
}
|
||||
|
||||
func (r registry) get(s globals.Subtype) (*registryEntry, error) {
|
||||
func (r registry) get(s subtypes.Subtype) (*registryEntry, error) {
|
||||
v, ok := r.Load(s)
|
||||
if !ok {
|
||||
return nil, fmt.Errorf("subtype %q not registered", s)
|
||||
@@ -65,7 +65,7 @@ func (r registry) get(s globals.Subtype) (*registryEntry, error) {
|
||||
return re, nil
|
||||
}
|
||||
|
||||
func (r registry) maskManager(s globals.Subtype) (handlers.MaskManager, error) {
|
||||
func (r registry) maskManager(s subtypes.Subtype) (handlers.MaskManager, error) {
|
||||
re, err := r.get(s)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
@@ -77,7 +77,7 @@ func (r registry) maskManager(s globals.Subtype) (handlers.MaskManager, error) {
|
||||
// newAttribute creates an Attribute for the given subtype. It delegates the
|
||||
// allocation of the Attribute to the registered attrFunc for the given
|
||||
// subtype. An error is returned if the provided subtype is not registered
|
||||
func (r registry) newAttribute(s globals.Subtype, m any) (Attributes, error) {
|
||||
func (r registry) newAttribute(s subtypes.Subtype, m any) (Attributes, error) {
|
||||
re, err := r.get(s)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
@@ -92,7 +92,7 @@ func (r registry) newAttribute(s globals.Subtype, m any) (Attributes, error) {
|
||||
// setting of the specific attribute type to the registered setAttributeFunc for
|
||||
// the given subtype. An error is returned if the provided subtype is not
|
||||
// registered.
|
||||
func (r registry) setAttributes(s globals.Subtype, in target.Target, out *pb.Target) error {
|
||||
func (r registry) setAttributes(s subtypes.Subtype, in target.Target, out *pb.Target) error {
|
||||
re, err := r.get(s)
|
||||
if err != nil {
|
||||
return err
|
||||
@@ -106,7 +106,7 @@ var subtypeRegistry = registry{
|
||||
}
|
||||
|
||||
// Register registers a subtype for used by the service handler.
|
||||
func Register(s globals.Subtype, maskManager handlers.MaskManager, af attributeFunc, sf setAttributeFunc, vsf validateSessionStateFunc) {
|
||||
func Register(s subtypes.Subtype, maskManager handlers.MaskManager, af attributeFunc, sf setAttributeFunc, vsf validateSessionStateFunc) {
|
||||
if _, existed := subtypeRegistry.LoadOrStore(s, ®istryEntry{
|
||||
maskManager: maskManager,
|
||||
attrFunc: af,
|
||||
|
||||
@@ -26,6 +26,7 @@ import (
|
||||
pbs "github.com/hashicorp/boundary/internal/gen/controller/api/services"
|
||||
intglobals "github.com/hashicorp/boundary/internal/globals"
|
||||
"github.com/hashicorp/boundary/internal/host"
|
||||
"github.com/hashicorp/boundary/internal/host/plugin"
|
||||
"github.com/hashicorp/boundary/internal/host/static"
|
||||
"github.com/hashicorp/boundary/internal/kms"
|
||||
"github.com/hashicorp/boundary/internal/perms"
|
||||
@@ -94,7 +95,7 @@ var (
|
||||
action.List,
|
||||
}
|
||||
|
||||
validateCredentialSourcesFn = func(context.Context, globals.Subtype, []target.CredentialSource) error { return nil }
|
||||
validateCredentialSourcesFn = func(context.Context, subtypes.Subtype, []target.CredentialSource) error { return nil }
|
||||
ValidateIngressWorkerFilterFn = IngressWorkerFilterUnsupported
|
||||
AuthorizeSessionWorkerFilterFn = AuthorizeSessionWithWorkerFilter
|
||||
PostSessionAuthorizationCallback = DefaultPostSessionAuthorizationCallback
|
||||
@@ -799,7 +800,7 @@ func (s Service) AuthorizeSession(ctx context.Context, req *pbs.AuthorizeSession
|
||||
for _, hSource := range hostSources {
|
||||
hsId := hSource.Id()
|
||||
switch subtypes.SubtypeFromId(hostDomain, hsId) {
|
||||
case globals.StaticSubtype:
|
||||
case static.Subtype:
|
||||
eps, err := staticHostRepo.Endpoints(ctx, hsId)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
@@ -2038,7 +2039,7 @@ func validateAuthorizeSessionRequest(req *pbs.AuthorizeSessionRequest) error {
|
||||
}
|
||||
if req.GetHostId() != "" {
|
||||
switch subtypes.SubtypeFromId(hostDomain, req.GetHostId()) {
|
||||
case globals.StaticSubtype, globals.PluginSubtype:
|
||||
case static.Subtype, plugin.Subtype:
|
||||
default:
|
||||
badFields[globals.HostIdField] = "Incorrectly formatted identifier."
|
||||
}
|
||||
|
||||
@@ -156,7 +156,7 @@ func TestGet(t *testing.T) {
|
||||
CreatedTime: tar.GetCreateTime().GetTimestamp(),
|
||||
UpdatedTime: tar.GetUpdateTime().GetTimestamp(),
|
||||
Scope: &scopes.ScopeInfo{Id: proj.GetPublicId(), Type: scope.Project.String(), ParentScopeId: o.GetPublicId()},
|
||||
Type: globals.TcpSubtype.String(),
|
||||
Type: tcp.Subtype.String(),
|
||||
HostSourceIds: []string{hs[0].GetPublicId(), hs[1].GetPublicId()},
|
||||
Attrs: &pb.Target_TcpTargetAttributes{},
|
||||
SessionMaxSeconds: wrapperspb.UInt32(28800),
|
||||
@@ -175,7 +175,7 @@ func TestGet(t *testing.T) {
|
||||
CreatedTime: tarAddr.GetCreateTime().GetTimestamp(),
|
||||
UpdatedTime: tarAddr.GetUpdateTime().GetTimestamp(),
|
||||
Scope: &scopes.ScopeInfo{Id: proj.GetPublicId(), Type: scope.Project.String(), ParentScopeId: o.GetPublicId()},
|
||||
Type: globals.TcpSubtype.String(),
|
||||
Type: tcp.Subtype.String(),
|
||||
Attrs: &pb.Target_TcpTargetAttributes{},
|
||||
SessionMaxSeconds: wrapperspb.UInt32(28800),
|
||||
SessionConnectionLimit: wrapperspb.Int32(-1),
|
||||
@@ -299,7 +299,7 @@ func TestList(t *testing.T) {
|
||||
CreatedTime: tar.GetCreateTime().GetTimestamp(),
|
||||
UpdatedTime: tar.GetUpdateTime().GetTimestamp(),
|
||||
Version: tar.GetVersion(),
|
||||
Type: globals.TcpSubtype.String(),
|
||||
Type: tcp.Subtype.String(),
|
||||
Attrs: &pb.Target_TcpTargetAttributes{},
|
||||
SessionMaxSeconds: wrapperspb.UInt32(28800),
|
||||
SessionConnectionLimit: wrapperspb.Int32(-1),
|
||||
@@ -316,7 +316,7 @@ func TestList(t *testing.T) {
|
||||
CreatedTime: tar.GetCreateTime().GetTimestamp(),
|
||||
UpdatedTime: tar.GetUpdateTime().GetTimestamp(),
|
||||
Version: tar.GetVersion(),
|
||||
Type: globals.TcpSubtype.String(),
|
||||
Type: tcp.Subtype.String(),
|
||||
Attrs: &pb.Target_TcpTargetAttributes{},
|
||||
SessionMaxSeconds: wrapperspb.UInt32(28800),
|
||||
SessionConnectionLimit: wrapperspb.Int32(-1),
|
||||
@@ -586,7 +586,7 @@ func TestCreate(t *testing.T) {
|
||||
ScopeId: proj.GetPublicId(),
|
||||
Name: wrapperspb.String("name"),
|
||||
Description: wrapperspb.String("desc"),
|
||||
Type: globals.TcpSubtype.String(),
|
||||
Type: tcp.Subtype.String(),
|
||||
Attrs: &pb.Target_TcpTargetAttributes{
|
||||
TcpTargetAttributes: &pb.TcpTargetAttributes{
|
||||
DefaultPort: wrapperspb.UInt32(2),
|
||||
@@ -602,7 +602,7 @@ func TestCreate(t *testing.T) {
|
||||
Scope: &scopes.ScopeInfo{Id: proj.GetPublicId(), Type: scope.Project.String(), ParentScopeId: org.GetPublicId()},
|
||||
Name: wrapperspb.String("name"),
|
||||
Description: wrapperspb.String("desc"),
|
||||
Type: globals.TcpSubtype.String(),
|
||||
Type: tcp.Subtype.String(),
|
||||
Attrs: &pb.Target_TcpTargetAttributes{
|
||||
TcpTargetAttributes: &pb.TcpTargetAttributes{
|
||||
DefaultPort: wrapperspb.UInt32(2),
|
||||
@@ -623,7 +623,7 @@ func TestCreate(t *testing.T) {
|
||||
ScopeId: proj.GetPublicId(),
|
||||
Name: wrapperspb.String("name"),
|
||||
Description: wrapperspb.String("desc"),
|
||||
Type: globals.TcpSubtype.String(),
|
||||
Type: tcp.Subtype.String(),
|
||||
EgressWorkerFilter: wrapperspb.String(`type == "bar"`),
|
||||
}},
|
||||
err: handlers.ApiErrorWithCode(codes.InvalidArgument),
|
||||
@@ -633,7 +633,7 @@ func TestCreate(t *testing.T) {
|
||||
req: &pbs.CreateTargetRequest{Item: &pb.Target{
|
||||
Name: wrapperspb.String("name"),
|
||||
Description: wrapperspb.String("desc"),
|
||||
Type: globals.TcpSubtype.String(),
|
||||
Type: tcp.Subtype.String(),
|
||||
Attrs: &pb.Target_TcpTargetAttributes{
|
||||
TcpTargetAttributes: &pb.TcpTargetAttributes{
|
||||
DefaultPort: wrapperspb.UInt32(2),
|
||||
@@ -818,7 +818,7 @@ func TestUpdate(t *testing.T) {
|
||||
{Id: hs[1].GetPublicId(), HostCatalogId: hs[1].GetCatalogId()},
|
||||
}
|
||||
|
||||
ttar, err := target.New(ctx, globals.TcpSubtype, proj.GetPublicId(),
|
||||
ttar, err := target.New(ctx, tcp.Subtype, proj.GetPublicId(),
|
||||
target.WithName("default"),
|
||||
target.WithDescription("default"),
|
||||
target.WithSessionMaxSeconds(1),
|
||||
@@ -871,7 +871,7 @@ func TestUpdate(t *testing.T) {
|
||||
Description: wrapperspb.String("desc"),
|
||||
SessionMaxSeconds: wrapperspb.UInt32(3600),
|
||||
SessionConnectionLimit: wrapperspb.Int32(5),
|
||||
Type: globals.TcpSubtype.String(),
|
||||
Type: tcp.Subtype.String(),
|
||||
},
|
||||
},
|
||||
res: &pbs.UpdateTargetResponse{
|
||||
@@ -881,7 +881,7 @@ func TestUpdate(t *testing.T) {
|
||||
Scope: &scopes.ScopeInfo{Id: proj.GetPublicId(), Type: scope.Project.String(), ParentScopeId: org.GetPublicId()},
|
||||
Name: wrapperspb.String("name"),
|
||||
Description: wrapperspb.String("desc"),
|
||||
Type: globals.TcpSubtype.String(),
|
||||
Type: tcp.Subtype.String(),
|
||||
Attrs: &pb.Target_TcpTargetAttributes{
|
||||
TcpTargetAttributes: &pb.TcpTargetAttributes{
|
||||
DefaultPort: wrapperspb.UInt32(2),
|
||||
@@ -907,7 +907,7 @@ func TestUpdate(t *testing.T) {
|
||||
Item: &pb.Target{
|
||||
Name: wrapperspb.String("name"),
|
||||
Description: wrapperspb.String("desc"),
|
||||
Type: globals.TcpSubtype.String(),
|
||||
Type: tcp.Subtype.String(),
|
||||
},
|
||||
},
|
||||
res: &pbs.UpdateTargetResponse{
|
||||
@@ -918,7 +918,7 @@ func TestUpdate(t *testing.T) {
|
||||
Name: wrapperspb.String("name"),
|
||||
Description: wrapperspb.String("desc"),
|
||||
CreatedTime: tar.GetCreateTime().GetTimestamp(),
|
||||
Type: globals.TcpSubtype.String(),
|
||||
Type: tcp.Subtype.String(),
|
||||
Attrs: &pb.Target_TcpTargetAttributes{
|
||||
TcpTargetAttributes: &pb.TcpTargetAttributes{
|
||||
DefaultPort: wrapperspb.UInt32(2),
|
||||
@@ -1018,7 +1018,7 @@ func TestUpdate(t *testing.T) {
|
||||
Scope: &scopes.ScopeInfo{Id: proj.GetPublicId(), Type: scope.Project.String(), ParentScopeId: org.GetPublicId()},
|
||||
Name: wrapperspb.String("default"),
|
||||
CreatedTime: tar.GetCreateTime().GetTimestamp(),
|
||||
Type: globals.TcpSubtype.String(),
|
||||
Type: tcp.Subtype.String(),
|
||||
Attrs: &pb.Target_TcpTargetAttributes{
|
||||
TcpTargetAttributes: &pb.TcpTargetAttributes{
|
||||
DefaultPort: wrapperspb.UInt32(2),
|
||||
@@ -1053,7 +1053,7 @@ func TestUpdate(t *testing.T) {
|
||||
Name: wrapperspb.String("updated"),
|
||||
Description: wrapperspb.String("default"),
|
||||
CreatedTime: tar.GetCreateTime().GetTimestamp(),
|
||||
Type: globals.TcpSubtype.String(),
|
||||
Type: tcp.Subtype.String(),
|
||||
Attrs: &pb.Target_TcpTargetAttributes{
|
||||
TcpTargetAttributes: &pb.TcpTargetAttributes{
|
||||
DefaultPort: wrapperspb.UInt32(2),
|
||||
@@ -1094,7 +1094,7 @@ func TestUpdate(t *testing.T) {
|
||||
DefaultClientPort: wrapperspb.UInt32(3),
|
||||
},
|
||||
},
|
||||
Type: globals.TcpSubtype.String(),
|
||||
Type: tcp.Subtype.String(),
|
||||
HostSourceIds: hostSourceIds,
|
||||
HostSources: hostSources,
|
||||
SessionMaxSeconds: wrapperspb.UInt32(tar.GetSessionMaxSeconds()),
|
||||
@@ -1306,7 +1306,7 @@ func TestUpdate_BadVersion(t *testing.T) {
|
||||
repo, err := repoFn()
|
||||
require.NoError(t, err, "Couldn't create new target repo.")
|
||||
|
||||
ttar, err := target.New(ctx, globals.TcpSubtype, proj.GetPublicId(), target.WithName("default"), target.WithDescription("default"))
|
||||
ttar, err := target.New(ctx, tcp.Subtype, proj.GetPublicId(), target.WithName("default"), target.WithDescription("default"))
|
||||
tar := ttar.(*tcp.Target)
|
||||
tar.DefaultPort = 2
|
||||
tar.DefaultClientPort = 3
|
||||
@@ -2544,7 +2544,7 @@ func TestAuthorizeSession(t *testing.T) {
|
||||
CredentialStoreId: vaultStore.GetPublicId(),
|
||||
Name: wrapperspb.String("Library Name"),
|
||||
Description: wrapperspb.String("Library Description"),
|
||||
Type: globals.VaultGenericLibrarySubtype.String(),
|
||||
Type: vault.GenericLibrarySubtype.String(),
|
||||
Attrs: &credlibpb.CredentialLibrary_VaultCredentialLibraryAttributes{
|
||||
VaultCredentialLibraryAttributes: &credlibpb.VaultCredentialLibraryAttributes{
|
||||
Path: &wrapperspb.StringValue{
|
||||
@@ -2659,7 +2659,7 @@ func TestAuthorizeSession(t *testing.T) {
|
||||
Name: clsResp.GetItem().GetName().GetValue(),
|
||||
Description: clsResp.GetItem().GetDescription().GetValue(),
|
||||
CredentialStoreId: vaultStore.GetPublicId(),
|
||||
Type: globals.VaultGenericLibrarySubtype.String(),
|
||||
Type: vault.GenericLibrarySubtype.String(),
|
||||
},
|
||||
},
|
||||
},
|
||||
@@ -2791,7 +2791,7 @@ func TestAuthorizeSessionTypedCredentials(t *testing.T) {
|
||||
CredentialStoreId: vaultStore.GetPublicId(),
|
||||
Name: wrapperspb.String("Usernamepassword Library"),
|
||||
Description: wrapperspb.String("Usernamepassword Library Description"),
|
||||
Type: globals.VaultGenericLibrarySubtype.String(),
|
||||
Type: vault.GenericLibrarySubtype.String(),
|
||||
Attrs: &credlibpb.CredentialLibrary_VaultCredentialLibraryAttributes{
|
||||
VaultCredentialLibraryAttributes: &credlibpb.VaultCredentialLibraryAttributes{
|
||||
Path: wrapperspb.String(path.Join("secret", "data", "default-userpass")),
|
||||
@@ -2806,7 +2806,7 @@ func TestAuthorizeSessionTypedCredentials(t *testing.T) {
|
||||
CredentialStoreId: vaultStore.GetPublicId(),
|
||||
Name: wrapperspb.String("Unspecified Library"),
|
||||
Description: wrapperspb.String("Unspecified Library Description"),
|
||||
Type: globals.VaultGenericLibrarySubtype.String(),
|
||||
Type: vault.GenericLibrarySubtype.String(),
|
||||
Attrs: &credlibpb.CredentialLibrary_VaultCredentialLibraryAttributes{
|
||||
VaultCredentialLibraryAttributes: &credlibpb.VaultCredentialLibraryAttributes{
|
||||
Path: wrapperspb.String(path.Join("secret", "data", "default-userpass")),
|
||||
@@ -2824,7 +2824,7 @@ func TestAuthorizeSessionTypedCredentials(t *testing.T) {
|
||||
CredentialStoreId: vaultStore.GetPublicId(),
|
||||
Name: wrapperspb.String("Usernamepassword Mapping Library"),
|
||||
Description: wrapperspb.String("Usernamepassword Mapping Library Description"),
|
||||
Type: globals.VaultGenericLibrarySubtype.String(),
|
||||
Type: vault.GenericLibrarySubtype.String(),
|
||||
Attrs: &credlibpb.CredentialLibrary_VaultCredentialLibraryAttributes{
|
||||
VaultCredentialLibraryAttributes: &credlibpb.VaultCredentialLibraryAttributes{
|
||||
Path: wrapperspb.String(path.Join("secret", "data", "non-default-userpass")),
|
||||
@@ -2844,7 +2844,7 @@ func TestAuthorizeSessionTypedCredentials(t *testing.T) {
|
||||
require.NoError(t, err)
|
||||
upCredResp, err := credService.CreateCredential(ctx, &pbs.CreateCredentialRequest{Item: &credpb.Credential{
|
||||
CredentialStoreId: staticStore.GetPublicId(),
|
||||
Type: globals.UsernamePasswordSubtype.String(),
|
||||
Type: credential.UsernamePasswordSubtype.String(),
|
||||
Name: wrapperspb.String("Cred Name"),
|
||||
Description: wrapperspb.String("Cred Description"),
|
||||
Attrs: &credpb.Credential_UsernamePasswordAttributes{
|
||||
@@ -2859,7 +2859,7 @@ func TestAuthorizeSessionTypedCredentials(t *testing.T) {
|
||||
|
||||
sshPkCredResp, err := credService.CreateCredential(ctx, &pbs.CreateCredentialRequest{Item: &credpb.Credential{
|
||||
CredentialStoreId: staticStore.GetPublicId(),
|
||||
Type: globals.SshPrivateKeySubtype.String(),
|
||||
Type: credential.SshPrivateKeySubtype.String(),
|
||||
Name: wrapperspb.String("Cred SSH Name"),
|
||||
Description: wrapperspb.String("Cred SSH Description"),
|
||||
Attrs: &credpb.Credential_SshPrivateKeyAttributes{
|
||||
@@ -2874,7 +2874,7 @@ func TestAuthorizeSessionTypedCredentials(t *testing.T) {
|
||||
|
||||
sshPkWithPassCredResp, err := credService.CreateCredential(ctx, &pbs.CreateCredentialRequest{Item: &credpb.Credential{
|
||||
CredentialStoreId: staticStore.GetPublicId(),
|
||||
Type: globals.SshPrivateKeySubtype.String(),
|
||||
Type: credential.SshPrivateKeySubtype.String(),
|
||||
Name: wrapperspb.String("Cred SSH With Pass Name"),
|
||||
Description: wrapperspb.String("Cred SSH Description"),
|
||||
Attrs: &credpb.Credential_SshPrivateKeyAttributes{
|
||||
@@ -2896,7 +2896,7 @@ func TestAuthorizeSessionTypedCredentials(t *testing.T) {
|
||||
CredentialStoreId: vaultStore.GetPublicId(),
|
||||
Name: wrapperspb.String("SSH Private Key Library"),
|
||||
Description: wrapperspb.String("SSH Private Key Library Description"),
|
||||
Type: globals.VaultGenericLibrarySubtype.String(),
|
||||
Type: vault.GenericLibrarySubtype.String(),
|
||||
Attrs: &credlibpb.CredentialLibrary_VaultCredentialLibraryAttributes{
|
||||
VaultCredentialLibraryAttributes: &credlibpb.VaultCredentialLibraryAttributes{
|
||||
Path: wrapperspb.String(path.Join("secret", "data", "default-sshpk")),
|
||||
@@ -2915,7 +2915,7 @@ func TestAuthorizeSessionTypedCredentials(t *testing.T) {
|
||||
CredentialStoreId: vaultStore.GetPublicId(),
|
||||
Name: wrapperspb.String("SSH Private Key Mapping Library"),
|
||||
Description: wrapperspb.String("SSH Private Key Mapping Library Description"),
|
||||
Type: globals.VaultGenericLibrarySubtype.String(),
|
||||
Type: vault.GenericLibrarySubtype.String(),
|
||||
Attrs: &credlibpb.CredentialLibrary_VaultCredentialLibraryAttributes{
|
||||
VaultCredentialLibraryAttributes: &credlibpb.VaultCredentialLibraryAttributes{
|
||||
Path: wrapperspb.String(path.Join("secret", "data", "non-default-sshpk")),
|
||||
@@ -2938,7 +2938,7 @@ func TestAuthorizeSessionTypedCredentials(t *testing.T) {
|
||||
CredentialStoreId: vaultStore.GetPublicId(),
|
||||
Name: wrapperspb.String("SSH Private Key With Passphrase Library"),
|
||||
Description: wrapperspb.String("SSH Private Key Library Description"),
|
||||
Type: globals.VaultGenericLibrarySubtype.String(),
|
||||
Type: vault.GenericLibrarySubtype.String(),
|
||||
Attrs: &credlibpb.CredentialLibrary_VaultCredentialLibraryAttributes{
|
||||
VaultCredentialLibraryAttributes: &credlibpb.VaultCredentialLibraryAttributes{
|
||||
Path: wrapperspb.String(path.Join("secret", "data", "default-sshpk-with-pass")),
|
||||
@@ -2958,7 +2958,7 @@ func TestAuthorizeSessionTypedCredentials(t *testing.T) {
|
||||
CredentialStoreId: vaultStore.GetPublicId(),
|
||||
Name: wrapperspb.String("SSH Private Key With Passphrase Mapping Library"),
|
||||
Description: wrapperspb.String("SSH Private Key Mapping Library Description"),
|
||||
Type: globals.VaultGenericLibrarySubtype.String(),
|
||||
Type: vault.GenericLibrarySubtype.String(),
|
||||
Attrs: &credlibpb.CredentialLibrary_VaultCredentialLibraryAttributes{
|
||||
VaultCredentialLibraryAttributes: &credlibpb.VaultCredentialLibraryAttributes{
|
||||
Path: wrapperspb.String(path.Join("secret", "data", "non-default-sshpk-with-pass")),
|
||||
@@ -2995,7 +2995,7 @@ func TestAuthorizeSessionTypedCredentials(t *testing.T) {
|
||||
Name: clsRespUnspecified.GetItem().GetName().GetValue(),
|
||||
Description: clsRespUnspecified.GetItem().GetDescription().GetValue(),
|
||||
CredentialStoreId: vaultStore.GetPublicId(),
|
||||
Type: globals.VaultGenericLibrarySubtype.String(),
|
||||
Type: vault.GenericLibrarySubtype.String(),
|
||||
},
|
||||
},
|
||||
},
|
||||
@@ -3011,7 +3011,7 @@ func TestAuthorizeSessionTypedCredentials(t *testing.T) {
|
||||
Name: clsRespUsernamePassword.GetItem().GetName().GetValue(),
|
||||
Description: clsRespUsernamePassword.GetItem().GetDescription().GetValue(),
|
||||
CredentialStoreId: vaultStore.GetPublicId(),
|
||||
Type: globals.VaultGenericLibrarySubtype.String(),
|
||||
Type: vault.GenericLibrarySubtype.String(),
|
||||
CredentialType: string(globals.UsernamePasswordCredentialType),
|
||||
},
|
||||
Credential: func() *structpb.Struct {
|
||||
@@ -3037,7 +3037,7 @@ func TestAuthorizeSessionTypedCredentials(t *testing.T) {
|
||||
Name: clsRespUsernamePasswordWithMapping.GetItem().GetName().GetValue(),
|
||||
Description: clsRespUsernamePasswordWithMapping.GetItem().GetDescription().GetValue(),
|
||||
CredentialStoreId: vaultStore.GetPublicId(),
|
||||
Type: globals.VaultGenericLibrarySubtype.String(),
|
||||
Type: vault.GenericLibrarySubtype.String(),
|
||||
CredentialType: string(globals.UsernamePasswordCredentialType),
|
||||
},
|
||||
Credential: func() *structpb.Struct {
|
||||
@@ -3063,7 +3063,7 @@ func TestAuthorizeSessionTypedCredentials(t *testing.T) {
|
||||
Name: upCredResp.GetItem().GetName().GetValue(),
|
||||
Description: upCredResp.GetItem().GetDescription().GetValue(),
|
||||
CredentialStoreId: staticStore.GetPublicId(),
|
||||
Type: globals.StaticSubtype.String(),
|
||||
Type: credstatic.Subtype.String(),
|
||||
CredentialType: string(globals.UsernamePasswordCredentialType),
|
||||
},
|
||||
Credential: func() *structpb.Struct {
|
||||
@@ -3089,7 +3089,7 @@ func TestAuthorizeSessionTypedCredentials(t *testing.T) {
|
||||
Name: sshPkCredResp.GetItem().GetName().GetValue(),
|
||||
Description: sshPkCredResp.GetItem().GetDescription().GetValue(),
|
||||
CredentialStoreId: staticStore.GetPublicId(),
|
||||
Type: globals.StaticSubtype.String(),
|
||||
Type: credstatic.Subtype.String(),
|
||||
CredentialType: string(globals.SshPrivateKeyCredentialType),
|
||||
},
|
||||
Credential: func() *structpb.Struct {
|
||||
@@ -3115,7 +3115,7 @@ func TestAuthorizeSessionTypedCredentials(t *testing.T) {
|
||||
Name: clsRespSshPrivateKey.GetItem().GetName().GetValue(),
|
||||
Description: clsRespSshPrivateKey.GetItem().GetDescription().GetValue(),
|
||||
CredentialStoreId: vaultStore.GetPublicId(),
|
||||
Type: globals.VaultGenericLibrarySubtype.String(),
|
||||
Type: vault.GenericLibrarySubtype.String(),
|
||||
CredentialType: string(globals.SshPrivateKeyCredentialType),
|
||||
},
|
||||
Credential: func() *structpb.Struct {
|
||||
@@ -3141,7 +3141,7 @@ func TestAuthorizeSessionTypedCredentials(t *testing.T) {
|
||||
Name: clsRespSshPrivateKeyWithMapping.GetItem().GetName().GetValue(),
|
||||
Description: clsRespSshPrivateKeyWithMapping.GetItem().GetDescription().GetValue(),
|
||||
CredentialStoreId: vaultStore.GetPublicId(),
|
||||
Type: globals.VaultGenericLibrarySubtype.String(),
|
||||
Type: vault.GenericLibrarySubtype.String(),
|
||||
CredentialType: string(globals.SshPrivateKeyCredentialType),
|
||||
},
|
||||
Credential: func() *structpb.Struct {
|
||||
@@ -3167,7 +3167,7 @@ func TestAuthorizeSessionTypedCredentials(t *testing.T) {
|
||||
Name: sshPkWithPassCredResp.GetItem().GetName().GetValue(),
|
||||
Description: sshPkWithPassCredResp.GetItem().GetDescription().GetValue(),
|
||||
CredentialStoreId: staticStore.GetPublicId(),
|
||||
Type: globals.StaticSubtype.String(),
|
||||
Type: credstatic.Subtype.String(),
|
||||
CredentialType: string(globals.SshPrivateKeyCredentialType),
|
||||
},
|
||||
Credential: func() *structpb.Struct {
|
||||
@@ -3194,7 +3194,7 @@ func TestAuthorizeSessionTypedCredentials(t *testing.T) {
|
||||
Name: clsRespSshPrivateKeyWithPass.GetItem().GetName().GetValue(),
|
||||
Description: clsRespSshPrivateKeyWithPass.GetItem().GetDescription().GetValue(),
|
||||
CredentialStoreId: vaultStore.GetPublicId(),
|
||||
Type: globals.VaultGenericLibrarySubtype.String(),
|
||||
Type: vault.GenericLibrarySubtype.String(),
|
||||
CredentialType: string(globals.SshPrivateKeyCredentialType),
|
||||
},
|
||||
Credential: func() *structpb.Struct {
|
||||
@@ -3221,7 +3221,7 @@ func TestAuthorizeSessionTypedCredentials(t *testing.T) {
|
||||
Name: clsRespSshPrivateKeyWithPassWithMapping.GetItem().GetName().GetValue(),
|
||||
Description: clsRespSshPrivateKeyWithPassWithMapping.GetItem().GetDescription().GetValue(),
|
||||
CredentialStoreId: vaultStore.GetPublicId(),
|
||||
Type: globals.VaultGenericLibrarySubtype.String(),
|
||||
Type: vault.GenericLibrarySubtype.String(),
|
||||
CredentialType: string(globals.SshPrivateKeyCredentialType),
|
||||
},
|
||||
Credential: func() *structpb.Struct {
|
||||
@@ -3435,7 +3435,7 @@ func TestAuthorizeSession_Errors(t *testing.T) {
|
||||
clsResp, err := credService.CreateCredentialLibrary(ctx, &pbs.CreateCredentialLibraryRequest{Item: &credlibpb.CredentialLibrary{
|
||||
CredentialStoreId: store.GetPublicId(),
|
||||
Description: wrapperspb.String(fmt.Sprintf("Library Description for target %q", tar.GetName())),
|
||||
Type: globals.VaultGenericLibrarySubtype.String(),
|
||||
Type: vault.GenericLibrarySubtype.String(),
|
||||
Attrs: &credlibpb.CredentialLibrary_VaultCredentialLibraryAttributes{
|
||||
VaultCredentialLibraryAttributes: &credlibpb.VaultCredentialLibraryAttributes{
|
||||
Path: wrapperspb.String(path.Join("database", "creds", "opened")),
|
||||
@@ -3460,7 +3460,7 @@ func TestAuthorizeSession_Errors(t *testing.T) {
|
||||
clsResp, err := credService.CreateCredentialLibrary(ctx, &pbs.CreateCredentialLibraryRequest{Item: &credlibpb.CredentialLibrary{
|
||||
CredentialStoreId: store.GetPublicId(),
|
||||
Description: wrapperspb.String(fmt.Sprintf("Library Description for target %q", tar.GetName())),
|
||||
Type: globals.VaultGenericLibrarySubtype.String(),
|
||||
Type: vault.GenericLibrarySubtype.String(),
|
||||
Attrs: &credlibpb.CredentialLibrary_VaultCredentialLibraryAttributes{
|
||||
VaultCredentialLibraryAttributes: &credlibpb.VaultCredentialLibraryAttributes{
|
||||
Path: wrapperspb.String("bad path"),
|
||||
@@ -3485,7 +3485,7 @@ func TestAuthorizeSession_Errors(t *testing.T) {
|
||||
clsResp, err := credService.CreateCredentialLibrary(ctx, &pbs.CreateCredentialLibraryRequest{Item: &credlibpb.CredentialLibrary{
|
||||
CredentialStoreId: expiredStore.GetPublicId(),
|
||||
Description: wrapperspb.String(fmt.Sprintf("Library Description for target %q", tar.GetName())),
|
||||
Type: globals.VaultGenericLibrarySubtype.String(),
|
||||
Type: vault.GenericLibrarySubtype.String(),
|
||||
Attrs: &credlibpb.CredentialLibrary_VaultCredentialLibraryAttributes{
|
||||
VaultCredentialLibraryAttributes: &credlibpb.VaultCredentialLibraryAttributes{
|
||||
Path: wrapperspb.String(path.Join("database", "creds", "opened")),
|
||||
|
||||
@@ -8,12 +8,12 @@ import (
|
||||
"math"
|
||||
|
||||
"github.com/golang/protobuf/ptypes/wrappers"
|
||||
"github.com/hashicorp/boundary/globals"
|
||||
"github.com/hashicorp/boundary/internal/daemon/controller/handlers"
|
||||
"github.com/hashicorp/boundary/internal/daemon/controller/handlers/targets"
|
||||
"github.com/hashicorp/boundary/internal/session"
|
||||
"github.com/hashicorp/boundary/internal/target"
|
||||
"github.com/hashicorp/boundary/internal/target/store"
|
||||
"github.com/hashicorp/boundary/internal/target/tcp"
|
||||
tcpStore "github.com/hashicorp/boundary/internal/target/tcp/store"
|
||||
pb "github.com/hashicorp/boundary/sdk/pbs/controller/api/resources/targets"
|
||||
)
|
||||
@@ -129,5 +129,5 @@ func init() {
|
||||
panic(err)
|
||||
}
|
||||
|
||||
targets.Register(globals.TcpSubtype, maskManager, newAttribute, setAttributes, noopSessionValidation)
|
||||
targets.Register(tcp.Subtype, maskManager, newAttribute, setAttributes, noopSessionValidation)
|
||||
}
|
||||
Reference in new issue
Block a user