Skip to content

Commit 8d174c6

Browse files
committed
Add test for InSpec operator
1 parent 0ee7ca4 commit 8d174c6

File tree

3 files changed

+56
-1
lines changed

3 files changed

+56
-1
lines changed

.kitchen.yml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -85,6 +85,7 @@ suites:
8585
backend: local
8686
controls:
8787
- gcloud
88+
- acm
8889
- name: gcp
8990
backend: gcp
9091
controls:
Lines changed: 52 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,52 @@
1+
# Copyright 2019 Google LLC
2+
#
3+
# Licensed under the Apache License, Version 2.0 (the "License");
4+
# you may not use this file except in compliance with the License.
5+
# You may obtain a copy of the License at
6+
#
7+
# https://www.apache.org/licenses/LICENSE-2.0
8+
#
9+
# Unless required by applicable law or agreed to in writing, software
10+
# distributed under the License is distributed on an "AS IS" BASIS,
11+
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12+
# See the License for the specific language governing permissions and
13+
# limitations under the License.
14+
15+
require 'kubeclient'
16+
require 'rest-client'
17+
18+
require 'base64'
19+
20+
kubernetes_endpoint = attribute('kubernetes_endpoint')
21+
client_token = attribute('client_token')
22+
ca_certificate = attribute('ca_certificate')
23+
24+
control "acm" do
25+
title "Anthos Config Management"
26+
27+
describe "kubernetes" do
28+
let(:kubernetes_http_endpoint) { "https://#{kubernetes_endpoint}/api" }
29+
let(:client) do
30+
cert_store = OpenSSL::X509::Store.new
31+
cert_store.add_cert(OpenSSL::X509::Certificate.new(Base64.decode64(ca_certificate)))
32+
Kubeclient::Client.new(
33+
kubernetes_http_endpoint,
34+
"v1",
35+
ssl_options: {
36+
cert_store: cert_store,
37+
verify_ssl: OpenSSL::SSL::VERIFY_PEER,
38+
},
39+
auth_options: {
40+
bearer_token: Base64.decode64(client_token),
41+
},
42+
)
43+
end
44+
45+
describe "config-management-system namespace" do
46+
let(:namespace) { client.get_namespace("config-management-system") }
47+
it "should exist" do
48+
expect(namespace).not_to be nil
49+
end
50+
end
51+
end
52+
end

test/integration/simple_zonal/inspec.yml

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -25,4 +25,6 @@ attributes:
2525
- name: service_account
2626
required: true
2727
type: string
28-
28+
- name: ca_certificate
29+
required: true
30+
type: string

0 commit comments

Comments
 (0)