td-client 1.0.0-java

Sign up to get free protection for your applications and to get access to all the features.
Files changed (49) hide show
  1. checksums.yaml +7 -0
  2. data/data/ca-bundle.crt +3448 -0
  3. data/lib/td-client.rb +1 -0
  4. data/lib/td/client.rb +606 -0
  5. data/lib/td/client/api.rb +707 -0
  6. data/lib/td/client/api/access_control.rb +74 -0
  7. data/lib/td/client/api/account.rb +45 -0
  8. data/lib/td/client/api/bulk_import.rb +184 -0
  9. data/lib/td/client/api/bulk_load.rb +172 -0
  10. data/lib/td/client/api/database.rb +50 -0
  11. data/lib/td/client/api/export.rb +38 -0
  12. data/lib/td/client/api/import.rb +38 -0
  13. data/lib/td/client/api/job.rb +390 -0
  14. data/lib/td/client/api/partial_delete.rb +27 -0
  15. data/lib/td/client/api/result.rb +46 -0
  16. data/lib/td/client/api/schedule.rb +120 -0
  17. data/lib/td/client/api/server_status.rb +21 -0
  18. data/lib/td/client/api/table.rb +132 -0
  19. data/lib/td/client/api/user.rb +134 -0
  20. data/lib/td/client/api_error.rb +37 -0
  21. data/lib/td/client/compat_gzip_reader.rb +22 -0
  22. data/lib/td/client/model.rb +816 -0
  23. data/lib/td/client/version.rb +5 -0
  24. data/lib/td/core_ext/openssl/ssl/sslcontext/set_params.rb +18 -0
  25. data/spec/spec_helper.rb +63 -0
  26. data/spec/td/client/access_control_api_spec.rb +37 -0
  27. data/spec/td/client/account_api_spec.rb +34 -0
  28. data/spec/td/client/api_error_spec.rb +77 -0
  29. data/spec/td/client/api_spec.rb +269 -0
  30. data/spec/td/client/api_ssl_connection_spec.rb +109 -0
  31. data/spec/td/client/bulk_import_spec.rb +199 -0
  32. data/spec/td/client/bulk_load_spec.rb +401 -0
  33. data/spec/td/client/db_api_spec.rb +123 -0
  34. data/spec/td/client/export_api_spec.rb +51 -0
  35. data/spec/td/client/import_api_spec.rb +148 -0
  36. data/spec/td/client/job_api_spec.rb +833 -0
  37. data/spec/td/client/model_job_spec.rb +136 -0
  38. data/spec/td/client/model_schedule_spec.rb +26 -0
  39. data/spec/td/client/model_schema_spec.rb +134 -0
  40. data/spec/td/client/partial_delete_api_spec.rb +58 -0
  41. data/spec/td/client/result_api_spec.rb +77 -0
  42. data/spec/td/client/sched_api_spec.rb +109 -0
  43. data/spec/td/client/server_status_api_spec.rb +25 -0
  44. data/spec/td/client/spec_resources.rb +99 -0
  45. data/spec/td/client/table_api_spec.rb +226 -0
  46. data/spec/td/client/user_api_spec.rb +118 -0
  47. data/spec/td/client_sched_spec.rb +79 -0
  48. data/spec/td/client_spec.rb +46 -0
  49. metadata +271 -0
