hybrid_platforms_conductor 33.3.0 → 33.4.0

Sign up to get free protection for your applications and to get access to all the features.
Files changed (30) hide show
  1. checksums.yaml +4 -4
  2. data/CHANGELOG.md +6 -0
  3. data/README.md +31 -2
  4. data/docs/config_dsl.md +43 -0
  5. data/lib/hybrid_platforms_conductor/bitbucket.rb +134 -90
  6. data/lib/hybrid_platforms_conductor/common_config_dsl/bitbucket.rb +12 -44
  7. data/lib/hybrid_platforms_conductor/common_config_dsl/github.rb +9 -31
  8. data/lib/hybrid_platforms_conductor/confluence.rb +93 -88
  9. data/lib/hybrid_platforms_conductor/credentials.rb +112 -95
  10. data/lib/hybrid_platforms_conductor/deployer.rb +2 -2
  11. data/lib/hybrid_platforms_conductor/github.rb +39 -0
  12. data/lib/hybrid_platforms_conductor/hpc_plugins/provisioner/proxmox.rb +4 -2
  13. data/lib/hybrid_platforms_conductor/hpc_plugins/report/confluence.rb +3 -1
  14. data/lib/hybrid_platforms_conductor/hpc_plugins/secrets_reader/keepass.rb +2 -1
  15. data/lib/hybrid_platforms_conductor/hpc_plugins/secrets_reader/thycotic.rb +3 -1
  16. data/lib/hybrid_platforms_conductor/hpc_plugins/test/bitbucket_conf.rb +4 -1
  17. data/lib/hybrid_platforms_conductor/hpc_plugins/test/github_ci.rb +4 -1
  18. data/lib/hybrid_platforms_conductor/hpc_plugins/test/jenkins_ci_conf.rb +6 -2
  19. data/lib/hybrid_platforms_conductor/hpc_plugins/test/jenkins_ci_masters_ok.rb +6 -2
  20. data/lib/hybrid_platforms_conductor/hpc_plugins/test_report/confluence.rb +3 -1
  21. data/lib/hybrid_platforms_conductor/logger_helpers.rb +7 -1
  22. data/lib/hybrid_platforms_conductor/thycotic.rb +80 -75
  23. data/lib/hybrid_platforms_conductor/version.rb +1 -1
  24. data/spec/hybrid_platforms_conductor_test.rb +6 -0
  25. data/spec/hybrid_platforms_conductor_test/api/credentials_spec.rb +247 -0
  26. data/spec/hybrid_platforms_conductor_test/api/deployer/secrets_reader_plugins/keepass_spec.rb +280 -319
  27. data/spec/hybrid_platforms_conductor_test/api/deployer/secrets_reader_plugins/thycotic_spec.rb +2 -2
  28. data/spec/hybrid_platforms_conductor_test/api/tests_runner/test_plugins/bitbucket_conf_spec.rb +49 -69
  29. data/spec/hybrid_platforms_conductor_test/api/tests_runner/test_plugins/github_ci_spec.rb +29 -39
  30. metadata +18 -2
@@ -39,9 +39,9 @@ describe HybridPlatformsConductor::Deployer do
39
39
  if user.nil?
40
40
  user = 'thycotic_user_from_netrc'
41
41
  password = 'thycotic_password_from_netrc'
42
- expect(HybridPlatformsConductor::Credentials).to receive(:with_credentials_for) do |id, _logger, _logger_stderr, url: nil, &client_code|
42
+ expect(test_deployer.instance_variable_get(:@secrets_readers)[:thycotic]).to receive(:with_credentials_for) do |id, resource: nil, &client_code|
43
43
  expect(id).to eq :thycotic
44
- expect(url).to eq thycotic_url
44
+ expect(resource).to eq thycotic_url
45
45
  client_code.call user, password
46
46
  end
47
47
  end
@@ -5,8 +5,9 @@ describe HybridPlatformsConductor::TestsRunner do
5
5
  context 'with bitbucket_conf' do
6
6
 
7
7
  it 'iterates over defined Bitbucket repos' do
