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
b229637b
Commit
b229637b
authored
Oct 05, 2017
by
Shinya Maeda
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
fetch_kubernetes_token_service_spec. Fix static analysys.
parent
31c89258
Changes
4
Hide whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
58 additions
and
8 deletions
+58
-8
app/services/ci/fetch_kubernetes_token_service.rb
app/services/ci/fetch_kubernetes_token_service.rb
+2
-0
spec/lib/gitlab/usage_data_spec.rb
spec/lib/gitlab/usage_data_spec.rb
+1
-0
spec/models/gcp/cluster_spec.rb
spec/models/gcp/cluster_spec.rb
+2
-2
spec/services/ci/fetch_kubernetes_token_service_spec.rb
spec/services/ci/fetch_kubernetes_token_service_spec.rb
+53
-6
No files found.
app/services/ci/fetch_kubernetes_token_service.rb
View file @
b229637b
...
@@ -22,6 +22,8 @@ module Ci
...
@@ -22,6 +22,8 @@ module Ci
return
Base64
.
decode64
(
token_base64
)
if
token_base64
return
Base64
.
decode64
(
token_base64
)
if
token_base64
end
end
end
end
nil
end
end
private
private
...
...
spec/lib/gitlab/usage_data_spec.rb
View file @
b229637b
...
@@ -60,6 +60,7 @@ describe Gitlab::UsageData do
...
@@ -60,6 +60,7 @@ describe Gitlab::UsageData do
deploy_keys
deploy_keys
deployments
deployments
environments
environments
gcp_clusters
in_review_folder
in_review_folder
groups
groups
issues
issues
...
...
spec/models/gcp/cluster_spec.rb
View file @
b229637b
...
@@ -122,12 +122,12 @@ describe Gcp::Cluster do
...
@@ -122,12 +122,12 @@ describe Gcp::Cluster do
let
(
:cluster
)
{
create
(
:gcp_cluster
)
}
let
(
:cluster
)
{
create
(
:gcp_cluster
)
}
before
do
before
do
cluster
.
creating!
cluster
.
make_
creating!
end
end
context
'when created'
do
context
'when created'
do
before
do
before
do
cluster
.
created!
cluster
.
make_
created!
end
end
it
{
is_expected
.
to
be_truthy
}
it
{
is_expected
.
to
be_truthy
}
...
...
spec/services/ci/fetch_kubernetes_token_service_spec.rb
View file @
b229637b
...
@@ -2,16 +2,63 @@ require 'spec_helper'
...
@@ -2,16 +2,63 @@ require 'spec_helper'
describe
Ci
::
FetchKubernetesTokenService
do
describe
Ci
::
FetchKubernetesTokenService
do
describe
'#execute'
do
describe
'#execute'
do
context
'when correct params'
do
subject
{
described_class
.
new
(
api_url
,
ca_pem
,
username
,
password
).
execute
}
it
'fetch the kubernetes token'
do
let
(
:api_url
)
{
'http://111.111.111.111'
}
let
(
:ca_pem
)
{
''
}
let
(
:username
)
{
'admin'
}
let
(
:password
)
{
'xxx'
}
context
'when params correct'
do
let
(
:token
)
{
'xxx.token.xxx'
}
let
(
:secrets_json
)
do
[
{
'metadata'
:
{
name:
metadata_name
},
'data'
:
{
'token'
:
Base64
.
encode64
(
token
)
}
}
]
end
before
do
allow_any_instance_of
(
Kubeclient
::
Client
)
.
to
receive
(
:get_secrets
).
and_return
(
secrets_json
)
end
context
'when default-token exists'
do
let
(
:metadata_name
)
{
'default-token-123'
}
it
{
is_expected
.
to
eq
(
token
)
}
end
end
end
context
'when invalid params
'
do
context
'when default-token does not exist
'
do
it
'returns nil'
do
let
(
:metadata_name
)
{
'another-token-123'
}
it
{
is_expected
.
to
be_nil
}
end
end
end
end
context
'when api_url is nil'
do
let
(
:api_url
)
{
nil
}
it
{
expect
{
subject
}.
to
raise_error
(
"Incomplete settings"
)
}
end
context
'when username is nil'
do
let
(
:username
)
{
nil
}
it
{
expect
{
subject
}.
to
raise_error
(
"Incomplete settings"
)
}
end
context
'when password is nil'
do
let
(
:password
)
{
nil
}
it
{
expect
{
subject
}.
to
raise_error
(
"Incomplete settings"
)
}
end
end
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