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
0
Merge Requests
0
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
Boxiang Sun
gitlab-ce
Commits
e5c408e4
Commit
e5c408e4
authored
Nov 06, 2018
by
Chris Baumbauer
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Refactor cluster application tests to centralize helm CA cert verification
parent
0d5be948
Changes
6
Show whitespace changes
Inline
Side-by-side
Showing
6 changed files
with
30 additions
and
110 deletions
+30
-110
spec/models/clusters/applications/ingress_spec.rb
spec/models/clusters/applications/ingress_spec.rb
+1
-23
spec/models/clusters/applications/jupyter_spec.rb
spec/models/clusters/applications/jupyter_spec.rb
+1
-23
spec/models/clusters/applications/knative_spec.rb
spec/models/clusters/applications/knative_spec.rb
+1
-18
spec/models/clusters/applications/prometheus_spec.rb
spec/models/clusters/applications/prometheus_spec.rb
+1
-23
spec/models/clusters/applications/runner_spec.rb
spec/models/clusters/applications/runner_spec.rb
+1
-23
spec/support/shared_examples/models/cluster_application_helm_cert_examples.rb
...examples/models/cluster_application_helm_cert_examples.rb
+25
-0
No files found.
spec/models/clusters/applications/ingress_spec.rb
View file @
e5c408e4
...
...
@@ -5,6 +5,7 @@ describe Clusters::Applications::Ingress do
include_examples
'cluster application core specs'
,
:clusters_applications_ingress
include_examples
'cluster application status specs'
,
:clusters_applications_ingress
include_examples
'cluster application helm specs'
,
:clusters_applications_knative
before
do
allow
(
ClusterWaitForIngressIpAddressWorker
).
to
receive
(
:perform_in
)
...
...
@@ -121,28 +122,5 @@ describe Clusters::Applications::Ingress do
expect
(
values
).
to
include
(
'stats'
)
expect
(
values
).
to
include
(
'podAnnotations'
)
end
context
'when the helm application does not have a ca_cert'
do
before
do
application
.
cluster
.
application_helm
.
ca_cert
=
nil
end
it
'should not include cert files'
do
expect
(
subject
[
:'ca.pem'
]).
not_to
be_present
expect
(
subject
[
:'cert.pem'
]).
not_to
be_present
expect
(
subject
[
:'key.pem'
]).
not_to
be_present
end
end
it
'should include cert files'
do
expect
(
subject
[
:'ca.pem'
]).
to
be_present
expect
(
subject
[
:'ca.pem'
]).
to
eq
(
application
.
cluster
.
application_helm
.
ca_cert
)
expect
(
subject
[
:'cert.pem'
]).
to
be_present
expect
(
subject
[
:'key.pem'
]).
to
be_present
cert
=
OpenSSL
::
X509
::
Certificate
.
new
(
subject
[
:'cert.pem'
])
expect
(
cert
.
not_after
).
to
be
<
60
.
minutes
.
from_now
end
end
end
spec/models/clusters/applications/jupyter_spec.rb
View file @
e5c408e4
...
...
@@ -2,6 +2,7 @@ require 'rails_helper'
describe
Clusters
::
Applications
::
Jupyter
do
include_examples
'cluster application core specs'
,
:clusters_applications_jupyter
include_examples
'cluster application helm specs'
,
:clusters_applications_knative
it
{
is_expected
.
to
belong_to
(
:oauth_application
)
}
...
...
@@ -79,29 +80,6 @@ describe Clusters::Applications::Jupyter do
subject
{
application
.
files
}
it
'should include cert files'
do
expect
(
subject
[
:'ca.pem'
]).
to
be_present
expect
(
subject
[
:'ca.pem'
]).
to
eq
(
application
.
cluster
.
application_helm
.
ca_cert
)
expect
(
subject
[
:'cert.pem'
]).
to
be_present
expect
(
subject
[
:'key.pem'
]).
to
be_present
cert
=
OpenSSL
::
X509
::
Certificate
.
new
(
subject
[
:'cert.pem'
])
expect
(
cert
.
not_after
).
to
be
<
60
.
minutes
.
from_now
end
context
'when the helm application does not have a ca_cert'
do
before
do
application
.
cluster
.
application_helm
.
ca_cert
=
nil
end
it
'should not include cert files'
do
expect
(
subject
[
:'ca.pem'
]).
not_to
be_present
expect
(
subject
[
:'cert.pem'
]).
not_to
be_present
expect
(
subject
[
:'key.pem'
]).
not_to
be_present
end
end
it
'should include valid values'
do
expect
(
values
).
to
include
(
'ingress'
)
expect
(
values
).
to
include
(
'hub'
)
...
...
spec/models/clusters/applications/knative_spec.rb
View file @
e5c408e4
...
...
@@ -5,6 +5,7 @@ describe Clusters::Applications::Knative do
include_examples
'cluster application core specs'
,
:clusters_applications_knative
include_examples
'cluster application status specs'
,
:clusters_applications_knative
include_examples
'cluster application helm specs'
,
:clusters_applications_knative
describe
'.installed'
do
subject
{
described_class
.
installed
}
...
...
@@ -68,23 +69,5 @@ describe Clusters::Applications::Knative do
it
'should include knative specific keys in the values.yaml file'
do
expect
(
values
).
to
include
(
'domain'
)
end
context
'when the helm application does not have a ca_cert'
do
before
do
application
.
cluster
.
application_helm
.
ca_cert
=
nil
end
it
'should not include cert files when there is no ca_cert entry'
do
expect
(
subject
).
not_to
include
(
:'ca.pem'
,
:'cert.pem'
,
:'key.pem'
)
end
end
it
'should include cert files when there is a ca_cert entry'
do
expect
(
subject
).
to
include
(
:'ca.pem'
,
:'cert.pem'
,
:'key.pem'
)
expect
(
subject
[
:'ca.pem'
]).
to
eq
(
application
.
cluster
.
application_helm
.
ca_cert
)
cert
=
OpenSSL
::
X509
::
Certificate
.
new
(
subject
[
:'cert.pem'
])
expect
(
cert
.
not_after
).
to
be
<
60
.
minutes
.
from_now
end
end
end
spec/models/clusters/applications/prometheus_spec.rb
View file @
e5c408e4
...
...
@@ -5,6 +5,7 @@ describe Clusters::Applications::Prometheus do
include_examples
'cluster application core specs'
,
:clusters_applications_prometheus
include_examples
'cluster application status specs'
,
:clusters_applications_prometheus
include_examples
'cluster application helm specs'
,
:clusters_applications_knative
describe
'.installed'
do
subject
{
described_class
.
installed
}
...
...
@@ -187,29 +188,6 @@ describe Clusters::Applications::Prometheus do
subject
{
application
.
files
}
it
'should include cert files'
do
expect
(
subject
[
:'ca.pem'
]).
to
be_present
expect
(
subject
[
:'ca.pem'
]).
to
eq
(
application
.
cluster
.
application_helm
.
ca_cert
)
expect
(
subject
[
:'cert.pem'
]).
to
be_present
expect
(
subject
[
:'key.pem'
]).
to
be_present
cert
=
OpenSSL
::
X509
::
Certificate
.
new
(
subject
[
:'cert.pem'
])
expect
(
cert
.
not_after
).
to
be
<
60
.
minutes
.
from_now
end
context
'when the helm application does not have a ca_cert'
do
before
do
application
.
cluster
.
application_helm
.
ca_cert
=
nil
end
it
'should not include cert files'
do
expect
(
subject
[
:'ca.pem'
]).
not_to
be_present
expect
(
subject
[
:'cert.pem'
]).
not_to
be_present
expect
(
subject
[
:'key.pem'
]).
not_to
be_present
end
end
it
'should include prometheus valid values'
do
expect
(
values
).
to
include
(
'alertmanager'
)
expect
(
values
).
to
include
(
'kubeStateMetrics'
)
...
...
spec/models/clusters/applications/runner_spec.rb
View file @
e5c408e4
...
...
@@ -5,6 +5,7 @@ describe Clusters::Applications::Runner do
include_examples
'cluster application core specs'
,
:clusters_applications_runner
include_examples
'cluster application status specs'
,
:clusters_applications_runner
include_examples
'cluster application helm specs'
,
:clusters_applications_knative
it
{
is_expected
.
to
belong_to
(
:runner
)
}
...
...
@@ -74,29 +75,6 @@ describe Clusters::Applications::Runner do
subject
{
application
.
files
}
it
'should include cert files'
do
expect
(
subject
[
:'ca.pem'
]).
to
be_present
expect
(
subject
[
:'ca.pem'
]).
to
eq
(
application
.
cluster
.
application_helm
.
ca_cert
)
expect
(
subject
[
:'cert.pem'
]).
to
be_present
expect
(
subject
[
:'key.pem'
]).
to
be_present
cert
=
OpenSSL
::
X509
::
Certificate
.
new
(
subject
[
:'cert.pem'
])
expect
(
cert
.
not_after
).
to
be
<
60
.
minutes
.
from_now
end
context
'when the helm application does not have a ca_cert'
do
before
do
application
.
cluster
.
application_helm
.
ca_cert
=
nil
end
it
'should not include cert files'
do
expect
(
subject
[
:'ca.pem'
]).
not_to
be_present
expect
(
subject
[
:'cert.pem'
]).
not_to
be_present
expect
(
subject
[
:'key.pem'
]).
not_to
be_present
end
end
it
'should include runner valid values'
do
expect
(
values
).
to
include
(
'concurrent'
)
expect
(
values
).
to
include
(
'checkInterval'
)
...
...
spec/support/shared_examples/models/cluster_application_helm_cert_examples.rb
0 → 100644
View file @
e5c408e4
shared_examples
'cluster application helm specs'
do
|
application_name
|
let
(
:application
)
{
create
(
application_name
)
}
describe
'#files'
do
subject
{
application
.
files
}
context
'when the helm application does not have a ca_cert'
do
before
do
application
.
cluster
.
application_helm
.
ca_cert
=
nil
end
it
'should not include cert files when there is no ca_cert entry'
do
expect
(
subject
).
not_to
include
(
:'ca.pem'
,
:'cert.pem'
,
:'key.pem'
)
end
end
it
'should include cert files when there is a ca_cert entry'
do
expect
(
subject
).
to
include
(
:'ca.pem'
,
:'cert.pem'
,
:'key.pem'
)
expect
(
subject
[
:'ca.pem'
]).
to
eq
(
application
.
cluster
.
application_helm
.
ca_cert
)
cert
=
OpenSSL
::
X509
::
Certificate
.
new
(
subject
[
:'cert.pem'
])
expect
(
cert
.
not_after
).
to
be
<
60
.
minutes
.
from_now
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