td 0.17.0 → 0.17.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 +4 -4
- data/ChangeLog +4 -0
- data/lib/td/command/account.rb +7 -3
- data/lib/td/version.rb +1 -1
- data/spec/td/command/account_spec.rb +79 -0
- metadata +4 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 7ed6a6e5934d927122c94bd28a5e356e6d422cacf182e97b30d83b9d453c1a29
|
4
|
+
data.tar.gz: eab2f179e910311ac9e0e45325cb366fadfb053268c7707cf4336b8f91e8150d
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 74843a395778c6fba9bf45d625ecdccbdaf956a7dabc08f4fe0fc1832e567fef60b6600c38aefcffddbd619cddaeb05a45ad71d457df9c31c02ee95ffa934fd5
|
7
|
+
data.tar.gz: 0f629764b2006b045235c7e836c0f51edceaa620679833182aba1ce2ce1538e27c6bae28804e913e51f805f1e535f27e6bb5e2eb24a2aade58dc450ad67b011b
|
data/ChangeLog
CHANGED
data/lib/td/command/account.rb
CHANGED
@@ -113,12 +113,16 @@ module Command
|
|
113
113
|
|
114
114
|
private
|
115
115
|
if Helpers.on_windows?
|
116
|
-
require '
|
116
|
+
require 'fiddle'
|
117
117
|
|
118
118
|
def get_char
|
119
|
-
|
119
|
+
msvcrt = Fiddle.dlopen('msvcrt')
|
120
|
+
getch = Fiddle::Function.new(msvcrt['_getch'], [], Fiddle::TYPE_CHAR)
|
121
|
+
getch.call()
|
120
122
|
rescue Exception
|
121
|
-
|
123
|
+
crtdll = Fiddle.dlopen('crtdll')
|
124
|
+
getch = Fiddle::Function.new(crtdll['_getch'], [], Fiddle::TYPE_CHAR)
|
125
|
+
getch.call()
|
122
126
|
end
|
123
127
|
|
124
128
|
def get_password
|
data/lib/td/version.rb
CHANGED
@@ -0,0 +1,79 @@
|
|
1
|
+
# encoding: utf-8
|
2
|
+
|
3
|
+
require 'spec_helper'
|
4
|
+
require "tempfile"
|
5
|
+
require 'td/command/common'
|
6
|
+
require 'td/command/account'
|
7
|
+
require 'td/command/list'
|
8
|
+
require 'td/helpers'
|
9
|
+
|
10
|
+
module TreasureData::Command
|
11
|
+
describe 'account command' do
|
12
|
+
let :command do
|
13
|
+
Class.new { include TreasureData::Command }.new
|
14
|
+
end
|
15
|
+
let(:client) { double(:client) }
|
16
|
+
let(:conf_file) { Tempfile.new("td.conf").tap {|s| s.close } }
|
17
|
+
let(:conf_expect) {
|
18
|
+
"""[account]
|
19
|
+
user = test@email.com
|
20
|
+
apikey = 1/xxx
|
21
|
+
"""
|
22
|
+
}
|
23
|
+
|
24
|
+
before do
|
25
|
+
TreasureData::Config.path = conf_file.path
|
26
|
+
end
|
27
|
+
|
28
|
+
it 'is called without any option' do
|
29
|
+
expect(STDIN).to receive(:gets).and_return('test@email.com')
|
30
|
+
if TreasureData::Helpers.on_windows?
|
31
|
+
'password'.chars.each { |c| expect(command).to receive(:get_char).and_return(c) }
|
32
|
+
expect(command).to receive(:get_char).and_return(nil)
|
33
|
+
else
|
34
|
+
expect(STDIN).to receive(:gets).and_return('password')
|
35
|
+
end
|
36
|
+
expect(TreasureData::Client).to receive(:authenticate).and_return(client)
|
37
|
+
expect(client).to receive(:apikey).and_return("1/xxx")
|
38
|
+
|
39
|
+
op = List::CommandParser.new("account", %w[], %w[], false, [], true)
|
40
|
+
command.account(op)
|
41
|
+
|
42
|
+
expect(File.read(conf_file.path)).to eq(conf_expect)
|
43
|
+
end
|
44
|
+
|
45
|
+
it 'is called with -f option' do
|
46
|
+
if TreasureData::Helpers.on_windows?
|
47
|
+
'password'.chars.each { |c| expect(command).to receive(:get_char).and_return(c) }
|
48
|
+
expect(command).to receive(:get_char).and_return(nil)
|
49
|
+
else
|
50
|
+
expect(STDIN).to receive(:gets).and_return('password')
|
51
|
+
end
|
52
|
+
expect(TreasureData::Client).to receive(:authenticate).and_return(client)
|
53
|
+
expect(client).to receive(:apikey).and_return("1/xxx")
|
54
|
+
|
55
|
+
op = List::CommandParser.new("account", %w[-f], %w[], false, ['test@email.com'], true)
|
56
|
+
command.account(op)
|
57
|
+
|
58
|
+
expect(File.read(conf_file.path)).to eq(conf_expect)
|
59
|
+
end
|
60
|
+
|
61
|
+
it 'is called with username password mismatched' do
|
62
|
+
if TreasureData::Helpers.on_windows?
|
63
|
+
3.times do
|
64
|
+
'password'.chars.each { |c| expect(command).to receive(:get_char).and_return(c) }
|
65
|
+
expect(command).to receive(:get_char).and_return(nil)
|
66
|
+
end
|
67
|
+
else
|
68
|
+
expect(STDIN).to receive(:gets).and_return('password').thrice
|
69
|
+
end
|
70
|
+
expect(TreasureData::Client).to receive(:authenticate).thrice.and_raise(TreasureData::AuthError)
|
71
|
+
expect(STDERR).to receive(:puts).with('User name or password mismatched.').thrice
|
72
|
+
|
73
|
+
op = List::CommandParser.new("account", %w[-f], %w[], false, ['test@email.com'], true)
|
74
|
+
command.account(op)
|
75
|
+
|
76
|
+
expect(File.read(conf_file.path)).to eq("")
|
77
|
+
end
|
78
|
+
end
|
79
|
+
end
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: td
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.17.
|
4
|
+
version: 0.17.1
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Treasure Data, Inc.
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2023-
|
11
|
+
date: 2023-04-18 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: msgpack
|
@@ -304,6 +304,7 @@ files:
|
|
304
304
|
- spec/file_reader/shared_context.rb
|
305
305
|
- spec/file_reader_spec.rb
|
306
306
|
- spec/spec_helper.rb
|
307
|
+
- spec/td/command/account_spec.rb
|
307
308
|
- spec/td/command/connector_spec.rb
|
308
309
|
- spec/td/command/export_spec.rb
|
309
310
|
- spec/td/command/import_spec.rb
|
@@ -360,6 +361,7 @@ test_files:
|
|
360
361
|
- spec/file_reader/shared_context.rb
|
361
362
|
- spec/file_reader_spec.rb
|
362
363
|
- spec/spec_helper.rb
|
364
|
+
- spec/td/command/account_spec.rb
|
363
365
|
- spec/td/command/connector_spec.rb
|
364
366
|
- spec/td/command/export_spec.rb
|
365
367
|
- spec/td/command/import_spec.rb
|