hammer_cli_katello 1.5.3 → 1.7.0

Sign up to get free protection for your applications and to get access to all the features.
@@ -2,7 +2,7 @@ require File.join(File.dirname(__FILE__), '../test_helper')
2
2
 
3
3
  describe 'create content-credentials' do
4
4
  before do
5
- @cmd = %w(alternate-content-sources create)
5
+ @cmd = %w(alternate-content-source create)
6
6
  end
7
7
 
8
8
  let(:name) { 'pizza' }
@@ -7,7 +7,7 @@ describe 'delete an acs' do
7
7
  api_expects(:alternate_content_sources, :destroy, 'delete acs').
8
8
  with_params('id' => id)
9
9
 
10
- command = %W(alternate-content-sources delete --id #{id})
10
+ command = %W(alternate-content-source delete --id #{id})
11
11
  assert_equal(0, run_cmd(command).exit_code)
12
12
  end
13
13
  end
@@ -3,7 +3,7 @@ require 'hammer_cli_katello/associating_commands'
3
3
 
4
4
  describe 'get acs info' do
5
5
  before do
6
- @cmd = %w(alternate-content-sources info)
6
+ @cmd = %w(alternate-content-source info)
7
7
  end
8
8
 
9
9
  it 'shows acs info by id' do
@@ -14,20 +14,17 @@ describe 'get acs info' do
14
14
  'name' => 'Pizza ACS',
15
15
  'label' => 'Pizza ACS',
16
16
  'base_url' => 'https://proxy.example.com',
17
- 'alternate_content_source_type' => 'custom',
18
17
  'content_type' => 'yum',
18
+ 'alternate_content_source_type' => 'custom',
19
+ 'subpaths' => [
20
+ 'test/repo1'
21
+ ],
19
22
  'smart_proxies' => {
20
23
  'id' => 1,
21
24
  'name' => 'centos7.example.com',
22
25
  'url' => 'https://centos7.example.com:9090',
23
- 'created_at' => '2022-05-09T17:40:21.007Z',
24
- 'updated_at' => '2022-05-09T17:40:21.007Z',
25
- 'expired_logs' => 0,
26
26
  'download_policy' => 'on_demand'
27
- },
28
- 'subpaths' => [
29
- 'test/repo1'
30
- ]
27
+ }
31
28
  )
32
29
  result = run_cmd(@cmd + params)
33
30
  # rubocop:disable Style/WordArray
@@ -35,18 +32,60 @@ describe 'get acs info' do
35
32
  ['Name', 'Pizza ACS'],
36
33
  ['Label', 'Pizza ACS'],
37
34
  ['Base URL', 'https://proxy.example.com'],
35
+ ['Content type', 'yum'],
38
36
  ['Alternate content source type', 'custom'],
37
+ ['Subpaths', ''],
38
+ ['', 'test/repo1'],
39
+ ['Smart proxies', ''],
40
+ ['Id', '1'],
41
+ ['Name', 'centos7.example.com'],
42
+ ['URL', 'https://centos7.example.com:9090'],
43
+ ['Download policy', 'on_demand']]
44
+
45
+ # rubocop:enable Style/WordArray
46
+ expected_results = expected_fields.map { |field| success_result(FieldMatcher.new(*field)) }
47
+ expected_results.each { |expected| assert_cmd(expected, result) }
48
+ end
49
+
50
+ it 'shows simplified acs info by id' do
51
+ params = ['--id=2']
52
+ ex = api_expects(:alternate_content_sources, :show, 'Get info')
53
+ ex.returns(
54
+ 'id' => 2,
55
+ 'name' => 'Pizza ACS',
56
+ 'label' => 'Pizza ACS',
57
+ 'content_type' => 'yum',
58
+ 'alternate_content_source_type' => 'simplified',
59
+ 'products' => {
60
+ 'id' => 999,
61
+ 'organization_id' => 9,
62
+ 'name' => 'Buttermilk Biscuits',
63
+ 'label' => 'Buttermilk_Biscuits'
64
+ },
65
+ 'smart_proxies' => {
66
+ 'id' => 1,
67
+ 'name' => 'centos7.example.com',
68
+ 'url' => 'https://centos7.example.com:9090',
69
+ 'download_policy' => 'on_demand'
70
+ }
71
+ )
72
+ result = run_cmd(@cmd + params)
73
+ # rubocop:disable Style/WordArray
74
+ expected_fields = [['ID', '2'],
75
+ ['Name', 'Pizza ACS'],
76
+ ['Label', 'Pizza ACS'],
39
77
  ['Content type', 'yum'],
78
+ ['Alternate content source type', 'simplified'],
79
+ ['Products', ''],
80
+ ['Id', '999'],
81
+ ['Organization ID', '9'],
82
+ ['Name', 'Buttermilk Biscuits'],
83
+ ['Label', 'Buttermilk_Biscuits'],
40
84
  ['Smart proxies', ''],
41
85
  ['Id', '1'],
42
86
  ['Name', 'centos7.example.com'],
43
87
  ['URL', 'https://centos7.example.com:9090'],
44
- ['Created at', '2022-05-09T17:40:21.007Z'],
45
- ['Updated at', '2022-05-09T17:40:21.007Z'],
46
- ['Expired logs', '0'],
47
- ['Download policy', 'on_demand'],
48
- ['Subpaths', ''],
49
- ['', 'test/repo1']]
88
+ ['Download policy', 'on_demand']]
50
89
 
51
90
  # rubocop:enable Style/WordArray
52
91
  expected_results = expected_fields.map { |field| success_result(FieldMatcher.new(*field)) }
@@ -2,7 +2,7 @@ require File.join(File.dirname(__FILE__), '../test_helper')
2
2
 
3
3
  describe 'listing acs' do
4
4
  before do
5
- @cmd = %w(alternate-content-sources list)
5
+ @cmd = %w(alternate-content-source list)
6
6
  end
7
7
 
8
8
  let(:empty_response) do
@@ -2,7 +2,7 @@ require File.join(File.dirname(__FILE__), '../test_helper')
2
2
 
3
3
  describe 'listing acs' do
4
4
  before do
5
- @cmd = %w(alternate-content-sources update)
5
+ @cmd = %w(alternate-content-source update)
6
6
  end
7
7
 
8
8
  let(:id) { 1 }
@@ -178,7 +178,9 @@ describe 'content-export complete repository' do
178
178
 
179
179
  it 'Errors out on lazy repositories' do
180
180
  params = ["--id=#{repository_id}"]
181
- expects_repository(repository_id, "download_policy" => "on_demand", "id" => repository_id)
181
+ expects_repository(repository_id, "content_type" => 'yum',
182
+ "download_policy" => "on_demand",
183
+ "id" => repository_id)
182
184
 
183
185
  ex = api_expects(:content_exports, :repository)
184
186
  ex.returns(response)
@@ -189,7 +189,9 @@ describe 'content-export incremental version' do
189
189
 
190
190
  it 'Errors out on lazy repositories' do
191
191
  params = ["--id=#{repository_id}"]
192
- expects_repository(repository_id, "download_policy" => "on_demand", "id" => repository_id)
192
+ expects_repository(repository_id, "content_type" => 'yum',
193
+ "download_policy" => "on_demand",
194
+ "id" => repository_id)
193
195
 
194
196
  ex = api_expects(:content_export_incrementals, :repository)
195
197
  ex.returns(response)
@@ -0,0 +1,39 @@
1
+ require File.join(File.dirname(__FILE__), '../../test_helper')
2
+
3
+ describe 'host enabled-repositories listing' do
4
+ before do
5
+ @cmd = %w(host subscription enabled-repositories)
6
+ end
7
+
8
+ let(:host_id) { 1 }
9
+ let(:empty_response) do
10
+ {
11
+ "total" => 0,
12
+ "subtotal" => 0,
13
+ "page" => "1",
14
+ "per_page" => "1000",
15
+ "error" => nil,
16
+ "search" => nil,
17
+ "sort" => {
18
+ "by" => nil,
19
+ "order" => nil
20
+ },
21
+ "results" => []
22
+ }
23
+ end
24
+
25
+ it 'allows listing by host' do
26
+ params = ["--host-id=#{host_id}"]
27
+ ex = api_expects(:host_subscriptions,
28
+ :enabled_repositories, 'host subscription enabled-repositories')
29
+ ex.returns(empty_response)
30
+ # rubocop:disable Layout/LineLength
31
+ expected_result = success_result("---|------|-------|--------------|----------|-----------------|-------------------|----------------------|------------------|-------------
32
+ ID | NAME | LABEL | CONTENT TYPE | CHECKSUM | CONTENT VIEW ID | CONTENT VIEW NAME | CONTENT VIEW VERSION | ENVIRONMENT NAME | PRODUCT NAME
33
+ ---|------|-------|--------------|----------|-----------------|-------------------|----------------------|------------------|-------------
34
+ ")
35
+ # rubocop:enable Layout/LineLength
36
+ result = run_cmd(@cmd + params)
37
+ assert_cmd(expected_result, result)
38
+ end
39
+ end
@@ -1,4 +1,5 @@
1
1
  require_relative '../test_helper'
2
+ require_relative './organization_helpers'
2
3
  require 'hammer_cli_katello/organization'
3
4
  require 'hammer_cli_katello/associating_commands'
4
5
 
@@ -65,4 +65,42 @@ ID | NAME | PRODUCT | CONTENT TYPE | URL
65
65
  result = run_cmd(@cmd + params)
66
66
  assert_cmd(expected_result, result)
67
67
  end
68
+
69
+ it "lists the repositories with a certain repository type" do
70
+ params = ['--organization-id=1', '--content-type=yum']
71
+
72
+ ex = api_expects(:repositories, :index, 'yum repositories list') do |par|
73
+ par['organization_id'] == org_id && par['page'] == 1 &&
74
+ par['per_page'] == 1000
75
+ end
76
+
77
+ ex.returns(empty_response)
78
+
79
+ expected_result = CommandExpectation.new("---|------|---------|--------------|----
80
+ ID | NAME | PRODUCT | CONTENT TYPE | URL
81
+ ---|------|---------|--------------|----
82
+ ")
83
+
84
+ result = run_cmd(@cmd + params)
85
+ assert_cmd(expected_result, result)
86
+ end
87
+
88
+ it "lists the repositories with a certain content unit type" do
89
+ params = ['--organization-id=1', '--with-content=srpm']
90
+
91
+ ex = api_expects(:repositories, :index, 'yum repositories list') do |par|
92
+ par['organization_id'] == org_id && par['page'] == 1 &&
93
+ par['per_page'] == 1000
94
+ end
95
+
96
+ ex.returns(empty_response)
97
+
98
+ expected_result = CommandExpectation.new("---|------|---------|--------------|----
99
+ ID | NAME | PRODUCT | CONTENT TYPE | URL
100
+ ---|------|---------|--------------|----
101
+ ")
102
+
103
+ result = run_cmd(@cmd + params)
104
+ assert_cmd(expected_result, result)
105
+ end
68
106
  end
@@ -31,7 +31,8 @@ module HammerCLIKatello
31
31
  p['id'] == 1 && p['ids'] == %w(20 21 22)
32
32
  end
33
33
 
34
- run_cmd(%w(repository remove-content --name repo1 --product-id 3 --ids 20,21,22))
34
+ run_cmd(%w(repository remove-content --name repo1 --product-id 3 --ids 20,21,22
35
+ --content-type rpm))
35
36
  end
36
37
  end
37
38
 
@@ -0,0 +1,120 @@
1
+
2
+ require File.join(File.dirname(__FILE__), '../test_helper')
3
+
4
+ describe 'repository types' do
5
+ before do
6
+ @cmd = %w(repository types)
7
+ end
8
+
9
+ let(:empty_response) do
10
+ {
11
+ "total" => 0,
12
+ "subtotal" => 0,
13
+ "page" => "1",
14
+ "per_page" => "1000",
15
+ "error" => nil,
16
+ "search" => nil,
17
+ "sort" => {
18
+ "by" => nil,
19
+ "order" => nil
20
+ },
21
+ "results" => []
22
+ }
23
+ end
24
+
25
+ let(:types_response) do
26
+ {
27
+ "results" => [
28
+ {
29
+ "name": "file",
30
+ "id": "file",
31
+ "creatable": true,
32
+ "pulp3_support": true,
33
+ "generic_remote_options": [],
34
+ "import_attributes": [],
35
+ "url_description": nil,
36
+ "content_types": [
37
+ {
38
+ "label": "file",
39
+ "generic_browser": nil,
40
+ "generic": false,
41
+ "removable": true,
42
+ "uploadable": true,
43
+ "indexed": true
44
+ }
45
+ ]
46
+ },
47
+ {
48
+ "name": "yum",
49
+ "id": "yum",
50
+ "creatable": true,
51
+ "pulp3_support": true,
52
+ "generic_remote_options": [],
53
+ "import_attributes": [],
54
+ "url_description": nil,
55
+ "content_types": [
56
+ {
57
+ "label": "rpm",
58
+ "generic_browser": nil,
59
+ "generic": false,
60
+ "removable": true,
61
+ "uploadable": true,
62
+ "indexed": true
63
+ },
64
+ {
65
+ "label": "modulemd",
66
+ "generic_browser": nil,
67
+ "generic": false,
68
+ "removable": false,
69
+ "uploadable": false,
70
+ "indexed": true
71
+ }
72
+ ]
73
+ }
74
+ ]
75
+ }
76
+ end
77
+
78
+ it "lists repository types and returns empty response" do
79
+ ex = api_expects(:repositories, :repository_types, 'repository types')
80
+
81
+ ex.returns(empty_response)
82
+
83
+ expected_result = success_result("\n\n")
84
+
85
+ result = run_cmd(@cmd)
86
+ assert_cmd(expected_result, result)
87
+ end
88
+
89
+ it "lists repository types and returns response" do
90
+ ex = api_expects(:repositories, :repository_types, 'repository types')
91
+
92
+ ex.returns(types_response)
93
+ # rubocop:disable Style/TrailingWhitespace
94
+ expected_result = success_result("Name: file
95
+ Content types:
96
+ 1) Type: file
97
+ Generic?: false
98
+ Removable?: true
99
+ Uploadable?: true
100
+ Indexed?: true
101
+
102
+ Name: yum
103
+ Content types:
104
+ 1) Type: rpm
105
+ Generic?: false
106
+ Removable?: true
107
+ Uploadable?: true
108
+ Indexed?: true
109
+ 2) Type: modulemd
110
+ Generic?: false
111
+ Removable?: false
112
+ Uploadable?: false
113
+ Indexed?: true
114
+
115
+ ")
116
+ # rubocop:enable Style/TrailingWhitespace
117
+ result = run_cmd(@cmd)
118
+ assert_cmd(expected_result, result)
119
+ end
120
+ end
@@ -0,0 +1,29 @@
1
+ require File.join(File.dirname(__FILE__), '../../test_helper')
2
+
3
+ describe 'simple-content-access status' do
4
+ before do
5
+ @cmd = %w(simple-content-access status)
6
+ end
7
+
8
+ let(:organization_id) { 3 }
9
+
10
+ it 'list status with required options' do
11
+ params = ["--organization-id=#{organization_id}"]
12
+ api_expects(:simple_content_access, :status).
13
+ with_params('organization_id' => organization_id).
14
+ returns('simple_content_access' => true)
15
+
16
+ run_cmd(@cmd + params)
17
+ end
18
+
19
+ it 'fails on missing required params' do
20
+ params = []
21
+ result = run_cmd(@cmd + params)
22
+ # rubocop:disable Layout/LineLength
23
+ expected_error = 'Could not find organization, please set one of options --organization-id, --organization, --organization-title, --organization-label.'
24
+ # rubocop:enable Layout/LineLength
25
+
26
+ assert_equal(result.exit_code, HammerCLI::EX_SOFTWARE)
27
+ assert_equal(result.err[/#{expected_error}/], expected_error)
28
+ end
29
+ end
data/test/test_helper.rb CHANGED
@@ -17,7 +17,7 @@ require 'minitest/spec'
17
17
  require 'mocha/minitest'
18
18
  require 'hammer_cli'
19
19
 
20
- KATELLO_VERSION = Gem::Version.new(ENV['TEST_API_VERSION'] || '4.5')
20
+ KATELLO_VERSION = Gem::Version.new(ENV['TEST_API_VERSION'] || '4.7')
21
21
 
22
22
  if HammerCLI.context[:api_connection]
23
23
  HammerCLI.context[:api_connection].create('foreman') do
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: hammer_cli_katello
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.5.3
4
+ version: 1.7.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Adam Price
@@ -35,7 +35,7 @@ authors:
35
35
  autorequire:
36
36
  bindir: bin
37
37
  cert_chain: []
38
- date: 2022-09-28 00:00:00.000000000 Z
38
+ date: 2022-11-09 00:00:00.000000000 Z
39
39
  dependencies:
40
40
  - !ruby/object:Gem::Dependency
41
41
  name: hammer_cli_foreman
@@ -321,6 +321,8 @@ files:
321
321
  - test/data/4.3/foreman_api.json
322
322
  - test/data/4.4/foreman_api.json
323
323
  - test/data/4.5/foreman_api.json
324
+ - test/data/4.6/foreman_api.json
325
+ - test/data/4.7/foreman_api.json
324
326
  - test/data/Readme.md
325
327
  - test/functional/acs/create_test.rb
326
328
  - test/functional/acs/delete_test.rb
@@ -423,6 +425,7 @@ files:
423
425
  - test/functional/host/subscription/attach_test.rb
424
426
  - test/functional/host/subscription/auto_attach_test.rb
425
427
  - test/functional/host/subscription/content_override_test.rb
428
+ - test/functional/host/subscription/enabled_repositories_test.rb
426
429
  - test/functional/host/subscription/product_content_test.rb
427
430
  - test/functional/host/subscription/register_test.rb
428
431
  - test/functional/host/subscription/remove_test.rb
@@ -478,6 +481,7 @@ files:
478
481
  - test/functional/repository/repository_helpers.rb
479
482
  - test/functional/repository/republish_test.rb
480
483
  - test/functional/repository/synchronize_test.rb
484
+ - test/functional/repository/types_test.rb
481
485
  - test/functional/repository/update_test.rb
482
486
  - test/functional/repository/upload_test.rb
483
487
  - test/functional/repository_set/available_repositories_test.rb
@@ -489,6 +493,7 @@ files:
489
493
  - test/functional/search_helpers.rb
490
494
  - test/functional/simple_content_access/disable_test.rb
491
495
  - test/functional/simple_content_access/enable_test.rb
496
+ - test/functional/simple_content_access/status_test.rb
492
497
  - test/functional/srpm/list_test.rb
493
498
  - test/functional/subscription/list_test.rb
494
499
  - test/functional/sync_plan/create_test.rb
@@ -552,6 +557,8 @@ test_files:
552
557
  - test/data/4.3/foreman_api.json
553
558
  - test/data/4.4/foreman_api.json
554
559
  - test/data/4.5/foreman_api.json
560
+ - test/data/4.6/foreman_api.json
561
+ - test/data/4.7/foreman_api.json
555
562
  - test/data/Readme.md
556
563
  - test/functional/acs/create_test.rb
557
564
  - test/functional/acs/delete_test.rb
@@ -654,6 +661,7 @@ test_files:
654
661
  - test/functional/host/subscription/attach_test.rb
655
662
  - test/functional/host/subscription/auto_attach_test.rb
656
663
  - test/functional/host/subscription/content_override_test.rb
664
+ - test/functional/host/subscription/enabled_repositories_test.rb
657
665
  - test/functional/host/subscription/product_content_test.rb
658
666
  - test/functional/host/subscription/register_test.rb
659
667
  - test/functional/host/subscription/remove_test.rb
@@ -709,6 +717,7 @@ test_files:
709
717
  - test/functional/repository/repository_helpers.rb
710
718
  - test/functional/repository/republish_test.rb
711
719
  - test/functional/repository/synchronize_test.rb
720
+ - test/functional/repository/types_test.rb
712
721
  - test/functional/repository/update_test.rb
713
722
  - test/functional/repository/upload_test.rb
714
723
  - test/functional/repository_set/available_repositories_test.rb
@@ -720,6 +729,7 @@ test_files:
720
729
  - test/functional/search_helpers.rb
721
730
  - test/functional/simple_content_access/disable_test.rb
722
731
  - test/functional/simple_content_access/enable_test.rb
732
+ - test/functional/simple_content_access/status_test.rb
723
733
  - test/functional/srpm/list_test.rb
724
734
  - test/functional/subscription/list_test.rb
725
735
  - test/functional/sync_plan/create_test.rb