8
- with_repository do
9
- platforms = <<~EO_CONFIG
8
+ with_test_platform(
9
+ { nodes: { 'node' => {} } },
10
+ additional_config: <<~EO_CONFIG
10
11
  bitbucket_repos(
11
12
  url: 'https://my_bb1.my_domain.com',
12
13
  project: 'PR1',
@@ -34,73 +35,52 @@ describe HybridPlatformsConductor::TestsRunner do
34
35
  }
35
36
  )
36
37
  EO_CONFIG
37
- with_platforms platforms do
38
- repos = []
39
- test_config.for_each_bitbucket_repo do |bitbucket, repo_info|
40
- repos << {
41
- bitbucket_url: bitbucket.bitbucket_url,
42
- repo_info: repo_info
43
- }
44
- end
45
- expect(repos).to eq [
46
- {
47
- bitbucket_url: 'https://my_bb1.my_domain.com',
48
- repo_info: {
49
- name: 'repo1',
50
- project: 'PR1',
51
- url: 'https://my_bb1.my_domain.com/scm/pr1/repo1.git',
52
- jenkins_ci_url: nil,
53
- checks: {}
54
- }
55
- },
56
- {
57
- bitbucket_url: 'https://my_bb1.my_domain.com',
58
- repo_info: {
59
- name: 'repo2',
60
- project: 'PR1',
61
- url: 'https://my_bb1.my_domain.com/scm/pr1/repo2.git',
62
- jenkins_ci_url: nil,
63
- checks: {}
64
- }
65
- },
66
- {
67
- bitbucket_url: 'https://my_bb2.my_domain.com',
68
- repo_info: {
69
- name: 'repo3',
70
- project: 'PR2',
71
- url: 'https://my_bb2.my_domain.com/scm/pr2/repo3.git',
72
- jenkins_ci_url: 'https://my_jenkins.com/job/repo3',
73
- checks: {
74
- branch_permissions: [
75
- {
76
- type: 'fast-forward-only',
77
- branch: 'master',
78
- exempted_users: ['toto']
79
- }
80
- ]
81
- }
82
- }
83
- },
84
- {
85
- bitbucket_url: 'https://my_bb2.my_domain.com',
86
- repo_info: {
87
- name: 'repo4',
88
- project: 'PR2',
89
- url: 'https://my_bb2.my_domain.com/scm/pr2/repo4.git',
90
- jenkins_ci_url: 'https://my_jenkins.com/job/repo4',
91
- checks: {
92
- branch_permissions: [
93
- {
94
- type: 'fast-forward-only',
95
- branch: 'master',
96
- exempted_users: ['toto']
97
- }
98
- ]
99
- }
100
- }
101
- }
102
- ]
103
- end
38
+ ) do
39
+ test_tests_runner.tests = [:bitbucket_conf]
40
+ WebMock.disable_net_connect!
41
+ stub_request(:get, 'https://my_bb1.my_domain.com/rest/api/1.0/projects/PR1/repos/repo1/settings/pull-requests').to_return(body: {}.to_json)
42
+ stub_request(:get, 'https://my_bb1.my_domain.com/rest/default-reviewers/1.0/projects/PR1/repos/repo1/conditions').to_return(body: {}.to_json)
43
+ expect(Git).to receive(:ls_remote).with('https://my_bb1.my_domain.com/scm/pr1/repo1.git').and_return(
44
+ 'branches' => { 'master' => { sha: '12345' } },
45
+ 'tags' => { 'v1.0.0' => { sha: '12345' } }
46
+ )
47
+ stub_request(:get, 'https://my_bb1.my_domain.com/rest/api/1.0/projects/PR1/repos/repo2/settings/pull-requests').to_return(body: {}.to_json)
48
+ stub_request(:get, 'https://my_bb1.my_domain.com/rest/default-reviewers/1.0/projects/PR1/repos/repo2/conditions').to_return(body: {}.to_json)
49
+ expect(Git).to receive(:ls_remote).with('https://my_bb1.my_domain.com/scm/pr1/repo2.git').and_return(
50
+ 'branches' => { 'master' => { sha: '12345' } },
51
+ 'tags' => { 'v1.0.0' => { sha: '12345' } }
52
+ )
53
+ stub_request(:get, 'https://my_bb2.my_domain.com/rest/api/1.0/projects/PR2/repos/repo3/settings/pull-requests').to_return(body: {}.to_json)
54
+ stub_request(:get, 'https://my_bb2.my_domain.com/rest/default-reviewers/1.0/projects/PR2/repos/repo3/conditions').to_return(body: {}.to_json)
55
+ stub_request(:get, 'https://my_bb2.my_domain.com/rest/branch-permissions/2.0/projects/PR2/repos/repo3/restrictions').to_return(body: {
56
+ 'values' => [{
57
+ 'type' => 'fast-forward-only',
58
+ 'matcher' => { 'id' => 'refs/heads/master' },
59
+ 'users' => [{ 'name' => 'toto' }],
60
+ 'groups' => [],
61
+ 'accessKeys' => []
62
+ }]
63
+ }.to_json)
64
+ expect(Git).to receive(:ls_remote).with('https://my_bb2.my_domain.com/scm/pr2/repo3.git').and_return(
65
+ 'branches' => { 'master' => { sha: '12345' } },
66
+ 'tags' => { 'v1.0.0' => { sha: '12345' } }
67
+ )
68
+ stub_request(:get, 'https://my_bb2.my_domain.com/rest/api/1.0/projects/PR2/repos/repo4/settings/pull-requests').to_return(body: {}.to_json)
69
+ stub_request(:get, 'https://my_bb2.my_domain.com/rest/default-reviewers/1.0/projects/PR2/repos/repo4/conditions').to_return(body: {}.to_json)
70
+ stub_request(:get, 'https://my_bb2.my_domain.com/rest/branch-permissions/2.0/projects/PR2/repos/repo4/restrictions').to_return(body: {
71
+ 'values' => [{
72
+ 'type' => 'fast-forward-only',
73
+ 'matcher' => { 'id' => 'refs/heads/master' },
74
+ 'users' => [{ 'name' => 'toto' }],
75
+ 'groups' => [],
76
+ 'accessKeys' => []
77
+ }]
78
+ }.to_json)
79
+ expect(Git).to receive(:ls_remote).with('https://my_bb2.my_domain.com/scm/pr2/repo4.git').and_return(
80
+ 'branches' => { 'master' => { sha: '12345' } },
81
+ 'tags' => { 'v1.0.0' => { sha: '12345' } }
82
+ )
83
+ expect(test_tests_runner.run_tests(%w[node])).to eq 0
104
84
  end
