Skip to content

Commit 51d3bf4

Browse files
[SWR] rename auth to user_auth for permissions (#421)
[SWR] rename auth to user_auth for permissions auth is reserved field in ansible-collections Reviewed-by: Vladimir Vshivkov Reviewed-by: Artem Lifshits
1 parent a725981 commit 51d3bf4

File tree

9 files changed

+33
-23
lines changed

9 files changed

+33
-23
lines changed

examples/swr/create_organization_permissions.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,7 @@
2626
{
2727
"user_id": "5a23ecb3999b458d92d51d524bb7fb4c",
2828
"user_name": "test",
29-
"auth": 1
29+
"user_auth": 1
3030
}
3131
],
3232
}

examples/swr/update_organization_permissions.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,7 @@
2626
{
2727
"user_id": "5a23ecb3999b458d92d51d524bb7fb4c",
2828
"user_name": "test",
29-
"auth": 3
29+
"user_auth": 3
3030
}
3131
],
3232
}

otcextensions/sdk/swr/v2/_proxy.py

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,12 @@
1818
from otcextensions.sdk.swr.v2 import domain as _domain
1919

2020

21+
def update_permissions_attrs(attrs):
22+
for permission in attrs.get('permissions', []):
23+
permission['auth'] = permission.pop('user_auth', None)
24+
return attrs
25+
26+
2127
class Proxy(proxy.Proxy):
2228
skip_discovery = True
2329

@@ -112,6 +118,7 @@ def create_organization_permissions(self, **attrs):
112118
:returns: The results of organization creation
113119
:rtype: :class:`~otcextensions.sdk.swr.v2.organization.Permission`
114120
"""
121+
attrs = update_permissions_attrs(attrs)
115122
return self._create(_organization.Permission, **attrs)
116123

117124
def organization_permissions(self, namespace, **query):
@@ -153,6 +160,7 @@ def update_organization_permissions(self, **attrs):
153160
154161
:rtype: :class:`~otcextensions.sdk.swr.v2.organization.Permission`
155162
"""
163+
attrs = update_permissions_attrs(attrs)
156164
return self._update(_organization.Permission, **attrs)
157165

158166
def create_repository(self, **attrs):
@@ -235,6 +243,7 @@ def create_repository_permissions(self, **attrs):
235243
:returns: The results of repository permission creation
236244
:rtype: :class:`~otcextensions.sdk.swr.v2.repository.Permission`
237245
"""
246+
attrs = update_permissions_attrs(attrs)
238247
return self._create(_repository.Permission, **attrs)
239248

240249
def repository_permissions(self, namespace, repository, **query):
@@ -281,6 +290,7 @@ def update_repository_permissions(self, **attrs):
281290
282291
:rtype: :class:`~otcextensions.sdk.swr.v2.repository.Permission`
283292
"""
293+
attrs = update_permissions_attrs(attrs)
284294
return self._update(_repository.Permission, **attrs)
285295

286296
def create_domain(self, **attrs):

otcextensions/sdk/swr/v2/organization.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -42,7 +42,7 @@ class Organization(resource.Resource):
4242
#: 3: Write
4343
#: 1: Read
4444
#: *Type:int*
45-
auth = resource.Body('auth', type=int)
45+
user_auth = resource.Body('auth', type=int)
4646

4747

4848
class Auth(resource.Resource):
@@ -55,7 +55,7 @@ class Auth(resource.Resource):
5555
#: 7: Manage
5656
#: 3: Write
5757
#: 1: Read
58-
auth = resource.Body('auth', type=int)
58+
user_auth = resource.Body('auth', type=int)
5959

6060

6161
class Permission(_base.Resource):

otcextensions/tests/functional/sdk/swr/v2/test_organization.py

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -31,7 +31,7 @@ def setUp(self):
3131
{
3232
"user_id": "5a23ecb3999b458d92d51d524bb7fb4b",
3333
"user_name": "pgubina",
34-
"auth": 1
34+
"user_auth": 1
3535
}
3636
]
3737
self.org_perm = self.client.create_organization_permissions(
@@ -47,12 +47,12 @@ def test_list_organizations(self):
4747
def test_get_organization(self):
4848
o = self.client.get_organization(self.org.namespace)
4949
self.assertEqual(self.org.namespace, o.name)
50-
self.assertEqual(7, o.auth)
50+
self.assertEqual(7, o.user_auth)
5151

5252
def test_find_organization(self):
5353
o = self.client.find_organization(self.org_name)
5454
self.assertEqual(self.org.namespace, o.name)
55-
self.assertEqual(7, o.auth)
55+
self.assertEqual(7, o.user_auth)
5656

5757
def test_organization_permissions(self):
5858
o = list(self.client.organization_permissions(self.org.namespace))
@@ -65,11 +65,11 @@ def test_update_organization_permissions(self):
6565
{
6666
"user_id": "5a23ecb3999b458d92d51d524bb7fb4b",
6767
"user_name": "pgubina",
68-
"auth": 3
68+
"user_auth": 3
6969
}
7070
]
7171
)
72-
self.assertEqual(3, o.permissions[0].auth)
72+
self.assertEqual(3, o.permissions[0].user_auth)
7373

