diff options
author | Kamil TrzciĆski <ayufan@ayufan.eu> | 2018-01-11 14:27:19 +0300 |
---|---|---|
committer | Luke Bennett <lbennett@gitlab.com> | 2018-01-11 21:57:15 +0300 |
commit | 782378e2e9d6ddabae79819521723eefd31b0c19 (patch) | |
tree | 747b0a109319b0e29c597e62f904acb0eda50309 /spec/support | |
parent | 7b030bcd6b4b435e9d9f510a0c7b6e25c76a3ba8 (diff) |
Merge branch 'gcp-fix' into 'master'
Fix GCP redirect
Closes #41867
See merge request gitlab-org/gitlab-ce!16355
(cherry picked from commit 59adc07f00f4f3ea326194d77c31580edfdfb2a4)
b44583e9 Extract GCP billing check as method
cf6258af Fix billing checking
0cdd56e6 Fix link to billing
e52bae3b Fix CheckGcpProjectBillingService spec
b8b2f5ff Fix CheckGcpProjectBillingWorker spec
8ba3e473 Fix GCP Controller spec
1f0a4fe6 Add missing user agent header to GCP client
6ef28ace Add API requirements to docs
0b294fc2 Use new tab for link in flash
cf95756a Refactor GCP redirect test suite
e6012d3e Change failed GCP billing check wording
35598274 Fix breadcumb of clusters show page
cf842986 Update links for GCP instructions
Diffstat (limited to 'spec/support')
-rw-r--r-- | spec/support/google_api/cloud_platform_helpers.rb | 47 |
1 files changed, 43 insertions, 4 deletions
diff --git a/spec/support/google_api/cloud_platform_helpers.rb b/spec/support/google_api/cloud_platform_helpers.rb index 99752ed396e..2fdbddd40c2 100644 --- a/spec/support/google_api/cloud_platform_helpers.rb +++ b/spec/support/google_api/cloud_platform_helpers.rb @@ -10,10 +10,14 @@ module GoogleApi request.session[GoogleApi::CloudPlatform::Client.session_key_for_expires_at] = 1.hour.ago.to_i.to_s end - def stub_google_project_billing_status - redis_double = double - allow(Gitlab::Redis::SharedState).to receive(:with).and_yield(redis_double) - allow(redis_double).to receive(:get).with(CheckGcpProjectBillingWorker.redis_shared_state_key_for('token')).and_return('true') + def stub_cloud_platform_projects_list(options) + WebMock.stub_request(:get, cloud_platform_projects_list_url) + .to_return(cloud_platform_response(cloud_platform_projects_body(options))) + end + + def stub_cloud_platform_projects_get_billing_info(project_id, billing_enabled) + WebMock.stub_request(:get, cloud_platform_projects_get_billing_info_url(project_id)) + .to_return(cloud_platform_response(cloud_platform_projects_billing_info_body(project_id, billing_enabled))) end def stub_cloud_platform_get_zone_cluster(project_id, zone, cluster_id, **options) @@ -46,6 +50,14 @@ module GoogleApi .to_return(status: [500, "Internal Server Error"]) end + def cloud_platform_projects_list_url + "https://cloudresourcemanager.googleapis.com/v1/projects" + end + + def cloud_platform_projects_get_billing_info_url(project_id) + "https://cloudbilling.googleapis.com/v1/projects/#{project_id}/billingInfo" + end + def cloud_platform_get_zone_cluster_url(project_id, zone, cluster_id) "https://container.googleapis.com/v1/projects/#{project_id}/zones/#{zone}/clusters/#{cluster_id}" end @@ -121,5 +133,32 @@ module GoogleApi "endTime": options[:endTime] || '' } end + + def cloud_platform_projects_body(**options) + { + "projects": [ + { + "projectNumber": options[:project_number] || "1234", + "projectId": options[:project_id] || "test-project-1234", + "lifecycleState": "ACTIVE", + "name": options[:name] || "test-project", + "createTime": "2017-12-16T01:48:29.129Z", + "parent": { + "type": "organization", + "id": "12345" + } + } + ] + } + end + + def cloud_platform_projects_billing_info_body(project_id, billing_enabled) + { + "name": "projects/#{project_id}/billingInfo", + "projectId": "#{project_id}", + "billingAccountName": "account-name", + "billingEnabled": billing_enabled + } + end end end |