105
85
  end
106
86
 
@@ -1,3 +1,5 @@
1
+ require 'octokit'
2
+
1
3
  describe HybridPlatformsConductor::TestsRunner do
2
4
 
3
5
  context 'when checking test plugins' do
@@ -5,8 +7,9 @@ describe HybridPlatformsConductor::TestsRunner do
5
7
  context 'with github_ci' do
6
8
 
7
9
  it 'iterates over defined Github repos' do
8
- with_repository do
9
- platforms = <<~EO_CONFIG
10
+ with_test_platform(
11
+ { nodes: { 'node' => {} } },
12
+ additional_config: <<~EO_CONFIG
10
13
  github_repos(
11
14
  url: 'https://my_gh.my_domain.com',
12
15
  user: 'GH-User1',
@@ -23,45 +26,32 @@ describe HybridPlatformsConductor::TestsRunner do
23
26
  ]
24
27
  )
25
28
  EO_CONFIG
26
- with_platforms platforms do
27
- repos = []
28
- test_config.for_each_github_repo do |github, repo_info|
29
- repos << {
30
- github_url: github.api_endpoint,
31
- repo_info: repo_info
32
- }
29
+ ) do
30
+ ENV['hpc_user_for_github'] = 'test-github-user'
31
+ ENV['hpc_password_for_github'] = 'GHTestToken'
32
+ test_tests_runner.tests = [:github_ci]
33
+ first_time = true
34
+ expect(Octokit::Client).to receive(:new).with(access_token: 'GHTestToken').twice do
35
+ mocked_client = instance_double(Octokit::Client)
36
+ if first_time
37
+ expect(mocked_client).to receive(:repository_workflow_runs).with('GH-User1/repo1').and_return(
38
+ workflow_runs: [{ head_branch: 'master', created_at: '2021-12-01 12:45:11', conclusion: 'success' }]
39
+ )
40
+ expect(mocked_client).to receive(:repository_workflow_runs).with('GH-User1/repo2').and_return(
41
+ workflow_runs: [{ head_branch: 'master', created_at: '2021-12-01 12:45:11', conclusion: 'success' }]
42
+ )
43
+ first_time = false
44
+ else
45
+ expect(mocked_client).to receive(:repository_workflow_runs).with('GH-User2/repo3').and_return(
46
+ workflow_runs: [{ head_branch: 'master', created_at: '2021-12-01 12:45:11', conclusion: 'success' }]
47
+ )
48
+ expect(mocked_client).to receive(:repository_workflow_runs).with('GH-User2/repo4').and_return(
49
+ workflow_runs: [{ head_branch: 'master', created_at: '2021-12-01 12:45:11', conclusion: 'success' }]
50
+ )
33
51
  end
