aptible-cli 0.11.0 → 0.11.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 4caf3814e0cffe6799a62625c5d9fb9f79dbd016
4
- data.tar.gz: dbe1d0e306d35ce276c4ac0d323d0e1ea706aba4
3
+ metadata.gz: c42a7a8ab65f7e7818b73f0e84c2b6bca1346eab
4
+ data.tar.gz: bc17a8345a7e44528ee857e6ec15b79d42226066
5
5
  SHA512:
6
- metadata.gz: 1149e64d3194970dd488a36519eb07d1783d9ef860b587bd04f844de452afb848980ee4340e2e6a2cef0a10afa148812e48fdce7d9f18c296d072e52da5d45f0
7
- data.tar.gz: 7aed71d453418b1d887d214974a6e60903338154c866d1a5ec90e59ab185f0ad02d0e06bc929046bc1290234572c3785c60fa5ac50c91498f9c6513f628a0127
6
+ metadata.gz: 4490c9a5f1d3fcd9eac19f718e5e1e5b51972952df98287597418f4f1c78d22487cffe06d801a34677e893c55c7c2a4ce626b0309add81475abb740e804024e7
7
+ data.tar.gz: 50e312a8537bd4ad49c16bca5ae40c4f4c703138877593f38923a8b8901d959e937c26080bce1cb1d6efd6b9f72afacfae2ca3e2b9372ba29e4266434ff57873
@@ -20,17 +20,20 @@ module Aptible
20
20
  )
21
21
 
22
22
  FileUtils.mkdir_p(File.dirname(token_file))
23
- File.open(token_file, 'w') do |file|
23
+
24
+ File.open(token_file, 'w', 0o600) do |file|
24
25
  file.puts hash.to_json
25
26
  end
26
- rescue
27
- raise Thor::Error, <<-ERR.gsub(/\s+/, ' ').strip
28
- Could not write token to #{token_file}, please check filesystem
29
- permissions
30
- ERR
27
+ rescue StandardError => e
28
+ m = "Could not write token to #{token_file}: #{e}. " \
29
+ 'Check filesystem permissions.'
30
+ raise Thor::Error, m
31
31
  end
32
32
 
33
33
  def current_token_hash
34
+ # NOTE: older versions of the CLI did not properly create the
35
+ # token_file with mode 600, which is why we update it when reading.
36
+ File.chmod(0o600, token_file)
34
37
  JSON.parse(File.read(token_file))
35
38
  rescue
36
39
  {}
@@ -1,5 +1,5 @@
1
1
  module Aptible
2
2
  module CLI
3
- VERSION = '0.11.0'.freeze
3
+ VERSION = '0.11.1'.freeze
4
4
  end
5
5
  end
@@ -0,0 +1,41 @@
1
+ require 'spec_helper'
2
+
3
+ describe Aptible::CLI::Helpers::Token do
4
+ around do |example|
5
+ Dir.mktmpdir { |home| ClimateControl.modify(HOME: home) { example.run } }
6
+ end
7
+
8
+ subject { Class.new.send(:include, described_class).new }
9
+
10
+ describe '#save_token / #fetch_token' do
11
+ it 'reads back a token it saved' do
12
+ subject.save_token('foo')
13
+ expect(subject.fetch_token).to eq('foo')
14
+ end
15
+ end
16
+
17
+ context 'permissions' do
18
+ before { skip 'Windows' if Gem.win_platform? }
19
+
20
+ describe '#save_token' do
21
+ it 'creates the token_file with mode 600' do
22
+ subject.save_token('foo')
23
+ expect(format('%o', File.stat(subject.token_file).mode))
24
+ .to eq('100600')
25
+ end
26
+ end
27
+
28
+ describe '#current_token_hash' do
29
+ it 'updates the token_file to mode 600' do
30
+ subject.save_token('foo')
31
+ File.chmod(0o644, subject.token_file)
32
+ expect(format('%o', File.stat(subject.token_file).mode))
33
+ .to eq('100644')
34
+
35
+ subject.current_token_hash
36
+ expect(format('%o', File.stat(subject.token_file).mode))
37
+ .to eq('100600')
38
+ end
39
+ end
40
+ end
41
+ end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: aptible-cli
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.11.0
4
+ version: 0.11.1
5
5
  platform: ruby
6
6
  authors:
7
7
  - Frank Macreery
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2017-06-28 00:00:00.000000000 Z
11
+ date: 2017-07-06 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: aptible-resource
@@ -255,6 +255,7 @@ files:
255
255
  - spec/aptible/cli/helpers/operation_spec.rb
256
256
  - spec/aptible/cli/helpers/options_handle_strategy_spec.rb
257
257
  - spec/aptible/cli/helpers/ssh_spec.rb
258
+ - spec/aptible/cli/helpers/token_spec.rb
258
259
  - spec/aptible/cli/helpers/tunnel_spec.rb
259
260
  - spec/aptible/cli/subcommands/apps_spec.rb
260
261
  - spec/aptible/cli/subcommands/backup_spec.rb
@@ -316,6 +317,7 @@ test_files:
316
317
  - spec/aptible/cli/helpers/operation_spec.rb
317
318
  - spec/aptible/cli/helpers/options_handle_strategy_spec.rb
318
319
  - spec/aptible/cli/helpers/ssh_spec.rb
320
+ - spec/aptible/cli/helpers/token_spec.rb
319
321
  - spec/aptible/cli/helpers/tunnel_spec.rb
320
322
  - spec/aptible/cli/subcommands/apps_spec.rb
321
323
  - spec/aptible/cli/subcommands/backup_spec.rb