|
| 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 |
0 commit comments