Skip to content

Commit

Permalink
Return default_ttl as int64 instead of time.Duration
Browse files Browse the repository at this point in the history
  • Loading branch information
joelthompson committed Aug 22, 2018
1 parent 525a59a commit 419495b
Show file tree
Hide file tree
Showing 3 changed files with 5 additions and 6 deletions.
6 changes: 3 additions & 3 deletions builtin/logical/aws/backend_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -544,7 +544,7 @@ func testAccStepReadPolicy(t *testing.T, name string, value string) logicaltest.
"role_arns": []string(nil),
"policy_document": value,
"credential_types": []string{iamUserCred, federationTokenCred},
"default_sts_ttl": time.Duration(0),
"default_sts_ttl": int64(0),
}
if !reflect.DeepEqual(resp.Data, expected) {
return fmt.Errorf("bad: got: %#v\nexpected: %#v", resp.Data, expected)
Expand Down Expand Up @@ -639,7 +639,7 @@ func TestBackend_iamUserManagedInlinePolicies(t *testing.T) {
"policy_arns": []string{ec2PolicyArn, iamPolicyArn},
"credential_types": []string{iamUserCred},
"role_arns": []string(nil),
"default_sts_ttl": time.Duration(0),
"default_sts_ttl": int64(0),
}
logicaltest.Test(t, logicaltest.TestCase{
AcceptanceTest: true,
Expand Down Expand Up @@ -754,7 +754,7 @@ func testAccStepReadArnPolicy(t *testing.T, name string, value string) logicalte
"role_arns": []string(nil),
"policy_document": "",
"credential_types": []string{iamUserCred},
"default_sts_ttl": time.Duration(0),
"default_sts_ttl": int64(0),
}
if !reflect.DeepEqual(resp.Data, expected) {
return fmt.Errorf("bad: got: %#v\nexpected: %#v", resp.Data, expected)
Expand Down
2 changes: 1 addition & 1 deletion builtin/logical/aws/path_roles.go
Original file line number Diff line number Diff line change
Expand Up @@ -406,7 +406,7 @@ func (r *awsRoleEntry) toResponseData() map[string]interface{} {
"policy_arns": r.PolicyArns,
"role_arns": r.RoleArns,
"policy_document": r.PolicyDocument,
"default_sts_ttl": r.DefaultSTSTTL / time.Second,
"default_sts_ttl": int64(r.DefaultSTSTTL.Seconds()),
}
if r.InvalidData != "" {
respData["invalid_data"] = r.InvalidData
Expand Down
3 changes: 1 addition & 2 deletions builtin/logical/aws/path_user.go
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,6 @@ import (
"context"
"fmt"
"strings"
"time"

"github.com/aws/aws-sdk-go/aws"
"github.com/aws/aws-sdk-go/service/iam"
Expand Down Expand Up @@ -63,7 +62,7 @@ func (b *backend) pathCredsRead(ctx context.Context, req *logical.Request, d *fr
case ok:
ttl = int64(ttlRaw.(int))
case role.DefaultSTSTTL > 0:
ttl = int64(role.DefaultSTSTTL / time.Second)
ttl = int64(role.DefaultSTSTTL.Seconds())
default:
ttl = int64(d.Get("ttl").(int))
}
Expand Down

0 comments on commit 419495b

Please sign in to comment.