@@ -0,0 +1,25 @@
1
+ require 'spec_helper'
2
+ require 'td/client/spec_resources'
3
+
4
+ describe 'ServerStatus API' do
5
+ include_context 'spec symbols'
6
+ include_context 'common helper'
7
+
8
+ let :api do
9
+ API.new(nil, {:max_cumul_retry_delay => -1})
10
+ end
11
+
12
+ describe 'server_status' do
13
+ it 'returns status' do
14
+ stub_api_request(:get, '/v3/system/server_status').
15
+ to_return(:body => {'status' => 'OK'}.to_json)
16
+ expect(api.server_status).to eq('OK')
17
+ end
18
+
19
+ it 'returns error description' do
20
+ stub_api_request(:get, '/v3/system/server_status').
21
+ to_return(:status => 500)
22
+ expect(api.server_status).to eq('Server is down (500)')
23
+ end
24
+ end
25
+ end
@@ -0,0 +1,99 @@
1
+ require 'spec_helper'
2
+ require 'td/client/model'
3
+
4
+ shared_context 'spec symbols' do
5
+ let :apikey do
6
+ '1/0123456789ABCDEFG'
7
+ end
8
+
9
+ let :db_name do
10
+ 'db_test'
11
+ end
12
+
13
+ let :table_name do
14
+ 'table_test'
15
+ end
16
+
17
+ let :sched_name do
18
+ 'sched test'
19
+ end
20
+
21
+ let :result_name do
22
+ 'test'
23
+ end
24
+
25
+ let :bi_name do
26
+ 'bi_test'
27
+ end
28
+
29
+ let :cron do
30
+ '* * * * *'
31
+ end
32
+
33
+ let :query do
34
+ 'select 1'
35
+ end
36
+ let :result_url do
37
+ 'td://@/test/table'
38
+ end
39
+ end
40
+
41
+ shared_context 'database resources' do
42
+ include_context 'common helper'
43
+
44
+ let :db_names do
45
+ [
46
+ 'cloud', 'yuffie', 'vincent', 'cid'
47
+ ]
48
+ end
49
+ end
50
+
51
+ shared_context 'job resources' do
52
+ include_context 'database resources'
53
+
54
+ MAX_JOB ||= 20
55
+
56
+ let :job_types do
57
+ [
58
+ ['HiveJob', 'hive'],
59
+ ['ExportJob', 'export'],
60
+ ['BulkImportJob', 'bulk_import'],
61
+ ['PartialDeleteJob', 'partialdelete']
62
+ ]
63
+ end
64
+
65
+ let :raw_jobs do
66
+ created_at = Time.at(1356966000)
67
+ types = job_types
68
+ dbs = db_names
69
+ (0...MAX_JOB).map { |i|
70
+ job_type = types[i % types.size]
71
+ status = i.odd? ? 'success' : 'error'
72
+ {
73
+ "job_id" => i,
74
+ "url" => "https://console.treasure-data.com/jobs/#{i.to_s}?target=query",
75
+ "database" => dbs[i % dbs.size].to_s,
76
+ "status" => status,
77
+ "type" => job_type[0].to_sym,
78
+ "query" => "select #{i}",
79
+ "priority" => i % 3,
80
+ "result" => nil,
81
+ "created_at" => created_at.to_s,
82
+ "updated_at" => (created_at + (i * 10)).to_s,
83
+ "start_at" => (created_at + (i * 10 * 60)).to_s,
84
+ "end_at" => (created_at + (i * 10 * 3600)).to_s,
85
+ "cpu_time" => i * 100 + i,
86
+ "result_size" => i * 1000,
87
+ 'retry_limit' => 10,
88
+ "duration" => i,
89
+ "num_records" => i * 1000,
90
+ 'organization' => nil,
91
+ 'hive_result_schema' => nil,
92
+ 'debug' => {
93
+ 'stderr' => "job #{i} #{status}",
94
+ 'cmdout' => "job #{i} command",
95
+ }
96
+ }
97
+ }
98
+ end
99
+ end
@@ -0,0 +1,226 @@
1
+ require 'spec_helper'
2
+ require 'td/client/spec_resources'
3
+
4
+ describe 'Table API' do
5
+ include_context 'spec symbols'
6
+ include_context 'common helper'
7
+
8
+ let :api do
9
+ API.new(nil)
10
+ end
11
+
12
+ let :client do
13
+ Client.new(apikey)
14
+ end
15
+
16
+ describe "'create_log_table' API" do
17
+ it 'should return 404 error if the database does not exist' do
18
+ err_msg = "Create log table failed: Couldn't find UserDatabase with name = #{db_name}"
19
+ stub_api_request(:post, "/v3/table/create/#{e db_name}/#{e(table_name)}/log").
20
+ to_return(:status => 404, :body => {'message' => err_msg}.to_json)
21
+
22
+ expect {
23
+ api.create_log_table(db_name, table_name)
24
+ }.to raise_error(TreasureData::NotFoundError, /#{err_msg}/)
25
+ end
26
+
27
+ it 'should create a new table if the database exists' do
28
+ stub_api_request(:post, "/v3/table/create/#{e db_name}/#{e(table_name)}/log").
29
+ to_return(:body => {'database' => db_name, 'table' => table_name, 'type' => 'log'}.to_json)
30
+ expect(api.create_log_table(db_name, table_name)).to be true
31
+ end
32
+
33
+ it 'should return 400 error with invalid name' do
34
+ invalid_name = 'a'
35
+ err_msg = "Name must be 3 to 256 characters, got #{invalid_name.length} characters. name = '#{invalid_name}'"
36
+ stub_api_request(:post, "/v3/table/create/#{e db_name}/#{e invalid_name}/log").
37
+ to_return(:status => 400, :body => {'message' => err_msg}.to_json)
38
+
39
+ expect {
40
+ api.create_log_table(db_name, invalid_name)
41
+ }.to raise_error(TreasureData::APIError, /#{err_msg}/)
42
+ end
43
+
44
+ it 'should return 409 error with duplicated name' do
45
+ err_msg = "Table #{table_name} already exists"
46
+ stub_api_request(:post, "/v3/table/create/#{e db_name}/#{e table_name}/log").
47
+ to_return(:status => 409, :body => {'message' => err_msg}.to_json)
48
+
49
+ expect {
50
+ api.create_log_table(db_name, table_name)
51
+ }.to raise_error(TreasureData::AlreadyExistsError, /#{err_msg}/)
52
+ end
53
+ end
54
+
55
+ describe "'list_tables' API" do
56
+ it 'should list the tables in a Hash whose values include type, count, created_at, updated_at, schema, ...' do
57
+ tables = [
58
+ ["table_1", "item", "[[\"time\",\"long\"],[\"value\",\"string\"]]", 111, "2013-01-21 01:51:41 UTC", "2014-01-21 01:51:41 UTC"],
59
+ ["table_2", "log", "[[\"time\",\"long\"],[\"value\",\"long\"]]", 222, "2013-02-22 02:52:42 UTC", "2014-02-22 02:52:42 UTC"],
60
+ ["table_3", "item", "[[\"time\",\"long\"],[\"value\",\"string\"]]", 333, "2013-03-23 03:53:43 UTC", "2014-03-23 03:53:43 UTC"],
61
+ ["table_4", "log", "[[\"time\",\"long\"],[\"value\",\"long\"]]", 444, "2013-04-24 04:54:44 UTC", "2014-04-24 04:54:44 UTC"]
62
+ ]
63
+ stub_api_request(:get, "/v3/table/list/#{e db_name}").
64
+ to_return(:body => {'tables' => [
65
+ {'name' => tables[0][0], 'type' => tables[0][1], 'schema' => tables[0][2], 'count' => tables[0][3], 'created_at' => tables[0][4], 'updated_at' => tables[0][5]},
66
+ {'name' => tables[1][0], 'type' => tables[1][1], 'schema' => tables[1][2], 'count' => tables[1][3], 'created_at' => tables[1][4], 'updated_at' => tables[1][5]},
67
+ {'name' => tables[2][0], 'type' => tables[2][1], 'schema' => tables[2][2], 'count' => tables[2][3], 'created_at' => tables[2][4], 'updated_at' => tables[2][5]},
68
+ {'name' => tables[3][0], 'type' => tables[3][1], 'schema' => tables[3][2], 'count' => tables[3][3], 'created_at' => tables[3][4], 'updated_at' => tables[3][5]}
69
+ ]}.to_json)
70
+
71
+ table_list = api.list_tables(db_name)
72
+ tables.each {|table|
73
+ expect(table_list[table[0]][0]).to eq(table[1].to_sym)
74
+ expect(table_list[table[0]][1]).to eq(JSON.parse(table[2]))
75
+ expect(table_list[table[0]][2]).to eq(table[3])
76
+ expect(table_list[table[0]][3]).to eq(table[4])
77
+ expect(table_list[table[0]][4]).to eq(table[5])
78
+ }
79
+ end
80
+ end
81
+
82
+ describe "'tables' Client API" do
83
+ it 'should return an array of Table objects' do
84
+ tables = [
85
+ ["table_1", "item", "[[\"value\",\"string\"]]", 111, "2013-01-21 01:51:41 UTC", "2014-01-21 01:51:41 UTC"],
86
+ ["table_2", "log", "[[\"value\",\"long\"]]", 222, "2013-02-22 02:52:42 UTC", "2014-02-22 02:52:42 UTC"],
87
+ ["table_3", "item", "[[\"value\",\"string\"]]", 333, "2013-03-23 03:53:43 UTC", "2014-03-23 03:53:43 UTC"],
88
+ ["table_4", "log", "[[\"value\",\"long\"]]", 444, "2013-04-24 04:54:44 UTC", "2014-04-24 04:54:44 UTC"]
89
+ ]
90
+ stub_api_request(:get, "/v3/table/list/#{e db_name}").
91
+ to_return(:body => {'tables' => [
92
+ {'name' => tables[0][0], 'type' => tables[0][1], 'schema' => tables[0][2], 'count' => tables[0][3], 'created_at' => tables[0][4], 'updated_at' => tables[0][5]},
93
+ {'name' => tables[1][0], 'type' => tables[1][1], 'schema' => tables[1][2], 'count' => tables[1][3], 'created_at' => tables[1][4], 'updated_at' => tables[1][5]},
94
+ {'name' => tables[2][0], 'type' => tables[2][1], 'schema' => tables[2][2], 'count' => tables[2][3], 'created_at' => tables[2][4], 'updated_at' => tables[2][5]},
95
+ {'name' => tables[3][0], 'type' => tables[3][1], 'schema' => tables[3][2], 'count' => tables[3][3], 'created_at' => tables[3][4], 'updated_at' => tables[3][5]}
96
+ ]}.to_json)
97
+
98
+ table_list = client.tables(db_name).sort_by { |e| e.name }
99
+
100
+ db_count = 0
101
+ tables.each {|table|
102
+ db_count += table[3]
103
+ }
104
+
105
+ # REST API call to fetch the database permission
106
+ stub_api_request(:get, "/v3/database/list").
107
+ to_return(:body => {'databases' => [
108
+ {'name' => db_name, 'count' => db_count, 'created_at' => tables[0][4], 'updated_at' => tables[0][5], 'permission' => 'full_access'}
109
+ ]}.to_json)
110
+
111
+ tables.length.times {|i|
112
+ expect(table_list[i].db_name).to eq(db_name)
113
+ expect(table_list[i].name).to eq(tables[i][0])
114
+ expect(table_list[i].type).to eq(tables[i][1].to_sym)
115
+ expect(table_list[i].schema.to_json).to eq(eval(tables[i][2]).to_json)
116
+ expect(table_list[i].count).to eq(tables[i][3])
117
+ expect(table_list[i].created_at).to eq(Time.parse(tables[i][4]))
118
+ expect(table_list[i].updated_at).to eq(Time.parse(tables[i][5]))
119
+
120
+ # REST API call to fetch the database permission
121
+ stub_api_request(:get, "/v3/database/list").
122
+ to_return(:body => {'databases' => [
123
+ {'name' => db_name, 'count' => db_count, 'created_at' => tables[0][4], 'updated_at' => tables[0][5], 'permission' => 'full_access'}
124
+ ]}.to_json)
125
+ expect(table_list[i].permission).to eq(:full_access)
126
+
127
+ # set up a trap to check this call never happens
128
+ # - if it did, the next assertion on the count would fail
129
+ stub_api_request(:get, "/v3/database/list").
130
+ to_return(:body => {'databases' => [
131
+ {'name' => db_name, 'count' => db_count + 100, 'created_at' => tables[0][4], 'updated_at' => tables[0][5], 'permission' => 'full_access'}
132
+ ]}.to_json)
133
+ expect(table_list[i].database.count).to eq(db_count)
134
+ }
135
+ end
136
+ end
137
+
138
+ describe "'table' Client API" do
139
+ it 'should return the Table object corresponding to the name' do
140
+ tables = [
141
+ ["table_1", "item", "[[\"value\",\"string\"]]", 111, "2013-01-21 01:51:41 UTC", "2014-01-21 01:51:41 UTC"],
142
+ ["table_2", "log", "[[\"value\",\"long\"]]", 222, "2013-02-22 02:52:42 UTC", "2014-02-22 02:52:42 UTC"],
143
+ ["table_3", "item", "[[\"value\",\"string\"]]", 333, "2013-03-23 03:53:43 UTC", "2014-03-23 03:53:43 UTC"],
144
+ ["table_4", "log", "[[\"value\",\"long\"]]", 444, "2013-04-24 04:54:44 UTC", "2014-04-24 04:54:44 UTC"]
145
+ ]
146
+ stub_api_request(:get, "/v3/table/list/#{e db_name}").
147
+ to_return(:body => {'tables' => [
148
+ {'name' => tables[0][0], 'type' => tables[0][1], 'schema' => tables[0][2], 'count' => tables[0][3], 'created_at' => tables[0][4], 'updated_at' => tables[0][5]},
149
+ {'name' => tables[1][0], 'type' => tables[1][1], 'schema' => tables[1][2], 'count' => tables[1][3], 'created_at' => tables[1][4], 'updated_at' => tables[1][5]},
150
+ {'name' => tables[2][0], 'type' => tables[2][1], 'schema' => tables[2][2], 'count' => tables[2][3], 'created_at' => tables[2][4], 'updated_at' => tables[2][5]},
151
+ {'name' => tables[3][0], 'type' => tables[3][1], 'schema' => tables[3][2], 'count' => tables[3][3], 'created_at' => tables[3][4], 'updated_at' => tables[3][5]}
152
+ ]}.to_json)
153
+
154
+ i = 1
155
+ table = client.table(db_name, tables[i][0])
156
+
157
+ expect(table.name).to eq(tables[i][0])
158
+ expect(table.type).to eq(tables[i][1].to_sym)
159
+ expect(table.schema.to_json).to eq(eval(tables[i][2]).to_json)
160
+ expect(table.count).to eq(tables[i][3])
161
+ expect(table.created_at).to eq(Time.parse(tables[i][4]))
162
+ expect(table.updated_at).to eq(Time.parse(tables[i][5]))
163
+ end
164
+ end
165
+
166
+ describe 'swap_table' do
167
+ it 'should swap tables' do
168
+ stub_api_request(:post, '/v3/table/swap/db/table1/table2')
169
+ expect(api.swap_table('db', 'table1', 'table2')).to eq(true)
170
+ end
171
+ end
172
+
173
+ describe 'update_expire' do
174
+ it 'should update expiry days' do
175
+ stub_api_request(:post, '/v3/table/update/db/table').
176
+ with(:body => {'expire_days' => '5'}).
177
+ to_return(:body => {'type' => 'type'}.to_json)
178
+ expect(api.update_expire('db', 'table', 5)).to eq(true)
179
+ end
180
+ end
181
+
182
+ describe 'tail' do
183
+ let :packed do
184
+ s = StringIO.new
185
+ pk = MessagePack::Packer.new(s)
186
+ pk.write([1, 2, 3])
187
+ pk.write([4, 5, 6])
188
+ pk.flush
189
+ s.string
190
+ end
191
+
192
+ it 'yields row if block given' do
193
+ stub_api_request(:get, '/v3/table/tail/db/table').
194
+ with(:query => {'format' => 'msgpack', 'count' => '10'}).
195
+ to_return(:body => packed)
196
+ result = []
197
+ api.tail('db', 'table', 10) do |row|
198
+ result << row
199
+ end
200
+ expect(result).to eq([[1, 2, 3], [4, 5, 6]])
201
+ end
202
+
203
+ it 'returns rows' do
204
+ stub_api_request(:get, '/v3/table/tail/db/table').
205
+ with(:query => {'format' => 'msgpack', 'count' => '10'}).
206
+ to_return(:body => packed)
207
+ expect(api.tail('db', 'table', 10)).to eq([[1, 2, 3], [4, 5, 6]])
208
+ end
209
+
210
+ it 'shows deprecated warning for from and to' do
211
+ stub_api_request(:get, '/v3/table/tail/db/table').
212
+ with(:query => {'format' => 'msgpack', 'count' => '10'}).
213
+ to_return(:body => packed)
214
+ r, w = IO.pipe
215
+ begin
216
+ backup = $stderr.dup
217
+ $stderr.reopen(w)
218
+ api.tail('db', 'table', 10, 100, 0)
219
+ ensure
220
+ $stderr.reopen(backup)
221
+ w.close
222
+ end
223
+ expect(r.read).to eq(%Q(parameter "to" and "from" no longer work\n))
224
+ end
225
+ end
226
+ end
@@ -0,0 +1,118 @@
1
+ require 'spec_helper'
2
+ require 'td/client/spec_resources'
3
+ require 'json'
4
+
5
+ describe 'User API' do
6
+ include_context 'spec symbols'
7
+ include_context 'common helper'
8
+
9
+ let :api do
10
+ API.new(nil)
11
+ end
12
+
13
+ describe 'authenticate' do
14
+ it 'returns apikey' do
15
+ stub_api_request(:post, "/v3/user/authenticate").
16
+ to_return(:body => {'apikey' => 'apikey'}.to_json)
17
+ expect(api.authenticate('user', 'password')).to eq('apikey')
18
+ end
19
+
20
+ it 'raises AuthError for authentication failure' do
21
+ stub_api_request(:post, "/v3/user/authenticate").
22
+ to_return(:status => 400, :body => {'apikey' => 'apikey'}.to_json)
23
+ expect {
24
+ api.authenticate('user', 'password')
25
+ }.to raise_error(TreasureData::AuthError)
26
+ end
27
+
28
+ it 'raises APIError for other error' do
29
+ stub_api_request(:post, "/v3/user/authenticate").
30
+ to_return(:status => 500, :body => {'apikey' => 'apikey'}.to_json)
31
+ expect {
32
+ api.authenticate('user', 'password')
33
+ }.to raise_error(TreasureData::APIError)
34
+ end
35
+ end
36
+
37
+ describe 'list_users' do
38
+ it 'returns users' do
39
+ stub_api_request(:get, "/v3/user/list").
40
+ to_return(:body => {'users' => [{'name' => 'name1', 'email' => 'email1'}, {'name' => 'name2', 'email' => 'email2'}]}.to_json)
41
+ expect(api.list_users).to eq([
42
+ ['name1', nil, nil, 'email1'],
43
+ ['name2', nil, nil, 'email2'],
44
+ ])
45
+ end
46
+ end
47
+
48
+ describe 'add_user' do
49
+ it 'runs' do
50
+ stub_api_request(:post, "/v3/user/add/name").to_return(:body => {}.to_json)
51
+ expect(api.add_user('name', "org", 'name+suffix@example.com', 'password')).to eq(true)
52
+ end
53
+
54
+ # TODO
55
+ it 'does not escape sp but it must be a bug' do
56
+ stub_api_request(:post, "/v3/user/add/!%20%20%20%20@%23$%25%5E&*()_%2B%7C~%2Ecom").to_return(:body => {}.to_json)
57
+ expect(api.add_user('! @#$%^&*()_+|~.com', "org", 'name+suffix@example.com', 'password')).to eq(true)
58
+ end
59
+ end
60
+
61
+ describe 'remove_user' do
62
+ it 'runs' do
63
+ stub_api_request(:post, "/v3/user/remove/name").to_return(:body => {}.to_json)
64
+ expect(api.remove_user('name')).to eq(true)
65
+ end
66
+ end
67
+
68
+ describe 'change_email' do
69
+ it 'runs' do
70
+ stub_api_request(:post, "/v3/user/email/change/name").
71
+ with(:body => {'email' => 'new@email.com'}).
72
+ to_return(:body => {}.to_json)
73
+ expect(api.change_email('name', 'new@email.com')).to eq(true)
74
+ end
75
+ end
76
+
77
+ describe 'list_apikeys' do
78
+ it 'runs' do
79
+ stub_api_request(:get, "/v3/user/apikey/list/name").
80
+ to_return(:body => {'apikeys' => ['key1', 'key2']}.to_json)
81
+ expect(api.list_apikeys('name')).to eq(['key1', 'key2'])
82
+ end
83
+ end
84
+
85
+ describe 'add_apikey' do
86
+ it 'does not return the generated apikey because you can list apikey afterwards' do
87
+ stub_api_request(:post, "/v3/user/apikey/add/name").
88
+ to_return(:body => {'apikey' => 'apikey'}.to_json)
89
+ expect(api.add_apikey('name')).to eq(true)
90
+ end
91
+ end
92
+
93
+ describe 'remove_apikey' do
94
+ it 'runs' do
95
+ stub_api_request(:post, "/v3/user/apikey/remove/name").
96
+ to_return(:body => {}.to_json)
97
+ expect(api.remove_apikey('name', 'apikey')).to eq(true)
98
+ end
99
+ end
100
+
101
+ describe 'change password' do
102
+ it 'runs' do
103
+ stub_api_request(:post, "/v3/user/password/change/name").
104
+ with(:body => {'password' => 'password'}).
105
+ to_return(:body => {}.to_json)
106
+ expect(api.change_password('name', 'password')).to eq(true)
107
+ end
108
+ end
109
+
110
+ describe 'change my password' do
111
+ it 'runs' do
112
+ stub_api_request(:post, "/v3/user/password/change").
113
+ with(:body => {'old_password' => 'old_password', 'password' => 'password'}).
114
+ to_return(:body => {}.to_json)
115
+ expect(api.change_my_password('old_password', 'password')).to eq(true)
116
+ end
117
+ end
118
+ end