simplify policy document in tests use Go verbatim strings (#1549)

This commit is contained in:
Harshavardhana
2022-02-11 11:26:11 -08:00
committed by GitHub
parent ed5cf89776
commit df55d5dcde
2 changed files with 32 additions and 16 deletions

View File

@@ -80,21 +80,22 @@ func TestAddServiceAccount(t *testing.T) {
assert.Equal(201, response.StatusCode, "Status Code is incorrect")
}
requestDataPolicy := map[string]interface{}{"policy": "{" +
"\n \"Version\": \"2012-10-17\"," +
"\n \"Statement\": [" +
"\n {" +
"\n \"Effect\": \"Allow\"," +
"\n \"Action\": [" +
"\n \"s3:GetBucketLocation\"," +
"\n \"s3:GetObject\"" +
"\n ]," +
"\n \"Resource\": [" +
"\n \"arn:aws:s3:::*\"" +
"\n ]" +
"\n }" +
"\n ]" +
"\n}",
requestDataPolicy := map[string]interface{}{"policy": `
{
"Version": "2012-10-17",
"Statement": [
{
"Effect": "Allow",
"Action": [
"s3:GetBucketLocation",
"s3:GetObject"
],
"Resource": [
"arn:aws:s3:::*"
]
}
]
}`,
}
fmt.Println("..............................TestServiceAccountPolicy(): Prepare the PUT")
requestDataJSON, _ = json.Marshal(requestDataPolicy)

View File

@@ -176,8 +176,23 @@ func TestGetServiceAccountPolicy(t *testing.T) {
// Test-1: getServiceAccountPolicy list serviceaccounts for a user
ctx := context.Background()
mockResponse := madmin.InfoServiceAccountResp{
Policy: "{\n \"Version\": \"2012-10-17\",\n \"Statement\": [\n {\n \"Effect\": \"Allow\",\n \"Action\": [\n \"s3:PutObject\"\n ],\n \"Resource\": [\n \"arn:aws:s3:::*\"\n ]\n }\n ]\n}",
Policy: `
{
"Version": "2012-10-17",
"Statement": [
{
"Effect": "Allow",
"Action": [
"s3:PutObject"
],
"Resource": [
"arn:aws:s3:::*"
]
}
]
}`,
}
minioInfoServiceAccountMock = func(ctx context.Context, user string) (madmin.InfoServiceAccountResp, error) {
return mockResponse, nil
}