Browse Source

Merge "Expose app creds and new attrs in fixtures"

Zuul 1 month ago
parent
commit
7f9ff9585d
2 changed files with 39 additions and 2 deletions
  1. 4
    0
      keystoneauth1/access/access.py
  2. 35
    2
      keystoneauth1/fixture/v3.py

+ 4
- 0
keystoneauth1/access/access.py View File

@@ -741,6 +741,10 @@ class AccessInfoV3(AccessInfo):
741 741
     def application_credential_id(self):
742 742
         return self._data['token']['application_credential']['id']
743 743
 
744
+    @_missingproperty
745
+    def application_credential_access_rules(self):
746
+        return self._data['token']['application_credential']['access_rules']
747
+
744 748
     @property
745 749
     def _oauth(self):
746 750
         return self._data['token']['OS-OAUTH1']

+ 35
- 2
keystoneauth1/fixture/v3.py View File

@@ -61,8 +61,10 @@ class Token(dict):
61 61
                  project_id=None, project_name=None, project_domain_id=None,
62 62
                  project_domain_name=None, domain_id=None, domain_name=None,
63 63
                  trust_id=None, trust_impersonation=None, trustee_user_id=None,
64
-                 trustor_user_id=None, oauth_access_token_id=None,
65
-                 oauth_consumer_id=None, audit_id=None, audit_chain_id=None,
64
+                 trustor_user_id=None, application_credential_id=None,
65
+                 application_credential_access_rules=None,
66
+                 oauth_access_token_id=None, oauth_consumer_id=None,
67
+                 audit_id=None, audit_chain_id=None,
66 68
                  is_admin_project=None, project_is_domain=None):
67 69
         super(Token, self).__init__()
68 70
 
@@ -112,6 +114,11 @@ class Token(dict):
112 114
                                  trustee_user_id=trustee_user_id,
113 115
                                  trustor_user_id=trustor_user_id)
114 116
 
117
+        if application_credential_id:
118
+            self.set_application_credential(
119
+                application_credential_id,
120
+                access_rules=application_credential_access_rules)
121
+
115 122
         if oauth_access_token_id or oauth_consumer_id:
116 123
             self.set_oauth(access_token_id=oauth_access_token_id,
117 124
                            consumer_id=oauth_consumer_id)
@@ -308,6 +315,26 @@ class Token(dict):
308 315
         trust = self.root.setdefault('OS-TRUST:trust', {})
309 316
         trust.setdefault('trustor_user', {})['id'] = value
310 317
 
318
+    @property
319
+    def application_credential_id(self):
320
+        return self.root.get('application_credential', {}).get('id')
321
+
322
+    @application_credential_id.setter
323
+    def application_credential_id(self, value):
324
+        application_credential = self.root.setdefault(
325
+            'application_credential', {})
326
+        application_credential.setdefault('id', value)
327
+
328
+    @property
329
+    def application_credential_access_rules(self):
330
+        return self.root.get('application_credential', {}).get('access_rules')
331
+
332
+    @application_credential_access_rules.setter
333
+    def application_credential_access_rules(self, value):
334
+        application_credential = self.root.setdefault(
335
+            'application_credential', {})
336
+        application_credential.setdefault('access_rules', value)
337
+
311 338
     @property
312 339
     def oauth_access_token_id(self):
313 340
         return self.root.get('OS-OAUTH1', {}).get('access_token_id')
@@ -439,6 +466,12 @@ class Token(dict):
439 466
         self.oauth_access_token_id = access_token_id or uuid.uuid4().hex
440 467
         self.oauth_consumer_id = consumer_id or uuid.uuid4().hex
441 468
 
469
+    def set_application_credential(self, application_credential_id,
470
+                                   access_rules=None):
471
+        self.application_credential_id = application_credential_id
472
+        if access_rules is not None:
473
+            self.application_credential_access_rules = access_rules
474
+
442 475
     @property
443 476
     def service_providers(self):
444 477
         return self.root.get('service_providers')

Loading…
Cancel
Save