Skip to content

Commit 9921c41

Browse files
authored
Update secret scope validation to include / characters (#892)
1 parent 5fe12a4 commit 9921c41

File tree

2 files changed

+33
-1
lines changed

2 files changed

+33
-1
lines changed

access/resource_secret_acl_test.go

Lines changed: 32 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -174,6 +174,38 @@ func TestResourceSecretACLCreate(t *testing.T) {
174174
assert.Equal(t, "global|||something", d.Id())
175175
}
176176

177+
func TestResourceSecretACLCreate_ScopeWithSlash(t *testing.T) {
178+
d, err := qa.ResourceFixture{
179+
Fixtures: []qa.HTTPFixture{
180+
{
181+
Method: "POST",
182+
Resource: "/api/2.0/secrets/acls/put",
183+
ExpectedRequest: SecretACLRequest{
184+
Principal: "something",
185+
Permission: "CAN_MANAGE",
186+
Scope: "myapplication/branch",
187+
},
188+
},
189+
{
190+
Method: "GET",
191+
Resource: "/api/2.0/secrets/acls/get?principal=something&scope=myapplication%2Fbranch",
192+
Response: ACLItem{
193+
Permission: "CAN_MANAGE",
194+
},
195+
},
196+
},
197+
Resource: ResourceSecretACL(),
198+
State: map[string]interface{}{
199+
"permission": "CAN_MANAGE",
200+
"principal": "something",
201+
"scope": "myapplication/branch",
202+
},
203+
Create: true,
204+
}.Apply(t)
205+
assert.NoError(t, err, err)
206+
assert.Equal(t, "myapplication/branch|||something", d.Id())
207+
}
208+
177209
func TestResourceSecretACLCreate_Error(t *testing.T) {
178210
d, err := qa.ResourceFixture{
179211
Fixtures: []qa.HTTPFixture{

access/resource_secret_scope.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -110,7 +110,7 @@ func (a SecretScopesAPI) Read(scopeName string) (SecretScope, error) {
110110
}
111111
}
112112

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

0 commit comments

Comments
 (0)