Skip to content

Commit 125340a

Browse files
committed
Identity v3: Adding ExpiresAt and DeletedAt fields to Trust results
1 parent 1931200 commit 125340a

File tree

4 files changed

+25
-13
lines changed

4 files changed

+25
-13
lines changed

acceptance/openstack/identity/v3/trusts_test.go

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@ package v3
44

55
import (
66
"testing"
7+
"time"
78

89
"github.com/gophercloud/gophercloud/acceptance/clients"
910
"github.com/gophercloud/gophercloud/acceptance/tools"
@@ -80,11 +81,13 @@ func TestTrustCRUD(t *testing.T) {
8081
th.AssertNoErr(t, err)
8182
defer DeleteUser(t, client, trusteeUser.ID)
8283

84+
expiresAt := time.Now().Add(time.Minute)
8385
// Create a trust.
8486
trust, err := CreateTrust(t, client, trusts.CreateOpts{
8587
TrusteeUserID: trusteeUser.ID,
8688
TrustorUserID: adminUser.ID,
8789
ProjectID: trusteeProject.ID,
90+
ExpiresAt: &expiresAt,
8891
Roles: []trusts.Role{
8992
{
9093
ID: memberRoleID,
@@ -99,6 +102,8 @@ func TestTrustCRUD(t *testing.T) {
99102

100103
p, err := trusts.Get(client, trust.ID).Extract()
101104
th.AssertNoErr(t, err)
105+
th.AssertEquals(t, p.ExpiresAt.IsZero(), false)
106+
th.AssertEquals(t, p.DeletedAt.IsZero(), true)
102107

103108
tools.PrintResource(t, p)
104109
}

openstack/identity/v3/extensions/trusts/results.go

Lines changed: 14 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,8 @@
11
package trusts
22

33
import (
4+
"time"
5+
46
"github.com/gophercloud/gophercloud"
57
"github.com/gophercloud/gophercloud/pagination"
68
)
@@ -75,16 +77,18 @@ func (t trustResult) Extract() (*Trust, error) {
7577
// Trust represents a delegated authorization request between two
7678
// identities.
7779
type Trust struct {
78-
ID string `json:"id"`
79-
Impersonation bool `json:"impersonation"`
80-
TrusteeUserID string `json:"trustee_user_id"`
81-
TrustorUserID string `json:"trustor_user_id"`
82-
RedelegatedTrustID string `json:"redelegated_trust_id"`
83-
RedelegationCount int `json:"redelegation_count,omitempty"`
84-
AllowRedelegation bool `json:"allow_redelegation,omitempty"`
85-
ProjectID string `json:"project_id,omitempty"`
86-
RemainingUses bool `json:"remaining_uses,omitempty"`
87-
Roles []Role `json:"roles,omitempty"`
80+
ID string `json:"id"`
81+
Impersonation bool `json:"impersonation"`
82+
TrusteeUserID string `json:"trustee_user_id"`
83+
TrustorUserID string `json:"trustor_user_id"`
84+
RedelegatedTrustID string `json:"redelegated_trust_id"`
85+
RedelegationCount int `json:"redelegation_count,omitempty"`
86+
AllowRedelegation bool `json:"allow_redelegation,omitempty"`
87+
ProjectID string `json:"project_id,omitempty"`
88+
RemainingUses bool `json:"remaining_uses,omitempty"`
89+
Roles []Role `json:"roles,omitempty"`
90+
DeletedAt time.Time `json:"deleted_at"`
91+
ExpiresAt time.Time `json:"expires_at"`
8892
}
8993

9094
// Role specifies a single role that is granted to a trustee.

openstack/identity/v3/extensions/trusts/testing/fixtures.go

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,9 +4,9 @@ import (
44
"fmt"
55
"net/http"
66
"testing"
7+
"time"
78

89
"github.com/gophercloud/gophercloud/openstack/identity/v3/extensions/trusts"
9-
1010
"github.com/gophercloud/gophercloud/openstack/identity/v3/tokens"
1111
"github.com/gophercloud/gophercloud/testhelper"
1212
"github.com/gophercloud/gophercloud/testhelper/client"
@@ -216,6 +216,8 @@ var FirstTrust = trusts.Trust{
216216
TrusteeUserID: "86c0d5",
217217
TrustorUserID: "a0fdfd",
218218
ProjectID: "0f1233",
219+
ExpiresAt: time.Date(2013, 02, 27, 18, 30, 59, 999999000, time.UTC),
220+
DeletedAt: time.Time{},
219221
}
220222

221223
var SecondTrust = trusts.Trust{
@@ -224,6 +226,8 @@ var SecondTrust = trusts.Trust{
224226
TrusteeUserID: "86c0d5",
225227
TrustorUserID: "3cd2ce",
226228
ProjectID: "0f1233",
229+
ExpiresAt: time.Time{},
230+
DeletedAt: time.Time{},
227231
}
228232

229233
// ExpectedRolesSlice is the slice of roles expected to be returned from ListOutput.

openstack/identity/v3/extensions/trusts/testing/requests_test.go

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4,10 +4,9 @@ import (
44
"testing"
55
"time"
66

7-
"github.com/gophercloud/gophercloud/pagination"
8-
97
"github.com/gophercloud/gophercloud/openstack/identity/v3/extensions/trusts"
108
"github.com/gophercloud/gophercloud/openstack/identity/v3/tokens"
9+
"github.com/gophercloud/gophercloud/pagination"
1110
th "github.com/gophercloud/gophercloud/testhelper"
1211
"github.com/gophercloud/gophercloud/testhelper/client"
1312
)

0 commit comments

Comments
 (0)