@@ -55,17 +55,20 @@ func NewApplicationCredentialClient(providerClient *gophercloud.ProviderClient,
5555}
5656
5757func (c applicationcredentialClient ) ListApplicationCredentials (ctx context.Context , userID string , listOpts applicationcredentials.ListOptsBuilder ) iter.Seq2 [* applicationcredentials.ApplicationCredential , error ] {
58+ userID = GetUserIDOrTokenID (userID , c .client .ProviderClient )
5859 pager := applicationcredentials .List (c .client , userID , listOpts )
5960 return func (yield func (* applicationcredentials.ApplicationCredential , error ) bool ) {
6061 _ = pager .EachPage (ctx , yieldPage (applicationcredentials .ExtractApplicationCredentials , yield ))
6162 }
6263}
6364
6465func (c applicationcredentialClient ) CreateApplicationCredential (ctx context.Context , userID string , opts applicationcredentials.CreateOptsBuilder ) (* applicationcredentials.ApplicationCredential , error ) {
66+ userID = GetUserIDOrTokenID (userID , c .client .ProviderClient )
6567 return applicationcredentials .Create (ctx , c .client , userID , opts ).Extract ()
6668}
6769
6870func (c applicationcredentialClient ) DeleteApplicationCredential (ctx context.Context , userID string , resourceID string ) error {
71+ userID = GetUserIDOrTokenID (userID , c .client .ProviderClient )
6972 return applicationcredentials .Delete (ctx , c .client , userID , resourceID ).ExtractErr ()
7073}
7174
@@ -113,6 +116,19 @@ func (c applicationcredentialClient) GetApplicationCredential(ctx context.Contex
113116 }
114117}
115118
119+ func GetUserIDOrTokenID (userID string , providerClient * gophercloud.ProviderClient ) string {
120+ // FIXME: This is mostly for E2E tests. As soon as ORC supports user resources,
121+ // this will be obsolete as the userID will become a UserRef to an existing user.
122+ if userID == "token" {
123+ tokenID , err := GetAuthenticatedUserID (providerClient )
124+ if err == nil {
125+ return tokenID
126+ }
127+ }
128+
129+ return userID
130+ }
131+
116132func GetAuthenticatedUserID (providerClient * gophercloud.ProviderClient ) (string , error ) {
117133 r := providerClient .GetAuthResult ()
118134 if r == nil {
0 commit comments