7474
def test_delete_organization_permissions(self):
7575
if os.getenv("OS_SWR_PERMISSIONS_RUN"):

otcextensions/tests/functional/sdk/swr/v2/test_repository.py

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -37,7 +37,7 @@ def setUp(self):
3737
{
3838
"user_id": "5a23ecb3999b458d92d51d524bb7fb4b",
3939
"user_name": "pgubina",
40-
"auth": 1
40+
"user_auth": 1
4141
}
4242
]
4343
self.repo_perm = self.client.create_repository_permissions(
@@ -102,8 +102,8 @@ def test_update_repository_permissions(self):
102102
{
103103
"user_id": "5a23ecb3999b458d92d51d524bb7fb4b",
104104
"user_name": "pgubina",
105-
"auth": 3
105+
"user_auth": 3
106106
}
107107
]
108108
)
109-
self.assertEqual(3, o.permissions[0].auth)
109+
self.assertEqual(3, o.permissions[0].user_auth)

otcextensions/tests/unit/sdk/swr/v2/test_organization.py

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -18,15 +18,15 @@
1818
"namespace": "test_create_org_v2",
1919
"id": 21,
2020
"creator_name": "anton",
21-
"auth": 7,
21+
"user_auth": 7,
2222
}
2323

2424
EXAMPLE_PERMISSION = {
2525
"permissions": [
2626
{
2727
"user_id": "5a23ecb3999b458d92d51d524bb7fb4b",
2828
"user_name": "test",
29-
"auth": 1
29+
"user_auth": 1
3030
}
3131
],
3232
"namespace": "test_create_org_v2"
@@ -50,7 +50,7 @@ def test_make_it(self):
5050
self.assertEqual(EXAMPLE['id'], sot.id)
5151
self.assertEqual(EXAMPLE['namespace'], sot.namespace)
5252
self.assertEqual(EXAMPLE['creator_name'], sot.creator_name)
53-
self.assertEqual(EXAMPLE['auth'], sot.auth)
53+
self.assertEqual(EXAMPLE['user_auth'], sot.user_auth)
5454

5555

5656
class TestOrganizationPermissions(base.TestCase):
@@ -73,8 +73,8 @@ def test_make_it(self):
7373
sot.permissions[0].user_id
7474
)
7575
self.assertEqual(
76-
EXAMPLE_PERMISSION['permissions'][0]["auth"],
77-
sot.permissions[0].auth
76+
EXAMPLE_PERMISSION['permissions'][0]["user_auth"],
77+
sot.permissions[0].user_auth
7878
)
7979
self.assertEqual(
8080
EXAMPLE_PERMISSION['permissions'][0]["user_name"],

otcextensions/tests/unit/sdk/swr/v2/test_proxy.py

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -74,7 +74,7 @@ def test_organization_permission_update(self):
7474
{
7575
'user_id': '123',
7676
'user_name': 'test',
77-
'auth': 1
77+
'user_auth': 1
7878
}
7979
],
8080
},
@@ -147,7 +147,7 @@ def test_repository_permission_create(self):
147147
{
148148
'user_id': '123',
149149
'user_name': 'test',
150-
'auth': 1
150+
'user_auth': 1
151151
}
152152
],
153153
},
@@ -188,7 +188,7 @@ def test_repository_permission_update(self):
188188
{
189189
'user_id': '123',
190190
'user_name': 'test',
191-
'auth': 1
191+
'user_auth': 1
192192
}
193193
],
194194
},

otcextensions/tests/unit/sdk/swr/v2/test_repository.py

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,7 @@
2727
{
2828
'user_id': '5a23ecb3999b458d92d51d524bb7fb4b',
2929
'user_name': 'test',
30-
'auth': 1
30+
'user_auth': 1
3131
}
3232
],
3333
'namespace': 'test_create_org_v2',
@@ -75,8 +75,8 @@ def test_make_it(self):
7575
sot.permissions[0].user_id
7676
)
7777
self.assertEqual(
78-
EXAMPLE_PERMISSION['permissions'][0]['auth'],
79-
sot.permissions[0].auth
78+
EXAMPLE_PERMISSION['permissions'][0]['user_auth'],
79+
sot.permissions[0].user_auth
8080
)
8181
self.assertEqual(
8282
EXAMPLE_PERMISSION['permissions'][0]['user_name'],

0 commit comments

Comments
 (0)