Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
G
gitlab-ce
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Issues
0
Issues
0
List
Boards
Labels
Milestones
Merge Requests
1
Merge Requests
1
Analytics
Analytics
Repository
Value Stream
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Commits
Issue Boards
Open sidebar
nexedi
gitlab-ce
Commits
fe135fac
Commit
fe135fac
authored
Oct 05, 2017
by
Shinya Maeda
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
authorizations_controller_spec. cluster_policy_spec.
parent
b229637b
Changes
3
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
73 additions
and
2 deletions
+73
-2
app/controllers/google_api/authorizations_controller.rb
app/controllers/google_api/authorizations_controller.rb
+2
-2
spec/controllers/google_api/authorizations_controller_spec.rb
.../controllers/google_api/authorizations_controller_spec.rb
+43
-0
spec/policies/gcp/cluster_policy_spec.rb
spec/policies/gcp/cluster_policy_spec.rb
+28
-0
No files found.
app/controllers/google_api/authorizations_controller.rb
View file @
fe135fac
...
...
@@ -9,10 +9,10 @@ module GoogleApi
session
[
GoogleApi
::
CloudPlatform
::
Client
.
session_key_for_expires_at
]
=
expires_at
.
to_s
if
params
[
:state
]
if
params
[
:state
]
.
present?
redirect_to
params
[
:state
]
else
redirect_to
root_
url
redirect_to
root_
path
end
end
end
...
...
spec/controllers/google_api/authorizations_controller_spec.rb
0 → 100644
View file @
fe135fac
require
'spec_helper'
describe
GoogleApi
::
AuthorizationsController
do
describe
'GET|POST #callback'
do
let
(
:user
)
{
create
(
:user
)
}
let
(
:project
)
{
create
(
:project
)
}
let
(
:state
)
{
namespace_project_clusters_url
(
project
.
namespace
,
project
).
to_s
}
let
(
:token
)
{
'token'
}
let
(
:expires_at
)
{
1
.
hour
.
since
.
strftime
(
'%s'
)
}
subject
{
get
:callback
,
code:
'xxx'
,
state:
state
}
before
do
sign_in
(
user
)
allow_any_instance_of
(
GoogleApi
::
CloudPlatform
::
Client
)
.
to
receive
(
:get_token
).
and_return
([
token
,
expires_at
])
end
it
'sets token and expires_atin session'
do
subject
expect
(
session
[
GoogleApi
::
CloudPlatform
::
Client
.
session_key_for_token
])
.
to
eq
(
token
)
expect
(
session
[
GoogleApi
::
CloudPlatform
::
Client
.
session_key_for_expires_at
])
.
to
eq
(
expires_at
)
end
context
'when redirection url is stored in state'
do
it
'redirects to the URL stored in state param'
do
expect
(
subject
).
to
redirect_to
(
state
)
end
end
context
'when redirection url is not stored in state'
do
let
(
:state
)
{
''
}
it
'redirects to root_path'
do
expect
(
subject
).
to
redirect_to
(
root_path
)
end
end
end
end
spec/policies/gcp/cluster_policy_spec.rb
0 → 100644
View file @
fe135fac
require
'spec_helper'
describe
Gcp
::
ClusterPolicy
,
:models
do
set
(
:project
)
{
create
(
:project
)
}
set
(
:cluster
)
{
create
(
:gcp_cluster
,
project:
project
)
}
let
(
:user
)
{
create
(
:user
)
}
let
(
:policy
)
{
described_class
.
new
(
user
,
cluster
)
}
describe
'rules'
do
context
'when developer'
do
before
do
project
.
add_developer
(
user
)
end
it
{
expect
(
policy
).
to
be_disallowed
:update_cluster
}
it
{
expect
(
policy
).
to
be_disallowed
:admin_cluster
}
end
context
'when master'
do
before
do
project
.
add_master
(
user
)
end
it
{
expect
(
policy
).
to
be_allowed
:update_cluster
}
it
{
expect
(
policy
).
to
be_allowed
:admin_cluster
}
end
end
end
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