34
- expect(repos).to eq [
35
- {
36
- github_url: 'https://my_gh.my_domain.com/',
37
- repo_info: {
38
- name: 'repo1',
39
- slug: 'GH-User1/repo1'
40
- }
41
- },
42
- {
43
- github_url: 'https://my_gh.my_domain.com/',
44
- repo_info: {
45
- name: 'repo2',
46
- slug: 'GH-User1/repo2'
47
- }
48
- },
49
- {
50
- github_url: 'https://api.github.com/',
51
- repo_info: {
52
- name: 'repo3',
53
- slug: 'GH-User2/repo3'
54
- }
55
- },
56
- {
57
- github_url: 'https://api.github.com/',
58
- repo_info: {
59
- name: 'repo4',
60
- slug: 'GH-User2/repo4'
61
- }
62
- }
63
- ]
52
+ mocked_client
64
53
  end
54
+ expect(test_tests_runner.run_tests(%w[node])).to eq 0
65
55
  end
66
56
  end
67
57
 
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: hybrid_platforms_conductor
3
3
  version: !ruby/object:Gem::Version
4
- version: 33.3.0
4
+ version: 33.4.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Muriel Salvan
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2021-07-02 00:00:00.000000000 Z
11
+ date: 2021-07-05 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: range_operators
@@ -332,6 +332,20 @@ dependencies:
332
332
  - - "~>"
333
333
  - !ruby/object:Gem::Version
334
334
  version: '2.4'
335
+ - !ruby/object:Gem::Dependency
336
+ name: webmock
337
+ requirement: !ruby/object:Gem::Requirement
338
+ requirements:
339
+ - - "~>"
340
+ - !ruby/object:Gem::Version
341
+ version: '3.11'
342
+ type: :development
343
+ prerelease: false
344
+ version_requirements: !ruby/object:Gem::Requirement
345
+ requirements:
346
+ - - "~>"
347
+ - !ruby/object:Gem::Version
348
+ version: '3.11'
335
349
  description: Provides a complete toolset to help DevOps maintain, deploy, monitor
336
350
  and test multiple platforms using various technologies
337
351
  email:
@@ -718,6 +732,7 @@ files:
718
732
  - lib/hybrid_platforms_conductor/current_dir_monitor.rb
719
733
  - lib/hybrid_platforms_conductor/deployer.rb
720
734
  - lib/hybrid_platforms_conductor/executable.rb
735
+ - lib/hybrid_platforms_conductor/github.rb
721
736
  - lib/hybrid_platforms_conductor/hpc_plugins/action/bash.rb
722
737
  - lib/hybrid_platforms_conductor/hpc_plugins/action/interactive.rb
723
738
  - lib/hybrid_platforms_conductor/hpc_plugins/action/my_action.rb.sample
@@ -842,6 +857,7 @@ files:
842
857
  - spec/hybrid_platforms_conductor_test/api/actions_executor/timeout_spec.rb
843
858
  - spec/hybrid_platforms_conductor_test/api/cmd_runner_spec.rb
844
859
  - spec/hybrid_platforms_conductor_test/api/config_spec.rb
860
+ - spec/hybrid_platforms_conductor_test/api/credentials_spec.rb
845
861
  - spec/hybrid_platforms_conductor_test/api/deployer/check_spec.rb
846
862
  - spec/hybrid_platforms_conductor_test/api/deployer/config_dsl_spec.rb
847
863
  - spec/hybrid_platforms_conductor_test/api/deployer/deploy_spec.rb