aptible-cli 0.11.0 → 0.11.1
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/lib/aptible/cli/helpers/token.rb +9 -6
- data/lib/aptible/cli/version.rb +1 -1
- data/spec/aptible/cli/helpers/token_spec.rb +41 -0
- metadata +4 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: c42a7a8ab65f7e7818b73f0e84c2b6bca1346eab
|
4
|
+
data.tar.gz: bc17a8345a7e44528ee857e6ec15b79d42226066
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
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
|
-
|
23
|
+
|
24
|
+
File.open(token_file, 'w', 0o600) do |file|
|
24
25
|
file.puts hash.to_json
|
25
26
|
end
|
26
|
-
rescue
|
27
|
-
|
28
|
-
|
29
|
-
|
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
|
{}
|
data/lib/aptible/cli/version.rb
CHANGED
@@ -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.
|
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
|
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
|