go fmt on aws path role files

This commit is contained in:
Vishal Nayak 2019-08-16 11:25:33 -04:00
parent 3ce3e40db7
commit 9b878b0717
2 changed files with 14 additions and 15 deletions

View File

@ -266,7 +266,6 @@ func (b *backend) pathRolesWrite(ctx context.Context, req *logical.Request, d *f
roleEntry.UserPath = userPathRaw.(string) roleEntry.UserPath = userPathRaw.(string)
} }
if legacyRole != "" { if legacyRole != "" {
roleEntry = upgradeLegacyPolicyEntry(legacyRole) roleEntry = upgradeLegacyPolicyEntry(legacyRole)
if roleEntry.InvalidData != "" { if roleEntry.InvalidData != "" {
@ -485,8 +484,8 @@ func (r *awsRoleEntry) validate() error {
} }
if r.MaxSTSTTL > 0 && if r.MaxSTSTTL > 0 &&
r.DefaultSTSTTL > 0 && r.DefaultSTSTTL > 0 &&
r.DefaultSTSTTL > r.MaxSTSTTL { r.DefaultSTSTTL > r.MaxSTSTTL {
errors = multierror.Append(errors, fmt.Errorf(`"default_sts_ttl" value must be less than or equal to "max_sts_ttl" value`)) errors = multierror.Append(errors, fmt.Errorf(`"default_sts_ttl" value must be less than or equal to "max_sts_ttl" value`))
} }

View File

@ -217,7 +217,7 @@ func TestUserPathValidity(t *testing.T) {
func TestRoleEntryValidationCredTypes(t *testing.T) { func TestRoleEntryValidationCredTypes(t *testing.T) {
roleEntry := awsRoleEntry{ roleEntry := awsRoleEntry{
CredentialTypes: []string{}, CredentialTypes: []string{},
PolicyArns: []string{"arn:aws:iam::aws:policy/AdministratorAccess"}, PolicyArns: []string{"arn:aws:iam::aws:policy/AdministratorAccess"},
} }
if roleEntry.validate() == nil { if roleEntry.validate() == nil {
t.Errorf("bad: invalid roleEntry with no CredentialTypes %#v passed validation", roleEntry) t.Errorf("bad: invalid roleEntry with no CredentialTypes %#v passed validation", roleEntry)
@ -237,7 +237,7 @@ func TestRoleEntryValidationIamUserCred(t *testing.T) {
roleEntry := awsRoleEntry{ roleEntry := awsRoleEntry{
CredentialTypes: []string{iamUserCred}, CredentialTypes: []string{iamUserCred},
PolicyArns: []string{"arn:aws:iam::aws:policy/AdministratorAccess"}, PolicyArns: []string{"arn:aws:iam::aws:policy/AdministratorAccess"},
} }
err := roleEntry.validate() err := roleEntry.validate()
if err != nil { if err != nil {
@ -256,7 +256,7 @@ func TestRoleEntryValidationIamUserCred(t *testing.T) {
roleEntry = awsRoleEntry{ roleEntry = awsRoleEntry{
CredentialTypes: []string{iamUserCred}, CredentialTypes: []string{iamUserCred},
RoleArns: []string{"arn:aws:iam::123456789012:role/SomeRole"}, RoleArns: []string{"arn:aws:iam::123456789012:role/SomeRole"},
} }
if roleEntry.validate() == nil { if roleEntry.validate() == nil {
t.Errorf("bad: invalid roleEntry with invalid RoleArns parameter %#v passed validation", roleEntry) t.Errorf("bad: invalid roleEntry with invalid RoleArns parameter %#v passed validation", roleEntry)
@ -264,8 +264,8 @@ func TestRoleEntryValidationIamUserCred(t *testing.T) {
roleEntry = awsRoleEntry{ roleEntry = awsRoleEntry{
CredentialTypes: []string{iamUserCred}, CredentialTypes: []string{iamUserCred},
PolicyArns: []string{"arn:aws:iam::aws:policy/AdministratorAccess"}, PolicyArns: []string{"arn:aws:iam::aws:policy/AdministratorAccess"},
DefaultSTSTTL: 1, DefaultSTSTTL: 1,
} }
if roleEntry.validate() == nil { if roleEntry.validate() == nil {
t.Errorf("bad: invalid roleEntry with unrecognized DefaultSTSTTL %#v passed validation", roleEntry) t.Errorf("bad: invalid roleEntry with unrecognized DefaultSTSTTL %#v passed validation", roleEntry)
@ -281,10 +281,10 @@ func TestRoleEntryValidationAssumedRoleCred(t *testing.T) {
var allowAllPolicyDocument = `{"Version": "2012-10-17", "Statement": [{"Sid": "AllowAll", "Effect": "Allow", "Action": "*", "Resource": "*"}]}` var allowAllPolicyDocument = `{"Version": "2012-10-17", "Statement": [{"Sid": "AllowAll", "Effect": "Allow", "Action": "*", "Resource": "*"}]}`
roleEntry := awsRoleEntry{ roleEntry := awsRoleEntry{
CredentialTypes: []string{assumedRoleCred}, CredentialTypes: []string{assumedRoleCred},
RoleArns: []string{"arn:aws:iam::123456789012:role/SomeRole"}, RoleArns: []string{"arn:aws:iam::123456789012:role/SomeRole"},
PolicyDocument: allowAllPolicyDocument, PolicyDocument: allowAllPolicyDocument,
DefaultSTSTTL: 2, DefaultSTSTTL: 2,
MaxSTSTTL: 3, MaxSTSTTL: 3,
} }
if err := roleEntry.validate(); err != nil { if err := roleEntry.validate(); err != nil {
t.Errorf("bad: valid roleEntry %#v failed validation: %v", roleEntry, err) t.Errorf("bad: valid roleEntry %#v failed validation: %v", roleEntry, err)
@ -310,9 +310,9 @@ func TestRoleEntryValidationFederationTokenCred(t *testing.T) {
var allowAllPolicyDocument = `{"Version": "2012-10-17", "Statement": [{"Sid": "AllowAll", "Effect": "Allow", "Action": "*", "Resource": "*"}]}` var allowAllPolicyDocument = `{"Version": "2012-10-17", "Statement": [{"Sid": "AllowAll", "Effect": "Allow", "Action": "*", "Resource": "*"}]}`
roleEntry := awsRoleEntry{ roleEntry := awsRoleEntry{
CredentialTypes: []string{federationTokenCred}, CredentialTypes: []string{federationTokenCred},
PolicyDocument: allowAllPolicyDocument, PolicyDocument: allowAllPolicyDocument,
DefaultSTSTTL: 2, DefaultSTSTTL: 2,
MaxSTSTTL: 3, MaxSTSTTL: 3,
} }
if err := roleEntry.validate(); err != nil { if err := roleEntry.validate(); err != nil {
t.Errorf("bad: valid roleEntry %#v failed validation: %v", roleEntry, err) t.Errorf("bad: valid roleEntry %#v failed validation: %v", roleEntry, err)