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
bfcd3f6d
Commit
bfcd3f6d
authored
Feb 11, 2019
by
GitLab Bot
Browse files
Options
Browse Files
Download
Plain Diff
Automatic merge of gitlab-org/gitlab-ce master
parents
0ab64c0d
15af0a45
Changes
5
Show whitespace changes
Inline
Side-by-side
Showing
5 changed files
with
39 additions
and
3 deletions
+39
-3
app/models/clusters/platforms/kubernetes.rb
app/models/clusters/platforms/kubernetes.rb
+1
-0
changelogs/unreleased/55447-validate-k8s-ca-cert.yml
changelogs/unreleased/55447-validate-k8s-ca-cert.yml
+5
-0
spec/fixtures/clusters/sample_cert.pem
spec/fixtures/clusters/sample_cert.pem
+1
-1
spec/models/clusters/kubernetes_namespace_spec.rb
spec/models/clusters/kubernetes_namespace_spec.rb
+1
-1
spec/models/clusters/platforms/kubernetes_spec.rb
spec/models/clusters/platforms/kubernetes_spec.rb
+31
-1
No files found.
app/models/clusters/platforms/kubernetes.rb
View file @
bfcd3f6d
...
@@ -43,6 +43,7 @@ module Clusters
...
@@ -43,6 +43,7 @@ module Clusters
# We expect to be `active?` only when enabled and cluster is created (the api_url is assigned)
# We expect to be `active?` only when enabled and cluster is created (the api_url is assigned)
validates
:api_url
,
url:
true
,
presence:
true
validates
:api_url
,
url:
true
,
presence:
true
validates
:token
,
presence:
true
validates
:token
,
presence:
true
validates
:ca_cert
,
certificate:
true
,
allow_blank:
true
,
if: :ca_cert_changed?
validate
:prevent_modification
,
on: :update
validate
:prevent_modification
,
on: :update
...
...
changelogs/unreleased/55447-validate-k8s-ca-cert.yml
0 → 100644
View file @
bfcd3f6d
---
title
:
Validate kubernetes cluster CA certificate
merge_request
:
24990
author
:
type
:
changed
spec/fixtures/clusters/sample_cert.pem
View file @
bfcd3f6d
spec/models/clusters/kubernetes_namespace_spec.rb
View file @
bfcd3f6d
...
@@ -97,7 +97,7 @@ RSpec.describe Clusters::KubernetesNamespace, type: :model do
...
@@ -97,7 +97,7 @@ RSpec.describe Clusters::KubernetesNamespace, type: :model do
let
(
:platform
)
{
create
(
:cluster_platform_kubernetes
,
api_url:
api_url
,
ca_cert:
ca_pem
,
token:
token
)
}
let
(
:platform
)
{
create
(
:cluster_platform_kubernetes
,
api_url:
api_url
,
ca_cert:
ca_pem
,
token:
token
)
}
let
(
:api_url
)
{
'https://kube.domain.com'
}
let
(
:api_url
)
{
'https://kube.domain.com'
}
let
(
:ca_pem
)
{
'CA PEM DATA'
}
let
(
:ca_pem
)
{
File
.
read
(
Rails
.
root
.
join
(
'spec/fixtures/clusters/sample_cert.pem'
))
}
let
(
:token
)
{
'token'
}
let
(
:token
)
{
'token'
}
let
(
:kubeconfig
)
do
let
(
:kubeconfig
)
do
...
...
spec/models/clusters/platforms/kubernetes_spec.rb
View file @
bfcd3f6d
...
@@ -114,6 +114,36 @@ describe Clusters::Platforms::Kubernetes, :use_clean_rails_memory_store_caching
...
@@ -114,6 +114,36 @@ describe Clusters::Platforms::Kubernetes, :use_clean_rails_memory_store_caching
end
end
end
end
context
'ca_cert'
do
let
(
:kubernetes
)
{
build
(
:cluster_platform_kubernetes
,
ca_pem:
ca_pem
)
}
context
'with a valid certificate'
do
let
(
:ca_pem
)
{
File
.
read
(
Rails
.
root
.
join
(
'spec/fixtures/clusters/sample_cert.pem'
))
}
it
{
is_expected
.
to
be_truthy
}
end
context
'with an invalid certificate'
do
let
(
:ca_pem
)
{
"invalid"
}
it
{
is_expected
.
to
be_falsey
}
context
'but the certificate is not being updated'
do
before
do
allow
(
kubernetes
).
to
receive
(
:ca_cert_changed?
).
and_return
(
false
)
end
it
{
is_expected
.
to
be_truthy
}
end
end
context
'with no certificate'
do
let
(
:ca_pem
)
{
""
}
it
{
is_expected
.
to
be_truthy
}
end
end
describe
'when using reserved namespaces'
do
describe
'when using reserved namespaces'
do
subject
{
build
(
:cluster_platform_kubernetes
,
namespace:
namespace
)
}
subject
{
build
(
:cluster_platform_kubernetes
,
namespace:
namespace
)
}
...
@@ -202,7 +232,7 @@ describe Clusters::Platforms::Kubernetes, :use_clean_rails_memory_store_caching
...
@@ -202,7 +232,7 @@ describe Clusters::Platforms::Kubernetes, :use_clean_rails_memory_store_caching
let!
(
:cluster
)
{
create
(
:cluster
,
:project
,
platform_kubernetes:
kubernetes
)
}
let!
(
:cluster
)
{
create
(
:cluster
,
:project
,
platform_kubernetes:
kubernetes
)
}
let
(
:kubernetes
)
{
create
(
:cluster_platform_kubernetes
,
api_url:
api_url
,
ca_cert:
ca_pem
)
}
let
(
:kubernetes
)
{
create
(
:cluster_platform_kubernetes
,
api_url:
api_url
,
ca_cert:
ca_pem
)
}
let
(
:api_url
)
{
'https://kube.domain.com'
}
let
(
:api_url
)
{
'https://kube.domain.com'
}
let
(
:ca_pem
)
{
'CA PEM DATA'
}
let
(
:ca_pem
)
{
File
.
read
(
Rails
.
root
.
join
(
'spec/fixtures/clusters/sample_cert.pem'
))
}
subject
{
kubernetes
.
predefined_variables
(
project:
cluster
.
project
)
}
subject
{
kubernetes
.
predefined_variables
(
project:
cluster
.
project
)
}
...
...
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