Sha256: 714d28f1a36c309ed009d48d191df0c754a420bf573093d46d86982fc4d2a8d0

Contents?: true

Size: 1.83 KB

Versions: 17

Compression:

Stored size: 1.83 KB

Contents

require 'spec_helper'
require 'stringio'

describe Vcloud::Core::Fog::Login do
  describe "#token" do
    it "should return the output from get_token" do
      expect(subject).to receive(:get_token).and_return('mekmitasdigoat')
      expect(subject.token('supersekret')).to eq("mekmitasdigoat")
    end
  end

  describe "#token_export" do
    it "should call #token with pass arg and return shell export string" do
      expect(subject).to receive(:token).with('supersekret').and_return('mekmitasdigoat')
      expect(subject.token_export("supersekret")).to eq("export FOG_VCLOUD_TOKEN=mekmitasdigoat")
    end
  end

  describe "#check_plaintext_pass" do
    context "vcloud_director_password not set" do
      it "should not raise an exception" do
        expect(Vcloud::Core::Fog).to receive(:fog_credentials_pass).and_return(nil)
        expect(subject).to receive(:get_token)
        expect { subject.token('supersekret') }.not_to raise_error
      end
    end

    context "vcloud_director_password empty string" do
      it "should not raise an exception" do
        expect(Vcloud::Core::Fog).to receive(:fog_credentials_pass).and_return('')
        expect(subject).to receive(:get_token)
        expect { subject.token('supersekret') }.not_to raise_error
      end
    end

    context "vcloud_director_password non-empty string" do
      it "should raise an exception" do
        expect(Vcloud::Core::Fog).to receive(:fog_credentials_pass).and_return('supersekret')
        expect(subject).to_not receive(:get_token)
        expect { subject.token('supersekret') }.to raise_error(
          RuntimeError,
          "Found plaintext vcloud_director_password entry. Please set it to an empty string as storing passwords in plaintext is insecure. See http://gds-operations.github.io/vcloud-tools/usage/ for further information."
        )
      end
    end
  end
end

Version data entries

17 entries across 17 versions & 1 rubygems

Version Path
vcloud-core-2.2.0 spec/vcloud/core/fog/login_spec.rb
vcloud-core-2.1.1 spec/vcloud/core/fog/login_spec.rb
vcloud-core-2.1.0 spec/vcloud/core/fog/login_spec.rb
vcloud-core-2.0.1 spec/vcloud/core/fog/login_spec.rb
vcloud-core-2.0.0 spec/vcloud/core/fog/login_spec.rb
vcloud-core-1.2.0 spec/vcloud/core/fog/login_spec.rb
vcloud-core-1.1.0 spec/vcloud/core/fog/login_spec.rb
vcloud-core-1.0.2 spec/vcloud/core/fog/login_spec.rb
vcloud-core-1.0.1 spec/vcloud/core/fog/login_spec.rb
vcloud-core-1.0.0 spec/vcloud/core/fog/login_spec.rb
vcloud-core-0.16.1 spec/vcloud/core/fog/login_spec.rb
vcloud-core-0.16.0 spec/vcloud/core/fog/login_spec.rb
vcloud-core-0.15.0 spec/vcloud/core/fog/login_spec.rb
vcloud-core-0.14.0 spec/vcloud/core/fog/login_spec.rb
vcloud-core-0.13.0 spec/vcloud/core/fog/login_spec.rb
vcloud-core-0.12.0 spec/vcloud/core/fog/login_spec.rb
vcloud-core-0.11.0 spec/vcloud/core/fog/login_spec.rb