Skip to content

Commit

Permalink
Update secret scope validation to include / characters (#892)
Browse files Browse the repository at this point in the history
  • Loading branch information
tylangesmith authored Nov 4, 2021
1 parent 5fe12a4 commit 9921c41
Show file tree
Hide file tree
Showing 2 changed files with 33 additions and 1 deletion.
32 changes: 32 additions & 0 deletions access/resource_secret_acl_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -174,6 +174,38 @@ func TestResourceSecretACLCreate(t *testing.T) {
assert.Equal(t, "global|||something", d.Id())
}

func TestResourceSecretACLCreate_ScopeWithSlash(t *testing.T) {
d, err := qa.ResourceFixture{
Fixtures: []qa.HTTPFixture{
{
Method: "POST",
Resource: "/api/2.0/secrets/acls/put",
ExpectedRequest: SecretACLRequest{
Principal: "something",
Permission: "CAN_MANAGE",
Scope: "myapplication/branch",
},
},
{
Method: "GET",
Resource: "/api/2.0/secrets/acls/get?principal=something&scope=myapplication%2Fbranch",
Response: ACLItem{
Permission: "CAN_MANAGE",
},
},
},
Resource: ResourceSecretACL(),
State: map[string]interface{}{
"permission": "CAN_MANAGE",
"principal": "something",
"scope": "myapplication/branch",
},
Create: true,
}.Apply(t)
assert.NoError(t, err, err)
assert.Equal(t, "myapplication/branch|||something", d.Id())
}

func TestResourceSecretACLCreate_Error(t *testing.T) {
d, err := qa.ResourceFixture{
Fixtures: []qa.HTTPFixture{
Expand Down
2 changes: 1 addition & 1 deletion access/resource_secret_scope.go
Original file line number Diff line number Diff line change
Expand Up @@ -110,7 +110,7 @@ func (a SecretScopesAPI) Read(scopeName string) (SecretScope, error) {
}
}

var validScope = validation.StringMatch(regexp.MustCompile(`^[\w\.@_-]{1,128}$`),
var validScope = validation.StringMatch(regexp.MustCompile(`^[\w\.@_/-]{1,128}$`),
"Must consist of alphanumeric characters, dashes, underscores, and periods, "+
"and may not exceed 128 characters.")

Expand Down

0 comments on commit 9921c41

Please sign in to comment.