BigW Consortium Gitlab
Skip to content
Projects
Groups
Snippets
Help
This project
Loading...
Sign in / Register
Toggle navigation
G
gitlab-ce
Project
Overview
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
Registry
Registry
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Commits
Issue Boards
Open sidebar
Forest Godfrey
gitlab-ce
Commits
59c7f46e
Unverified
Commit
59c7f46e
authored
Dec 21, 2017
by
Matija Čupić
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Remove actions for async GCP project billing check
parent
ab2326f8
Show whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
0 additions
and
211 deletions
+0
-211
gcp_controller.rb
app/controllers/projects/clusters/gcp_controller.rb
+0
-31
project.rb
config/routes/project.rb
+0
-2
gcp_controller_spec.rb
spec/controllers/projects/clusters/gcp_controller_spec.rb
+0
-178
No files found.
app/controllers/projects/clusters/gcp_controller.rb
View file @
59c7f46e
...
...
@@ -18,29 +18,6 @@ class Projects::Clusters::GcpController < Projects::ApplicationController
end
end
def
check
respond_to
do
|
format
|
format
.
json
do
Gitlab
::
PollingInterval
.
set_header
(
response
,
interval:
STATUS_POLLING_INTERVAL
)
Gitlab
::
Redis
::
SharedState
.
with
do
|
redis
|
render
json:
{
billing:
redis
.
get
(
CheckGcpProjectBillingWorker
.
redis_shared_state_key_for
(
token_in_session
))
}
end
end
format
.
html
{
render
:check
}
end
end
def
run_check
respond_to
do
|
format
|
format
.
json
do
CheckGcpProjectBillingWorker
.
perform_async
(
token_in_session
)
head
:no_content
end
end
end
def
new
@cluster
=
::
Clusters
::
Cluster
.
new
.
tap
do
|
cluster
|
cluster
.
build_provider_gcp
...
...
@@ -84,14 +61,6 @@ class Projects::Clusters::GcpController < Projects::ApplicationController
end
end
def
authorize_google_project_billing
Gitlab
::
Redis
::
SharedState
.
with
do
|
redis
|
unless
redis
.
get
(
CheckGcpProjectBillingWorker
.
redis_shared_state_key_for
(
token_in_session
))
==
'true'
CheckGcpProjectBillingWorker
.
perform_async
(
token_in_session
)
redirect_to
action:
'check'
end
end
end
def
token_in_session
@token_in_session
||=
...
...
config/routes/project.rb
View file @
59c7f46e
...
...
@@ -192,8 +192,6 @@ constraints(ProjectUrlConstrainer.new) do
get
'/gcp/new'
,
to:
'clusters/gcp#new'
get
'/gcp/login'
,
to:
'clusters/gcp#login'
get
'/gcp/check'
,
to:
'clusters/gcp#check'
post
'/gcp/check'
,
to:
'clusters/gcp#run_check'
post
'/gcp'
,
to:
'clusters/gcp#create'
end
end
...
...
spec/controllers/projects/clusters/gcp_controller_spec.rb
View file @
59c7f46e
...
...
@@ -62,132 +62,6 @@ describe Projects::Clusters::GcpController do
end
end
describe
'GET check'
do
let
(
:user
)
{
create
(
:user
)
}
before
do
project
.
add_master
(
user
)
sign_in
(
user
)
end
describe
'functionality'
do
context
'when access token is valid'
do
before
do
stub_google_api_validate_token
end
context
'when redis has wanted billing status'
do
let
(
:token
)
{
'bogustoken'
}
before
do
redis_double
=
double
allow
(
Gitlab
::
Redis
::
SharedState
).
to
receive
(
:with
).
and_yield
(
redis_double
)
allow
(
redis_double
).
to
receive
(
:get
).
and_return
(
'true'
)
end
it
'should render json with billing status'
do
go
expect
(
response
).
to
have_http_status
(
:ok
)
expect
(
JSON
.
parse
(
response
.
body
)).
to
include
(
'billing'
=>
'true'
)
end
end
context
'when redis does not have billing status'
do
before
do
redis_double
=
double
allow
(
Gitlab
::
Redis
::
SharedState
).
to
receive
(
:with
).
and_yield
(
redis_double
)
allow
(
redis_double
).
to
receive
(
:get
).
and_return
(
nil
)
end
it
'should render json with null billing status'
do
go
expect
(
response
).
to
have_http_status
(
:ok
)
expect
(
JSON
.
parse
(
response
.
body
)).
to
include
(
'billing'
=>
nil
)
end
end
end
context
'when access token is expired'
do
before
do
stub_google_api_expired_token
end
it
{
expect
(
go
).
to
redirect_to
(
gcp_login_project_clusters_path
(
project
))
}
end
context
'when access token is not stored in session'
do
it
{
expect
(
go
).
to
redirect_to
(
gcp_login_project_clusters_path
(
project
))
}
end
end
describe
'security'
do
it
{
expect
{
go
}.
to
be_allowed_for
(
:admin
)
}
it
{
expect
{
go
}.
to
be_allowed_for
(
:owner
).
of
(
project
)
}
it
{
expect
{
go
}.
to
be_allowed_for
(
:master
).
of
(
project
)
}
it
{
expect
{
go
}.
to
be_denied_for
(
:developer
).
of
(
project
)
}
it
{
expect
{
go
}.
to
be_denied_for
(
:reporter
).
of
(
project
)
}
it
{
expect
{
go
}.
to
be_denied_for
(
:guest
).
of
(
project
)
}
it
{
expect
{
go
}.
to
be_denied_for
(
:user
)
}
it
{
expect
{
go
}.
to
be_denied_for
(
:external
)
}
end
def
go
get
:check
,
namespace_id:
project
.
namespace
,
project_id:
project
,
format: :json
end
end
describe
'POST check'
do
let
(
:user
)
{
create
(
:user
)
}
before
do
project
.
add_master
(
user
)
sign_in
(
user
)
end
describe
'functionality'
do
context
'when access token is valid'
do
before
do
stub_google_api_validate_token
end
it
'calls check worker asynchronously'
do
expect
(
CheckGcpProjectBillingWorker
).
to
receive
(
:perform_async
)
expect
(
go
).
to
have_http_status
(
:no_content
)
end
end
context
'when access token is expired'
do
before
do
stub_google_api_expired_token
end
it
{
expect
(
go
).
to
redirect_to
(
gcp_login_project_clusters_path
(
project
))
}
end
context
'when access token is not stored in session'
do
it
{
expect
(
go
).
to
redirect_to
(
gcp_login_project_clusters_path
(
project
))
}
end
end
describe
'security'
do
it
{
expect
{
go
}.
to
be_allowed_for
(
:admin
)
}
it
{
expect
{
go
}.
to
be_allowed_for
(
:owner
).
of
(
project
)
}
it
{
expect
{
go
}.
to
be_allowed_for
(
:master
).
of
(
project
)
}
it
{
expect
{
go
}.
to
be_denied_for
(
:developer
).
of
(
project
)
}
it
{
expect
{
go
}.
to
be_denied_for
(
:reporter
).
of
(
project
)
}
it
{
expect
{
go
}.
to
be_denied_for
(
:guest
).
of
(
project
)
}
it
{
expect
{
go
}.
to
be_denied_for
(
:user
)
}
it
{
expect
{
go
}.
to
be_denied_for
(
:external
)
}
end
def
go
post
:run_check
,
namespace_id:
project
.
namespace
,
project_id:
project
,
format: :json
end
end
describe
'GET new'
do
describe
'functionality'
do
let
(
:user
)
{
create
(
:user
)
}
...
...
@@ -202,11 +76,6 @@ describe Projects::Clusters::GcpController do
stub_google_api_validate_token
end
context
'when google project billing status is true'
do
before
do
stub_google_project_billing_status
end
it
'has new object'
do
go
...
...
@@ -214,27 +83,6 @@ describe Projects::Clusters::GcpController do
end
end
context
'when google project billing status is not true'
do
before
do
redis_double
=
double
allow
(
Gitlab
::
Redis
::
SharedState
).
to
receive
(
:with
).
and_yield
(
redis_double
)
allow
(
redis_double
).
to
receive
(
:get
).
and_return
(
nil
)
end
it
'redirects to check page'
do
allow
(
CheckGcpProjectBillingWorker
).
to
receive
(
:perform_async
)
expect
(
go
).
to
redirect_to
(
gcp_check_project_clusters_path
(
project
))
end
it
'calls gcp project billing check worker'
do
expect
(
CheckGcpProjectBillingWorker
).
to
receive
(
:perform_async
)
go
end
end
end
context
'when access token is expired'
do
before
do
stub_google_api_expired_token
...
...
@@ -289,11 +137,6 @@ describe Projects::Clusters::GcpController do
stub_google_api_validate_token
end
context
'when google project billing status is true'
do
before
do
stub_google_project_billing_status
end
context
'when creates a cluster on gke'
do
it
'creates a new cluster'
do
expect
(
ClusterProvisionWorker
).
to
receive
(
:perform_async
)
...
...
@@ -306,27 +149,6 @@ describe Projects::Clusters::GcpController do
end
end
context
'when google project billing status is not true'
do
before
do
redis_double
=
double
allow
(
Gitlab
::
Redis
::
SharedState
).
to
receive
(
:with
).
and_yield
(
redis_double
)
allow
(
redis_double
).
to
receive
(
:get
).
and_return
(
nil
)
end
it
'redirects to check page'
do
allow
(
CheckGcpProjectBillingWorker
).
to
receive
(
:perform_async
)
expect
(
go
).
to
redirect_to
(
gcp_check_project_clusters_path
(
project
))
end
it
'calls gcp project billing check worker'
do
expect
(
CheckGcpProjectBillingWorker
).
to
receive
(
:perform_async
)
go
end
end
end
context
'when access token is expired'
do
before
do
stub_google_api_expired_token
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment