Sha256: 745548a3acc90633da0619eab6d1eafc8b2d6b278917f5472b21fc97946871a5

Contents?: true

Size: 1.1 KB

Versions: 37

Compression:

Stored size: 1.1 KB

Contents

require 'spec_helper'

describe Aptible::CLI::Helpers::Token do
  around do |example|
    Dir.mktmpdir { |home| ClimateControl.modify(HOME: home) { example.run } }
  end

  subject { Class.new.send(:include, described_class).new }

  describe '#save_token / #fetch_token' do
    it 'reads back a token it saved' do
      subject.save_token('foo')
      expect(subject.fetch_token).to eq('foo')
    end
  end

  context 'permissions' do
    before { skip 'Windows' if Gem.win_platform? }

    describe '#save_token' do
      it 'creates the token_file with mode 600' do
        subject.save_token('foo')
        expect(format('%o', File.stat(subject.token_file).mode))
          .to eq('100600')
      end
    end

    describe '#current_token_hash' do
      it 'updates the token_file to mode 600' do
        subject.save_token('foo')
        File.chmod(0o644, subject.token_file)
        expect(format('%o', File.stat(subject.token_file).mode))
          .to eq('100644')

        subject.current_token_hash
        expect(format('%o', File.stat(subject.token_file).mode))
          .to eq('100600')
      end
    end
  end
end

Version data entries

37 entries across 37 versions & 1 rubygems

Version Path
aptible-cli-0.22.0 spec/aptible/cli/helpers/token_spec.rb
aptible-cli-0.21.0 spec/aptible/cli/helpers/token_spec.rb
aptible-cli-0.20.0 spec/aptible/cli/helpers/token_spec.rb
aptible-cli-0.19.9 spec/aptible/cli/helpers/token_spec.rb
aptible-cli-0.19.7 spec/aptible/cli/helpers/token_spec.rb
aptible-cli-0.19.6 spec/aptible/cli/helpers/token_spec.rb
aptible-cli-0.19.4 spec/aptible/cli/helpers/token_spec.rb
aptible-cli-0.19.3 spec/aptible/cli/helpers/token_spec.rb
aptible-cli-0.19.2 spec/aptible/cli/helpers/token_spec.rb
aptible-cli-0.19.1 spec/aptible/cli/helpers/token_spec.rb
aptible-cli-0.19.0 spec/aptible/cli/helpers/token_spec.rb
aptible-cli-0.18.3 spec/aptible/cli/helpers/token_spec.rb
aptible-cli-0.18.2 spec/aptible/cli/helpers/token_spec.rb
aptible-cli-0.18.1 spec/aptible/cli/helpers/token_spec.rb
aptible-cli-0.18.0 spec/aptible/cli/helpers/token_spec.rb
aptible-cli-0.17.2 spec/aptible/cli/helpers/token_spec.rb
aptible-cli-0.17.1 spec/aptible/cli/helpers/token_spec.rb
aptible-cli-0.17.0 spec/aptible/cli/helpers/token_spec.rb
aptible-cli-0.16.9 spec/aptible/cli/helpers/token_spec.rb
aptible-cli-0.16.8 spec/aptible/cli/helpers/token_spec.rb