Skip to content

Commit

Permalink
Increase IAM custom role length validation to match API.
Browse files Browse the repository at this point in the history
  • Loading branch information
rremer committed May 20, 2019
1 parent c7aa148 commit 7970184
Show file tree
Hide file tree
Showing 2 changed files with 3 additions and 3 deletions.
2 changes: 1 addition & 1 deletion google/validation.go
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ const (
ComputeServiceAccountNameRegex = "[0-9]{1,20}[email protected]"

// https://cloud.google.com/iam/docs/understanding-custom-roles#naming_the_role
IAMCustomRoleIDRegex = "^[a-zA-Z0-9_\\.\\-]{1,30}$"
IAMCustomRoleIDRegex = "^[a-zA-Z0-9_\\.\\-]{1,64}$"
)

var (
Expand Down
4 changes: 2 additions & 2 deletions google/validation_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -325,7 +325,7 @@ func TestValidateIAMCustomRoleIDRegex(t *testing.T) {
{TestName: "with numbers", Value: "foobar123"},
{TestName: "with capipals", Value: "FooBar"},
{TestName: "short", Value: "f"},
{TestName: "long", Value: "foobarfoobarfoobarfoobarfoobar"},
{TestName: "long", Value: strings.Repeat("f", 64)},
{TestName: "has a hyphen", Value: "foo-bar"},
{TestName: "has a dot", Value: "foo.bar"},
{TestName: "has an underscore", Value: "foo_bar"},
Expand All @@ -336,7 +336,7 @@ func TestValidateIAMCustomRoleIDRegex(t *testing.T) {
{TestName: "has an slash", Value: "foo/bar", ExpectError: true},
{TestName: "has a dollar", Value: "foo$", ExpectError: true},
{TestName: "has a space", Value: "foo bar", ExpectError: true},
{TestName: "too long", Value: strings.Repeat("f", 31), ExpectError: true},
{TestName: "too long", Value: strings.Repeat("f", 65), ExpectError: true},
}

es := testStringValidationCases(x, validateIAMCustomRoleID)
Expand Down

0 comments on commit 7970184

Please sign in to comment.