summaryrefslogtreecommitdiff
path: root/spec/lib/gitlab/kubernetes/kubeconfig/entry/cluster_spec.rb
blob: 508808be1be8f9b78641a6c31f157a18b5d0e5e0 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
# frozen_string_literal: true

require 'spec_helper'

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