2021-10-27 15:23:28 +05:30
|
|
|
# frozen_string_literal: true
|
|
|
|
|
2022-10-11 01:57:18 +05:30
|
|
|
require 'fast_spec_helper'
|
2021-10-27 15:23:28 +05:30
|
|
|
|
|
|
|
RSpec.describe Gitlab::Kubernetes::Kubeconfig::Entry::Cluster do
|
|
|
|
describe '#to_h' do
|
|
|
|
let(:name) { 'name' }
|
|
|
|
let(:url) { 'url' }
|
|
|
|
|
|
|
|
subject { described_class.new(name: name, url: url).to_h }
|
|
|
|
|
|
|
|
it { is_expected.to eq({ name: name, cluster: { server: url } }) }
|
|
|
|
|
|
|
|
context 'with a certificate' do
|
|
|
|
let(:cert) { 'certificate' }
|
|
|
|
let(:cert_encoded) { Base64.strict_encode64(cert) }
|
|
|
|
|
|
|
|
subject { described_class.new(name: name, url: url, ca_pem: cert).to_h }
|
|
|
|
|
|
|
|
it { is_expected.to eq({ name: name, cluster: { server: url, 'certificate-authority-data': cert_encoded } }) }
|
|
|
|
end
|
|
|
|
end
|
|
|
|
end
|