Skip to content

Commit

Permalink
Merge pull request denverdino#2 from chainone/sts
Browse files Browse the repository at this point in the history
Revert "Moved role test to a separate package: role_test"
  • Loading branch information
chainone committed Aug 11, 2016
2 parents 8c63a99 + 6182dcc commit 9e8c1e8
Showing 1 changed file with 18 additions and 20 deletions.
38 changes: 18 additions & 20 deletions ram/role_test.go
Original file line number Diff line number Diff line change
@@ -1,13 +1,11 @@
package ram_test
package ram

import (
"encoding/json"
"os"
"strconv"
"testing"
"time"

"github.com/denverdino/aliyungo/ram"
)

/*
Expand All @@ -18,32 +16,32 @@ var (
accountId = os.Getenv("AccountId")
roleName = strconv.FormatInt(time.Now().Unix(), 10)

princpal = ram.AssumeRolePolicyPrincpal{RAM: []string{"acs:ram::" + accountId + ":root"}}
princpal = AssumeRolePolicyPrincpal{RAM: []string{"acs:ram::" + accountId + ":root"}}

policyDocument = ram.AssumeRolePolicyDocument{
Statement: []ram.AssumeRolePolicyItem{
ram.AssumeRolePolicyItem{Action: "sts:AssumeRole", Effect: "Allow", Principal: princpal},
policyDocument = AssumeRolePolicyDocument{
Statement: []AssumeRolePolicyItem{
AssumeRolePolicyItem{Action: "sts:AssumeRole", Effect: "Allow", Principal: princpal},
},
Version: "1"}

newPolicyDocument = ram.AssumeRolePolicyDocument{
Statement: []ram.AssumeRolePolicyItem{
ram.AssumeRolePolicyItem{Action: "sts:AssumeRole", Effect: "Deny", Principal: princpal},
newPolicyDocument = AssumeRolePolicyDocument{
Statement: []AssumeRolePolicyItem{
AssumeRolePolicyItem{Action: "sts:AssumeRole", Effect: "Deny", Principal: princpal},
},
Version: "1"}

RoleReq = ram.RoleRequest{
role = RoleRequest{
RoleName: roleName,
AssumeRolePolicyDocument: getAssumeRolePolicyDocumentStr(),
Description: "this is a role for unit test purpose",
}

updateRoleRequest = ram.UpdateRoleRequest{
updateRoleRequest = UpdateRoleRequest{
RoleName: roleName,
NewAssumeRolePolicyDocument: getNewAssumeRolePolicyDocumentStr(),
}

roleQuery = ram.RoleQueryRequest{RoleName: roleName}
roleQuery = RoleQueryRequest{RoleName: roleName}
)

func getAssumeRolePolicyDocumentStr() string {
Expand All @@ -57,16 +55,16 @@ func getNewAssumeRolePolicyDocumentStr() string {
}

func TestCreateRole(t *testing.T) {
client := ram.NewTestClient()
resp, err := client.CreateRole(RoleReq)
client := NewTestClient()
resp, err := client.CreateRole(role)
if err != nil {
t.Errorf("Failed to CreateRole %v", err)
}
t.Logf("pass CreateRole %v", resp)
}

func TestGetRole(t *testing.T) {
client := ram.NewTestClient()
client := NewTestClient()
resp, err := client.GetRole(roleQuery)
if err != nil {
t.Errorf("Failed to GetRole %v", err)
Expand All @@ -75,7 +73,7 @@ func TestGetRole(t *testing.T) {
}

func TestUpdateRole(t *testing.T) {
client := ram.NewTestClient()
client := NewTestClient()
resp, err := client.UpdateRole(updateRoleRequest)
if err != nil {
t.Errorf("Failed to UpdateRole %v", err)
Expand All @@ -84,7 +82,7 @@ func TestUpdateRole(t *testing.T) {
}

func TestListRoles(t *testing.T) {
client := ram.NewTestClient()
client := NewTestClient()
resp, err := client.ListRoles()
if err != nil {
t.Errorf("Failed to ListRoles %v", err)
Expand All @@ -93,8 +91,8 @@ func TestListRoles(t *testing.T) {
}

func TestDeleteRole(t *testing.T) {
client := ram.NewTestClient()
resp, err := client.DeleteRole(ram.RoleQueryRequest{RoleName: roleName})
client := NewTestClient()
resp, err := client.DeleteRole(RoleQueryRequest{RoleName: roleName})
if err != nil {
t.Errorf("Failed to DeleteRole %v", err)
}
Expand Down

0 comments on commit 9e8c1e8

Please sign in to comment.