Skip to content

Commit

Permalink
activation_key: submit org_id when querying subs
Browse files Browse the repository at this point in the history
this is required to work with Katello 4.1
  • Loading branch information
evgeni committed Jun 23, 2021
1 parent a06c19d commit 5503dc8
Show file tree
Hide file tree
Showing 35 changed files with 1,515 additions and 4,066 deletions.
Original file line number Diff line number Diff line change
@@ -1,2 +1,3 @@
bugfixes:
- subscription_info - mark ``organization`` parameter as required, to match Katello
- activation_key - submit organization_id when querying subs, required for Katello 4.1
1 change: 1 addition & 0 deletions plugins/modules/activation_key.py
Original file line number Diff line number Diff line change
Expand Up @@ -282,6 +282,7 @@ def main():
activation_key = module.ensure_entity('activation_keys', module.foreman_params, activation_key, params=scope)

ak_scope = {'activation_key_id': activation_key['id']}
ak_scope.update(scope)
if subscriptions is not None:
desired_subscriptions = []
for subscription in subscriptions:
Expand Down
140 changes: 37 additions & 103 deletions tests/test_playbooks/fixtures/activation_key-0.yml
Original file line number Diff line number Diff line change
Expand Up @@ -11,45 +11,35 @@ interactions:
User-Agent:
- apypie (https://github.com/Apipie/apypie)
method: GET
uri: https://centos7-katello-3-14.yatsu.example.com/api/status
uri: https://foreman.example.org/api/status
response:
body:
string: '{"result":"ok","status":200,"version":"1.24.0","api_version":2}'
string: '{"result":"ok","status":200,"version":"2.5.0","api_version":2}'
headers:
Cache-Control:
- max-age=0, private, must-revalidate
Connection:
- Keep-Alive
Content-Length:
- '63'
Content-Security-Policy:
- 'default-src ''self''; child-src ''self''; connect-src ''self'' ws: wss:;
img-src ''self'' data: *.gravatar.com; script-src ''unsafe-eval'' ''unsafe-inline''
''self''; style-src ''unsafe-inline'' ''self'''
img-src ''self'' data:; script-src ''unsafe-eval'' ''unsafe-inline'' ''self'';
style-src ''unsafe-inline'' ''self'''
Content-Type:
- application/json; charset=utf-8
Date:
- Thu, 12 Dec 2019 15:13:48 GMT
ETag:
- W/"53b0d6d0bf9fce118840f03bbd316797"
Foreman_api_version:
- '2'
Foreman_current_location:
- ; ANY
Foreman_current_organization:
- ; ANY
Foreman_version:
- 1.24.0
- 2.5.0
Keep-Alive:
- timeout=5, max=10000
Server:
- Apache
Set-Cookie:
- _session_id=a07b1f87e6d6baf732c7a9828b3f6145; path=/; secure; HttpOnly; SameSite=Lax
Status:
- 200 OK
- timeout=15, max=100
Strict-Transport-Security:
- max-age=631139040; includeSubdomains
Vary:
- Accept-Encoding
X-Content-Type-Options:
- nosniff
X-Download-Options:
Expand All @@ -58,14 +48,10 @@ interactions:
- sameorigin
X-Permitted-Cross-Domain-Policies:
- none
X-Powered-By:
- Phusion Passenger 4.0.53
X-Request-Id:
- ac55174c-8cd7-4308-9dd3-6a814347f413
X-Runtime:
- '0.086086'
X-XSS-Protection:
- 1; mode=block
content-length:
- '62'
status:
code: 200
message: OK
Expand All @@ -78,19 +64,17 @@ interactions:
- gzip, deflate
Connection:
- keep-alive
Cookie:
- _session_id=a07b1f87e6d6baf732c7a9828b3f6145
User-Agent:
- apypie (https://github.com/Apipie/apypie)
method: GET
uri: https://centos7-katello-3-14.yatsu.example.com/katello/api/organizations?search=name%3D%22Test+Organization%22&per_page=4294967296
uri: https://foreman.example.org/katello/api/organizations?search=name%3D%22Test+Organization%22&per_page=4294967296
response:
body:
string: "{\n \"total\": 2,\n \"subtotal\": 1,\n \"page\": 1,\n \"per_page\"\
: 4294967296,\n \"search\": \"name=\\\"Test Organization\\\"\",\n \"sort\"\
: {\n \"by\": null,\n \"order\": null\n },\n \"results\": [{\"label\"\
:\"Test_Organization\",\"created_at\":\"2019-12-12 15:13:35 UTC\",\"updated_at\"\
:\"2019-12-12 15:13:35 UTC\",\"id\":3,\"name\":\"Test Organization\",\"title\"\
:\"Test_Organization\",\"created_at\":\"2021-06-22 14:20:36 UTC\",\"updated_at\"\
:\"2021-06-22 14:20:38 UTC\",\"id\":4,\"name\":\"Test Organization\",\"title\"\
:\"Test Organization\",\"description\":\"A test organization\"}]\n}\n"
headers:
Cache-Control:
Expand All @@ -99,28 +83,20 @@ interactions:
- Keep-Alive
Content-Security-Policy:
- 'default-src ''self''; child-src ''self''; connect-src ''self'' ws: wss:;
img-src ''self'' data: *.gravatar.com; script-src ''unsafe-eval'' ''unsafe-inline''
''self''; style-src ''unsafe-inline'' ''self'''
img-src ''self'' data:; script-src ''unsafe-eval'' ''unsafe-inline'' ''self'';
style-src ''unsafe-inline'' ''self'''
Content-Type:
- application/json; charset=utf-8
Date:
- Thu, 12 Dec 2019 15:13:48 GMT
ETag:
- W/"8163b611dd00b4069fdd125dbb79385f-gzip"
Foreman_api_version:
- '2'
Foreman_current_location:
- ; ANY
Foreman_current_organization:
- ; ANY
Foreman_version:
- 1.24.0
- 2.5.0
Keep-Alive:
- timeout=5, max=9999
Server:
- Apache
Status:
- 200 OK
- timeout=15, max=99
Strict-Transport-Security:
- max-age=631139040; includeSubdomains
Vary:
Expand All @@ -133,12 +109,6 @@ interactions:
- sameorigin
X-Permitted-Cross-Domain-Policies:
- none
X-Powered-By:
- Phusion Passenger 4.0.53
X-Request-Id:
- f7969669-d262-49b9-b914-d550e36eb80c
X-Runtime:
- '0.025024'
X-XSS-Protection:
- 1; mode=block
content-length:
Expand All @@ -155,12 +125,10 @@ interactions:
- gzip, deflate
Connection:
- keep-alive
Cookie:
- _session_id=a07b1f87e6d6baf732c7a9828b3f6145
User-Agent:
- apypie (https://github.com/Apipie/apypie)
method: GET
uri: https://centos7-katello-3-14.yatsu.example.com/katello/api/organizations/3/activation_keys?search=name%3D%22Test+Activation+Key%22&per_page=4294967296
uri: https://foreman.example.org/katello/api/organizations/4/activation_keys?search=name%3D%22Test+Activation+Key%22&per_page=4294967296
response:
body:
string: '{"total":0,"subtotal":0,"page":1,"per_page":"4294967296","error":null,"search":"name=\"Test
Expand All @@ -174,28 +142,20 @@ interactions:
- Keep-Alive
Content-Security-Policy:
- 'default-src ''self''; child-src ''self''; connect-src ''self'' ws: wss:;
img-src ''self'' data: *.gravatar.com; script-src ''unsafe-eval'' ''unsafe-inline''
''self''; style-src ''unsafe-inline'' ''self'''
img-src ''self'' data:; script-src ''unsafe-eval'' ''unsafe-inline'' ''self'';
style-src ''unsafe-inline'' ''self'''
Content-Type:
- application/json; charset=utf-8
Date:
- Thu, 12 Dec 2019 15:13:48 GMT
ETag:
- W/"654689cec84b94eec4bd8af1e8960bb6-gzip"
Foreman_api_version:
- '2'
Foreman_current_location:
- ; ANY
Foreman_current_organization:
- ; ANY
- 4; Test Organization
Foreman_version:
- 1.24.0
- 2.5.0
Keep-Alive:
- timeout=5, max=9998
Server:
- Apache
Status:
- 200 OK
- timeout=15, max=98
Strict-Transport-Security:
- max-age=631139040; includeSubdomains
Vary:
Expand All @@ -208,12 +168,6 @@ interactions:
- sameorigin
X-Permitted-Cross-Domain-Policies:
- none
X-Powered-By:
- Phusion Passenger 4.0.53
X-Request-Id:
- 5fc22b66-9bd4-4f2c-b912-454133c0751e
X-Runtime:
- '0.023264'
X-XSS-Protection:
- 1; mode=block
content-length:
Expand All @@ -222,7 +176,7 @@ interactions:
code: 200
message: OK
- request:
body: '{"organization_id": 3, "name": "Test Activation Key"}'
body: '{"organization_id": 4, "name": "Test Activation Key"}'
headers:
Accept:
- application/json;version=2
Expand All @@ -234,18 +188,16 @@ interactions:
- '53'
Content-Type:
- application/json
Cookie:
- _session_id=a07b1f87e6d6baf732c7a9828b3f6145
User-Agent:
- apypie (https://github.com/Apipie/apypie)
method: POST
uri: https://centos7-katello-3-14.yatsu.example.com/katello/api/activation_keys
uri: https://foreman.example.org/katello/api/activation_keys
response:
body:
string: ' {"service_level":null,"content_overrides":[],"id":1,"name":"Test
Activation Key","description":null,"unlimited_hosts":true,"auto_attach":null,"content_view_id":null,"environment_id":null,"usage_count":0,"user_id":4,"max_hosts":null,"release_version":null,"purpose_usage":null,"purpose_role":null,"organization_id":3,"organization":{"name":"Test
Organization","label":"Test_Organization","id":3},"created_at":"2019-12-12
15:13:49 UTC","updated_at":"2019-12-12 15:13:49 UTC","content_view":null,"environment":null,"products":[],"host_collections":[],"purpose_addons":[],"permissions":{"view_activation_keys":true,"edit_activation_keys":true,"destroy_activation_keys":true}}
Activation Key","description":null,"unlimited_hosts":true,"auto_attach":true,"content_view_id":null,"environment_id":null,"usage_count":0,"user_id":4,"max_hosts":null,"release_version":null,"purpose_usage":null,"purpose_role":null,"organization_id":4,"organization":{"name":"Test
Organization","label":"Test_Organization","id":4},"created_at":"2021-06-22
14:20:47 UTC","updated_at":"2021-06-22 14:20:47 UTC","content_view":null,"environment":null,"products":[],"host_collections":[],"purpose_addons":[],"permissions":{"view_activation_keys":true,"edit_activation_keys":true,"destroy_activation_keys":true}}
'
headers:
Expand All @@ -255,34 +207,24 @@ interactions:
- Keep-Alive
Content-Security-Policy:
- 'default-src ''self''; child-src ''self''; connect-src ''self'' ws: wss:;
img-src ''self'' data: *.gravatar.com; script-src ''unsafe-eval'' ''unsafe-inline''
''self''; style-src ''unsafe-inline'' ''self'''
img-src ''self'' data:; script-src ''unsafe-eval'' ''unsafe-inline'' ''self'';
style-src ''unsafe-inline'' ''self'''
Content-Type:
- application/json; charset=utf-8
Date:
- Thu, 12 Dec 2019 15:13:48 GMT
ETag:
- W/"1bd3877810664d49341971952ace5567-gzip"
Foreman_api_version:
- '2'
Foreman_current_location:
- ; ANY
Foreman_current_organization:
- ; ANY
- 4; Test Organization
Foreman_version:
- 1.24.0
- 2.5.0
Keep-Alive:
- timeout=5, max=9997
Server:
- Apache
Set-Cookie:
- request_method=POST; path=/; secure; HttpOnly; SameSite=Lax
Status:
- 200 OK
- timeout=15, max=97
Strict-Transport-Security:
- max-age=631139040; includeSubdomains
Vary:
- Accept-Encoding
Transfer-Encoding:
- chunked
X-Content-Type-Options:
- nosniff
X-Download-Options:
Expand All @@ -291,17 +233,9 @@ interactions:
- sameorigin
X-Permitted-Cross-Domain-Policies:
- none
X-Powered-By:
- Phusion Passenger 4.0.53
X-Request-Id:
- 0f026b48-c869-4b86-af0e-c1515066e93b
X-Runtime:
- '0.682141'
X-XSS-Protection:
- 1; mode=block
content-length:
- '674'
status:
code: 200
message: OK
code: 201
message: Created
version: 1
Loading

0 comments on commit 5503dc8

Please sign in to comment.