gooddata 0.6.26 → 0.6.27
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/gooddata.gemspec +3 -4
- data/lib/gooddata/cli/shared.rb +5 -0
- data/lib/gooddata/commands/project.rb +2 -4
- data/lib/gooddata/core/logging.rb +48 -29
- data/lib/gooddata/core/nil_logger.rb +6 -0
- data/lib/gooddata/helpers/global_helpers.rb +3 -3
- data/lib/gooddata/models/domain.rb +5 -4
- data/lib/gooddata/models/metadata.rb +2 -1
- data/lib/gooddata/models/metadata/report.rb +5 -1
- data/lib/gooddata/models/model.rb +1 -1
- data/lib/gooddata/models/process.rb +2 -0
- data/lib/gooddata/models/project.rb +30 -9
- data/lib/gooddata/models/project_metadata.rb +8 -2
- data/lib/gooddata/rest/connection.rb +19 -17
- data/lib/gooddata/version.rb +1 -1
- data/spec/environment/develop.rb +4 -4
- data/spec/environment/environment.rb +9 -2
- data/spec/integration/clients_spec.rb +5 -6
- data/spec/integration/full_process_schedule_spec.rb +1 -1
- data/spec/integration/project_spec.rb +3 -3
- data/spec/integration/schedule_spec.rb +2 -2
- data/spec/integration/user_filters_spec.rb +2 -1
- data/spec/integration/user_group_spec.rb +8 -8
- data/spec/integration/variables_spec.rb +2 -1
- data/spec/unit/core/logging_spec.rb +11 -3
- data/spec/unit/helpers_spec.rb +0 -1
- data/spec/unit/models/domain_spec.rb +0 -9
- data/spec/unit/models/from_wire_spec.rb +0 -4
- data/spec/unit/models/metric_spec.rb +0 -4
- data/spec/unit/models/profile_spec.rb +3 -2
- data/spec/unit/models/project_role_spec.rb +7 -8
- data/spec/unit/models/to_manifest_spec.rb +2 -4
- metadata +30 -81
- data/lib/gooddata/rest/connections/rest_client_connection.rb +0 -181
- data/spec/unit/cli/commands/cmd_api_spec.rb +0 -40
- data/spec/unit/cli/commands/cmd_domain_spec.rb +0 -112
- data/spec/unit/cli/commands/cmd_process_spec.rb +0 -47
- data/spec/unit/cli/commands/cmd_project_spec.rb +0 -85
- data/spec/unit/cli/commands/cmd_role_spec.rb +0 -59
- data/spec/unit/cli/commands/cmd_run_ruby_spec.rb +0 -17
- data/spec/unit/cli/commands/cmd_scaffold_spec.rb +0 -64
- data/spec/unit/cli/commands/cmd_user_spec.rb +0 -35
- data/spec/unit/commands/command_api_spec.rb +0 -18
- data/spec/unit/commands/command_auth_spec.rb +0 -171
- data/spec/unit/commands/command_dataset_spec.rb +0 -50
- data/spec/unit/commands/command_process_spec.rb +0 -97
- data/spec/unit/commands/command_scaffold_spec.rb +0 -67
- data/spec/unit/commands/command_user_spec.rb +0 -28
- data/spec/unit/data/guesser_spec.rb +0 -63
@@ -1,181 +0,0 @@
|
|
1
|
-
# encoding: UTF-8
|
2
|
-
#
|
3
|
-
# Copyright (c) 2010-2015 GoodData Corporation. All rights reserved.
|
4
|
-
# This source code is licensed under the BSD-style license found in the
|
5
|
-
# LICENSE file in the root directory of this source tree.
|
6
|
-
|
7
|
-
require_relative '../connection'
|
8
|
-
|
9
|
-
require 'multi_json'
|
10
|
-
require 'rest-client'
|
11
|
-
|
12
|
-
module GoodData
|
13
|
-
module Rest
|
14
|
-
module Connections
|
15
|
-
# Implementation of GoodData::Rest::Connection using https://rubygems.org/gems/rest-client
|
16
|
-
class RestClientConnection < GoodData::Rest::Connection
|
17
|
-
def initialize(opts = {})
|
18
|
-
super
|
19
|
-
|
20
|
-
@headers = DEFAULT_HEADERS.dup
|
21
|
-
@user = nil
|
22
|
-
@server = nil
|
23
|
-
|
24
|
-
@opts = opts
|
25
|
-
headers = opts[:headers] || {}
|
26
|
-
@headers.merge! headers
|
27
|
-
end
|
28
|
-
|
29
|
-
# Connect using username and password
|
30
|
-
def connect(username, password, options = {})
|
31
|
-
server = options[:server] || Helpers::AuthHelper.read_server
|
32
|
-
@server = RestClient::Resource.new server, DEFAULT_LOGIN_PAYLOAD
|
33
|
-
|
34
|
-
super
|
35
|
-
end
|
36
|
-
|
37
|
-
# HTTP DELETE
|
38
|
-
#
|
39
|
-
# @param uri [String] Target URI
|
40
|
-
def delete(uri, options = {})
|
41
|
-
GoodData.logger.debug "DELETE: #{@server.url}#{uri}"
|
42
|
-
profile "DELETE #{uri}" do
|
43
|
-
b = proc { @server[uri].delete cookies }
|
44
|
-
process_response(options, &b)
|
45
|
-
end
|
46
|
-
end
|
47
|
-
|
48
|
-
# HTTP GET
|
49
|
-
#
|
50
|
-
# @param uri [String] Target URI
|
51
|
-
def get(uri, options = {})
|
52
|
-
GoodData.logger.debug "GET: #{@server.url}#{uri}"
|
53
|
-
profile "GET #{uri}" do
|
54
|
-
b = proc { @server[uri].get cookies }
|
55
|
-
process_response(options, &b)
|
56
|
-
end
|
57
|
-
end
|
58
|
-
|
59
|
-
# HTTP PUT
|
60
|
-
#
|
61
|
-
# @param uri [String] Target URI
|
62
|
-
def put(uri, data, options = {})
|
63
|
-
payload = data.is_a?(Hash) ? data.to_json : data
|
64
|
-
GoodData.logger.debug "PUT: #{@server.url}#{uri}, #{scrub_params(data, [:password, :login, :authorizationToken, :verifyPassword])}"
|
65
|
-
profile "PUT #{uri}" do
|
66
|
-
b = proc { @server[uri].put payload, cookies }
|
67
|
-
process_response(options, &b)
|
68
|
-
end
|
69
|
-
end
|
70
|
-
|
71
|
-
# HTTP POST
|
72
|
-
#
|
73
|
-
# @param uri [String] Target URI
|
74
|
-
def post(uri, data, options = {})
|
75
|
-
GoodData.logger.debug "POST: #{@server.url}#{uri}, #{scrub_params(data, [:password, :login, :authorizationToken, :verifyPassword])}"
|
76
|
-
profile "POST #{uri}" do
|
77
|
-
payload = data.is_a?(Hash) ? data.to_json : data
|
78
|
-
b = proc { @server[uri].post payload, cookies }
|
79
|
-
process_response(options, &b)
|
80
|
-
end
|
81
|
-
end
|
82
|
-
|
83
|
-
# Uploads a file to GoodData server
|
84
|
-
# /uploads/ resources are special in that they use a different
|
85
|
-
# host and a basic authentication.
|
86
|
-
def upload(file, options = {})
|
87
|
-
dir = options[:directory] || ''
|
88
|
-
staging_uri = options[:staging_url].to_s
|
89
|
-
url = dir.empty? ? staging_uri : URI.join(staging_uri, "#{dir}/").to_s
|
90
|
-
|
91
|
-
# Make a directory, if needed
|
92
|
-
unless dir.empty?
|
93
|
-
method = :get
|
94
|
-
GoodData.logger.debug "#{method}: #{url}"
|
95
|
-
begin
|
96
|
-
# first check if it does exits
|
97
|
-
raw = {
|
98
|
-
:method => method,
|
99
|
-
:url => url,
|
100
|
-
# :timeout => @options[:timeout],
|
101
|
-
:headers => @headers
|
102
|
-
}.merge(cookies)
|
103
|
-
RestClient::Request.execute(raw)
|
104
|
-
rescue RestClient::Exception => e
|
105
|
-
if e.http_code == 404
|
106
|
-
method = :mkcol
|
107
|
-
GoodData.logger.debug "#{method}: #{url}"
|
108
|
-
raw = {
|
109
|
-
:method => method,
|
110
|
-
:url => url,
|
111
|
-
# :timeout => @options[:timeout],
|
112
|
-
:headers => @headers
|
113
|
-
}.merge(cookies)
|
114
|
-
RestClient::Request.execute(raw)
|
115
|
-
end
|
116
|
-
end
|
117
|
-
end
|
118
|
-
|
119
|
-
payload = options[:stream] ? 'file' : File.read(file)
|
120
|
-
filename = options[:filename] || options[:stream] ? 'randome-filename.txt' : File.basename(file)
|
121
|
-
|
122
|
-
# Upload the file
|
123
|
-
# puts "uploading the file #{URI.join(url, filename).to_s}"
|
124
|
-
raw = {
|
125
|
-
:method => :put,
|
126
|
-
:url => URI.join(url, filename).to_s,
|
127
|
-
# :timeout => @options[:timeout],
|
128
|
-
:headers => {
|
129
|
-
:user_agent => GoodData.gem_version_string
|
130
|
-
},
|
131
|
-
:payload => payload,
|
132
|
-
:raw_response => true,
|
133
|
-
# :user => @username,
|
134
|
-
# :password => @password
|
135
|
-
}.merge(cookies)
|
136
|
-
RestClient::Request.execute(raw)
|
137
|
-
true
|
138
|
-
end
|
139
|
-
|
140
|
-
private
|
141
|
-
|
142
|
-
def process_response(options = {}, &block)
|
143
|
-
begin
|
144
|
-
response = block.call
|
145
|
-
rescue RestClient::Unauthorized
|
146
|
-
raise $ERROR_INFO if options[:dont_reauth]
|
147
|
-
refresh_token
|
148
|
-
response = block.call
|
149
|
-
end
|
150
|
-
|
151
|
-
merge_cookies! response.cookies
|
152
|
-
content_type = response.headers[:content_type]
|
153
|
-
return response if options[:process] == false
|
154
|
-
|
155
|
-
if content_type == 'application/json' || content_type == 'application/json;charset=UTF-8'
|
156
|
-
result = response.to_str == '""' ? {} : MultiJson.load(response.to_str)
|
157
|
-
GoodData.logger.debug "Response: #{result.inspect}"
|
158
|
-
elsif ['text/plain;charset=UTF-8', 'text/plain; charset=UTF-8', 'text/plain'].include?(content_type)
|
159
|
-
result = response
|
160
|
-
GoodData.logger.debug "Response: plain text - #{result[0..99]}"
|
161
|
-
elsif content_type == 'application/zip'
|
162
|
-
result = response
|
163
|
-
GoodData.logger.debug 'Response: a zipped stream'
|
164
|
-
elsif response.headers[:content_length].to_s == '0'
|
165
|
-
result = nil
|
166
|
-
GoodData.logger.debug 'Response: Empty response possibly 204'
|
167
|
-
elsif response.code == 204
|
168
|
-
result = nil
|
169
|
-
GoodData.logger.debug 'Response: 204 no content'
|
170
|
-
else
|
171
|
-
fail "Unsupported response content type '%s':\n%s" % [content_type, response.to_str[0..127]]
|
172
|
-
end
|
173
|
-
result
|
174
|
-
rescue RestClient::Exception => e
|
175
|
-
GoodData.logger.debug "Response: #{e.response}"
|
176
|
-
raise $ERROR_INFO
|
177
|
-
end
|
178
|
-
end
|
179
|
-
end
|
180
|
-
end
|
181
|
-
end
|
@@ -1,40 +0,0 @@
|
|
1
|
-
# encoding: UTF-8
|
2
|
-
#
|
3
|
-
# Copyright (c) 2010-2015 GoodData Corporation. All rights reserved.
|
4
|
-
# This source code is licensed under the BSD-style license found in the
|
5
|
-
# LICENSE file in the root directory of this source tree.
|
6
|
-
|
7
|
-
require 'gooddata/cli/cli'
|
8
|
-
|
9
|
-
describe 'GoodData::CLI - api', :broken => true do
|
10
|
-
describe 'api' do
|
11
|
-
it 'Complains when no subcommand specified' do
|
12
|
-
args = %w(api)
|
13
|
-
|
14
|
-
out = run_cli(args)
|
15
|
-
out.should include("Command 'api' requires a subcommand info,get")
|
16
|
-
end
|
17
|
-
end
|
18
|
-
|
19
|
-
describe 'api info' do
|
20
|
-
it 'Can be called without arguments' do
|
21
|
-
args = %w(api info)
|
22
|
-
|
23
|
-
run_cli(args)
|
24
|
-
end
|
25
|
-
end
|
26
|
-
|
27
|
-
describe 'api get' do
|
28
|
-
it 'Can be called without arguments' do
|
29
|
-
args = %w(api get)
|
30
|
-
|
31
|
-
run_cli(args)
|
32
|
-
end
|
33
|
-
|
34
|
-
it 'Is able to get /gdc' do
|
35
|
-
args = %w(api get /gdc)
|
36
|
-
|
37
|
-
run_cli(args)
|
38
|
-
end
|
39
|
-
end
|
40
|
-
end
|
@@ -1,112 +0,0 @@
|
|
1
|
-
# encoding: UTF-8
|
2
|
-
#
|
3
|
-
# Copyright (c) 2010-2015 GoodData Corporation. All rights reserved.
|
4
|
-
# This source code is licensed under the BSD-style license found in the
|
5
|
-
# LICENSE file in the root directory of this source tree.
|
6
|
-
|
7
|
-
require 'gooddata/cli/cli'
|
8
|
-
|
9
|
-
describe 'GoodData::CLI - domain', :broken => true do
|
10
|
-
describe 'domain' do
|
11
|
-
it 'Complains when no subcommand specified' do
|
12
|
-
args = %w(domain)
|
13
|
-
|
14
|
-
out = run_cli(args)
|
15
|
-
out.should include "Command 'domain' requires a subcommand add_user,list_users"
|
16
|
-
end
|
17
|
-
end
|
18
|
-
|
19
|
-
describe "domain add_user" do
|
20
|
-
TEST_DOMAIN = 'gooddata'
|
21
|
-
TEST_EMAIL = 'joe.doe@gooddata.com'
|
22
|
-
TEST_PASSWORD = 'p4ssw0rth'
|
23
|
-
|
24
|
-
it "Outputs 'Domain name has to be provided' if none specified" do
|
25
|
-
args = [
|
26
|
-
'-U',
|
27
|
-
ConnectionHelper::DEFAULT_USERNAME,
|
28
|
-
'-P',
|
29
|
-
ConnectionHelper::DEFAULT_PASSWORD,
|
30
|
-
'domain',
|
31
|
-
'add_user'
|
32
|
-
]
|
33
|
-
|
34
|
-
out = run_cli(args)
|
35
|
-
out.should include 'Domain name has to be provided'
|
36
|
-
end
|
37
|
-
|
38
|
-
it "Outputs 'Email has to be provided' if none specified" do
|
39
|
-
args = [
|
40
|
-
'-U',
|
41
|
-
ConnectionHelper::DEFAULT_USERNAME,
|
42
|
-
'-P',
|
43
|
-
ConnectionHelper::DEFAULT_PASSWORD,
|
44
|
-
'domain',
|
45
|
-
'add_user',
|
46
|
-
TEST_DOMAIN
|
47
|
-
]
|
48
|
-
|
49
|
-
out = run_cli(args)
|
50
|
-
out.should include 'Email has to be provided'
|
51
|
-
end
|
52
|
-
|
53
|
-
it "Outputs 'Password has to be provided' if none specified" do
|
54
|
-
args = [
|
55
|
-
'-U',
|
56
|
-
ConnectionHelper::DEFAULT_USERNAME,
|
57
|
-
'-P',
|
58
|
-
ConnectionHelper::DEFAULT_PASSWORD,
|
59
|
-
'domain',
|
60
|
-
'add_user',
|
61
|
-
TEST_DOMAIN,
|
62
|
-
TEST_EMAIL
|
63
|
-
]
|
64
|
-
|
65
|
-
out = run_cli(args)
|
66
|
-
out.should include 'Password has to be provided'
|
67
|
-
end
|
68
|
-
|
69
|
-
it 'Works' do
|
70
|
-
args = [
|
71
|
-
'-U',
|
72
|
-
ConnectionHelper::DEFAULT_USERNAME,
|
73
|
-
'-P',
|
74
|
-
ConnectionHelper::DEFAULT_PASSWORD,
|
75
|
-
'domain',
|
76
|
-
'add_user',
|
77
|
-
TEST_DOMAIN,
|
78
|
-
TEST_EMAIL,
|
79
|
-
TEST_PASSWORD
|
80
|
-
]
|
81
|
-
|
82
|
-
out = run_cli(args)
|
83
|
-
end
|
84
|
-
|
85
|
-
end
|
86
|
-
|
87
|
-
describe 'domain list_users' do
|
88
|
-
it 'Complains when no parameters specified' do
|
89
|
-
args = [
|
90
|
-
'-U',
|
91
|
-
ConnectionHelper::DEFAULT_USERNAME,
|
92
|
-
'-P',
|
93
|
-
ConnectionHelper::DEFAULT_PASSWORD,
|
94
|
-
'domain',
|
95
|
-
'list_users'
|
96
|
-
]
|
97
|
-
|
98
|
-
out = run_cli(args)
|
99
|
-
out.should include 'Domain name has to be provided'
|
100
|
-
end
|
101
|
-
|
102
|
-
it 'Works' do
|
103
|
-
args = [
|
104
|
-
'domain',
|
105
|
-
'list_users',
|
106
|
-
'gooddata'
|
107
|
-
]
|
108
|
-
|
109
|
-
out = run_cli(args)
|
110
|
-
end
|
111
|
-
end
|
112
|
-
end
|
@@ -1,47 +0,0 @@
|
|
1
|
-
# encoding: UTF-8
|
2
|
-
#
|
3
|
-
# Copyright (c) 2010-2015 GoodData Corporation. All rights reserved.
|
4
|
-
# This source code is licensed under the BSD-style license found in the
|
5
|
-
# LICENSE file in the root directory of this source tree.
|
6
|
-
|
7
|
-
require 'gooddata/cli/cli'
|
8
|
-
|
9
|
-
describe 'GoodData::CLI - process', :broken => true do
|
10
|
-
describe 'process' do
|
11
|
-
it 'Complains when no subcommand specified' do
|
12
|
-
args = %w(process)
|
13
|
-
|
14
|
-
out = run_cli(args)
|
15
|
-
out.should include "Command 'process' requires a subcommand list,show,deploy,delete,execute"
|
16
|
-
end
|
17
|
-
end
|
18
|
-
|
19
|
-
describe 'process deploy' do
|
20
|
-
it 'Can be called without arguments' do
|
21
|
-
args = %w(process deploy)
|
22
|
-
|
23
|
-
run_cli(args)
|
24
|
-
end
|
25
|
-
end
|
26
|
-
|
27
|
-
describe 'process get' do
|
28
|
-
it 'Can be called without arguments' do
|
29
|
-
args = %w(process get)
|
30
|
-
|
31
|
-
run_cli(args)
|
32
|
-
end
|
33
|
-
end
|
34
|
-
|
35
|
-
describe 'process list' do
|
36
|
-
it 'Lists processes when project ID specified' do
|
37
|
-
args = [
|
38
|
-
'process',
|
39
|
-
'list',
|
40
|
-
ProjectHelper::PROJECT_ID
|
41
|
-
]
|
42
|
-
|
43
|
-
run_cli(args)
|
44
|
-
end
|
45
|
-
end
|
46
|
-
|
47
|
-
end
|
@@ -1,85 +0,0 @@
|
|
1
|
-
# encoding: UTF-8
|
2
|
-
#
|
3
|
-
# Copyright (c) 2010-2015 GoodData Corporation. All rights reserved.
|
4
|
-
# This source code is licensed under the BSD-style license found in the
|
5
|
-
# LICENSE file in the root directory of this source tree.
|
6
|
-
|
7
|
-
require 'gooddata/cli/cli'
|
8
|
-
|
9
|
-
describe 'GoodData::CLI - project', :broken => true do
|
10
|
-
describe 'project' do
|
11
|
-
it 'Complains when no subcommand specified' do
|
12
|
-
args = %w(project)
|
13
|
-
|
14
|
-
out = run_cli(args)
|
15
|
-
out.should include "Command 'project' requires a subcommand jack_in,create,delete,clone,invite,users,show,build,update,roles,validate"
|
16
|
-
end
|
17
|
-
end
|
18
|
-
|
19
|
-
describe 'project build' do
|
20
|
-
it 'Can be called without arguments' do
|
21
|
-
args = %w(project build)
|
22
|
-
|
23
|
-
run_cli(args)
|
24
|
-
end
|
25
|
-
end
|
26
|
-
|
27
|
-
describe 'project clone' do
|
28
|
-
it 'Can be called without arguments' do
|
29
|
-
args = %w(project clone)
|
30
|
-
|
31
|
-
run_cli(args)
|
32
|
-
end
|
33
|
-
end
|
34
|
-
|
35
|
-
describe 'project create' do
|
36
|
-
it 'Can be called without arguments' do
|
37
|
-
args = %w(project create)
|
38
|
-
|
39
|
-
# TODO: Pass all required args to prevent interaction
|
40
|
-
# TODO: Investigate, fix and enable execution
|
41
|
-
# run_cli(args)
|
42
|
-
end
|
43
|
-
end
|
44
|
-
|
45
|
-
describe 'project delete' do
|
46
|
-
it 'Can be called without arguments' do
|
47
|
-
args = %w(project delete)
|
48
|
-
|
49
|
-
run_cli(args)
|
50
|
-
end
|
51
|
-
end
|
52
|
-
|
53
|
-
describe 'project jack_in' do
|
54
|
-
it 'Can be called without arguments' do
|
55
|
-
args = %w(project jack_in)
|
56
|
-
|
57
|
-
run_cli(args)
|
58
|
-
end
|
59
|
-
end
|
60
|
-
|
61
|
-
describe 'project list' do
|
62
|
-
it 'Can be called without arguments' do
|
63
|
-
args = %w(project list)
|
64
|
-
|
65
|
-
run_cli(args)
|
66
|
-
end
|
67
|
-
end
|
68
|
-
|
69
|
-
describe 'project show' do
|
70
|
-
it 'Can be called without arguments' do
|
71
|
-
args = %w(project show)
|
72
|
-
|
73
|
-
run_cli(args)
|
74
|
-
end
|
75
|
-
end
|
76
|
-
|
77
|
-
describe 'project update' do
|
78
|
-
it 'Can be called without arguments' do
|
79
|
-
args = %w(project update)
|
80
|
-
|
81
|
-
run_cli(args)
|
82
|
-
end
|
83
|
-
end
|
84
|
-
|
85
|
-
end
|