marty 1.0.47 → 1.0.48
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/Gemfile.lock +1 -1
- data/app/components/marty/api_log_view.rb +55 -34
- data/app/components/marty/report_form.rb +39 -2
- data/app/controllers/marty/diagnostic_controller.rb +1 -1
- data/app/controllers/marty/rpc_controller.rb +16 -14
- data/app/models/marty/data_grid.rb +14 -12
- data/app/models/marty/log.rb +3 -3
- data/app/views/marty/diagnostic/op.html.erb +1 -1
- data/config/locales/en.yml +1 -0
- data/config/routes.rb +4 -0
- data/db/migrate/304_drop_marty_api_logs.rb +9 -0
- data/lib/marty/data_exporter.rb +4 -1
- data/lib/marty/version.rb +1 -1
- data/spec/controllers/diagnostic_controller_spec.rb +1 -1
- data/spec/controllers/rpc_controller_spec.rb +69 -38
- data/spec/features/reporting_spec.rb +44 -0
- metadata +3 -3
- data/app/models/marty/api_log.rb +0 -5
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 376e0b397909c27475e6b4cdae94dee42567e903
|
4
|
+
data.tar.gz: b93e6460252eb76a0391732a33ed14304d422b90
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 5d573ea332aea15f9eb89406a0158c00c359ab2761ddbc53f07804e7bb2044862ca02a31ab1308588c6a2a5d1901797e18367ec80a81738dce87dd2278585fdc
|
7
|
+
data.tar.gz: 6d1523146cc9ed32261d66676c54d673c4221b23cc915b9005a244da666a1c864a9ec451750138773b0a342715f05a8b90fc242fb7a99f7896fddf606ca82705
|
data/Gemfile.lock
CHANGED
@@ -3,28 +3,34 @@ class Marty::ApiLogView < Marty::Grid
|
|
3
3
|
has_marty_permissions read: :admin,
|
4
4
|
update: :admin
|
5
5
|
|
6
|
+
DATE_OP_MAP = {
|
7
|
+
'eq' => '=',
|
8
|
+
'gt' => '>',
|
9
|
+
'lt' => '<'
|
10
|
+
}
|
11
|
+
|
12
|
+
@@attrs = [
|
13
|
+
:script,
|
14
|
+
:node,
|
15
|
+
:attrs,
|
16
|
+
:input,
|
17
|
+
:output,
|
18
|
+
:error,
|
19
|
+
:remote_ip,
|
20
|
+
:auth_name,
|
21
|
+
:start_time,
|
22
|
+
:end_time,
|
23
|
+
]
|
24
|
+
|
6
25
|
def configure(c)
|
7
26
|
super
|
8
27
|
c.editing = :in_form
|
9
28
|
c.paging = :buffered
|
10
29
|
c.title = 'Api Log View'
|
11
|
-
c.model = Marty::
|
12
|
-
c.attributes =
|
13
|
-
|
14
|
-
|
15
|
-
:attrs,
|
16
|
-
:start_time,
|
17
|
-
:end_time,
|
18
|
-
:input,
|
19
|
-
:output,
|
20
|
-
:error,
|
21
|
-
:remote_ip,
|
22
|
-
:auth_name,
|
23
|
-
]
|
24
|
-
|
25
|
-
c.store_config.merge!(
|
26
|
-
{sorters: [{ property: :start_time, direction: :desc }]},
|
27
|
-
)
|
30
|
+
c.model = Marty::Log
|
31
|
+
c.attributes = @@attrs
|
32
|
+
c.scope = {message_type: 'api'}
|
33
|
+
c.store_config.merge!(sorters: [{property: :timestamp, direction: 'DESC'}])
|
28
34
|
end
|
29
35
|
|
30
36
|
component :edit_window do |c|
|
@@ -32,13 +38,6 @@ class Marty::ApiLogView < Marty::Grid
|
|
32
38
|
c.width = 1200
|
33
39
|
end
|
34
40
|
|
35
|
-
[:script, :node, :attrs, :remote_ip, :auth_name, :start_time,
|
36
|
-
:end_time].each do |a|
|
37
|
-
attribute a do |c|
|
38
|
-
c.read_only = true
|
39
|
-
end
|
40
|
-
end
|
41
|
-
|
42
41
|
def default_form_items
|
43
42
|
[
|
44
43
|
:script,
|
@@ -54,20 +53,42 @@ class Marty::ApiLogView < Marty::Grid
|
|
54
53
|
]
|
55
54
|
end
|
56
55
|
|
57
|
-
|
56
|
+
@@attrs.each do |a|
|
58
57
|
attribute a do |c|
|
59
|
-
c.
|
60
|
-
c.
|
61
|
-
c.
|
62
|
-
c.
|
63
|
-
|
58
|
+
c.filterable = true
|
59
|
+
c.read_only = true
|
60
|
+
c.getter = lambda {|r| r.details[a.to_s] }
|
61
|
+
c.sorting_scope = lambda {
|
62
|
+
|r, dir|
|
63
|
+
r.order("details->>'#{a.to_s}'" + dir.to_s)
|
64
|
+
}
|
65
|
+
c.filter_with = lambda {
|
66
|
+
|r, v, op|
|
67
|
+
r.where("details->>'#{a.to_s}' #{op} '#{v}%'")
|
68
|
+
} unless [:start_time, :endtime].include?(a)
|
69
|
+
|
70
|
+
case a
|
71
|
+
when :start_time, :end_time
|
72
|
+
c.type = :datetime
|
73
|
+
c.format = 'Y-m-d h:i:s'
|
74
|
+
c.getter = lambda {|r| Time.zone.parse(r.details[a.to_s])}
|
75
|
+
c.filter_with = lambda {
|
76
|
+
|r, v, op|
|
77
|
+
r.where("(details->>'#{a.to_s}')::date #{DATE_OP_MAP[op]} '#{v}%'")
|
78
|
+
}
|
79
|
+
when :input, :output
|
80
|
+
c.getter = lambda { |r| r.details[a.to_s].pretty_inspect }
|
81
|
+
c.width = 900
|
82
|
+
c.read_only = true
|
83
|
+
end
|
64
84
|
end
|
85
|
+
end
|
86
|
+
|
87
|
+
[:input, :output].each do |a|
|
65
88
|
column a do |c|
|
66
|
-
c.width
|
67
|
-
c.
|
68
|
-
c.getter = lambda { |r| r.send(a).to_json }
|
89
|
+
c.width = 250
|
90
|
+
c.getter = lambda { |r| r.details[a.to_s].to_json }
|
69
91
|
end
|
70
92
|
end
|
71
|
-
|
72
93
|
end
|
73
94
|
ApiLogView = Marty::ApiLogView
|
@@ -14,11 +14,17 @@ class Marty::ReportForm < Marty::Form
|
|
14
14
|
a.disabled = false
|
15
15
|
end
|
16
16
|
|
17
|
+
action :link do |a|
|
18
|
+
a.text = a.tooltip = I18n.t("reporting.link")
|
19
|
+
a.icon = :link_go
|
20
|
+
a.disabled = false
|
21
|
+
end
|
22
|
+
|
17
23
|
######################################################################
|
18
24
|
|
19
25
|
def default_bbar
|
20
26
|
[
|
21
|
-
'->', :apply, :foreground
|
27
|
+
'->', :apply, :foreground, :link
|
22
28
|
]
|
23
29
|
end
|
24
30
|
|
@@ -134,6 +140,37 @@ class Marty::ReportForm < Marty::Form
|
|
134
140
|
document.body.removeChild(form);
|
135
141
|
}
|
136
142
|
JS
|
143
|
+
|
144
|
+
c.netzke_on_link = l(<<-JS)
|
145
|
+
function() {
|
146
|
+
var values = this.getForm().getValues();
|
147
|
+
|
148
|
+
// check for early url generation and exit with error message
|
149
|
+
if (values['selected_script_name'] == null) {
|
150
|
+
alert("Please select a report before generating url.");
|
151
|
+
return;
|
152
|
+
}
|
153
|
+
|
154
|
+
params = {
|
155
|
+
"format": this.repformat,
|
156
|
+
"reptitle": this.reptitle
|
157
|
+
}
|
158
|
+
|
159
|
+
for (var key in values) {if (values[key] == "") {delete values[key]}}
|
160
|
+
data = Ext.encode(values)
|
161
|
+
|
162
|
+
// construct url
|
163
|
+
var proto_host = location.protocol + '//' + location.host
|
164
|
+
var url = proto_host + '/report?data=' + data
|
165
|
+
for (var key in params) {
|
166
|
+
if (params[key] == "") continue;
|
167
|
+
url += '&' + key + '=' + params[key];
|
168
|
+
}
|
169
|
+
url = encodeURI(url)
|
170
|
+
var win = window.open('');
|
171
|
+
win.document.write(url.link(url));
|
172
|
+
}
|
173
|
+
JS
|
137
174
|
end
|
138
175
|
|
139
176
|
endpoint :netzke_load do |params|
|
@@ -231,7 +268,7 @@ class Marty::ReportForm < Marty::Form
|
|
231
268
|
c.reptitle = title
|
232
269
|
c.authenticity_token = controller.send(:form_authenticity_token)
|
233
270
|
|
234
|
-
|
271
|
+
[:foreground, :link].each{|a| actions[a].disabled = !!background_only}
|
235
272
|
end
|
236
273
|
end
|
237
274
|
|
@@ -83,7 +83,7 @@ module Marty
|
|
83
83
|
display = <<-ERB
|
84
84
|
<% inconsistent = diff(data) %>
|
85
85
|
<h3><%=name.demodulize%></h3>
|
86
|
-
<%='<h3 class="error"
|
86
|
+
<%='<h3 class="error">Issues Detected</h3>' if
|
87
87
|
inconsistent%>
|
88
88
|
<div class="wrapper">
|
89
89
|
<% data.each do |node, result| %>
|
@@ -155,10 +155,13 @@ class Marty::RpcController < ActionController::Base
|
|
155
155
|
rescue => e
|
156
156
|
return {error: e.message}
|
157
157
|
end
|
158
|
+
shash = Hash[schemas]
|
158
159
|
pairs = attrs.zip(res)
|
159
|
-
pairs.
|
160
|
+
pairs.each do |attr, result|
|
161
|
+
next unless sch = shash[attr+"_"]
|
162
|
+
next if result.is_a?(Hash) && result["error"]
|
160
163
|
begin
|
161
|
-
er = JSON::Validator.fully_validate(sch.merge(to_append),
|
164
|
+
er = JSON::Validator.fully_validate(sch.merge(to_append), result, opt)
|
162
165
|
rescue NameError
|
163
166
|
return {error: "Unrecognized PgEnum for attribute #{attr}"}
|
164
167
|
rescue => ex
|
@@ -168,20 +171,19 @@ class Marty::RpcController < ActionController::Base
|
|
168
171
|
err_count += er.size
|
169
172
|
end
|
170
173
|
if err_count > 0
|
171
|
-
res = pairs.map do |attr,
|
172
|
-
|
173
|
-
the_error = validation_error[attr]
|
174
|
+
res = pairs.map do |attr, result|
|
175
|
+
next result unless shash[attr+"_"]
|
176
|
+
next result unless the_error = validation_error[attr]
|
174
177
|
|
175
178
|
Marty::Logger.error("API #{sname}:#{node}.#{attr}",
|
176
179
|
{error: the_error,
|
177
|
-
data:
|
178
|
-
|
180
|
+
data: result})
|
181
|
+
strict_validate.include?(attr) ?
|
179
182
|
{error: "Error(s) validating: #{the_error}",
|
180
|
-
data:
|
183
|
+
data: result} : result
|
181
184
|
end
|
182
185
|
end
|
183
186
|
end
|
184
|
-
|
185
187
|
return retval = (attrs_atom ? res.first : res)
|
186
188
|
rescue => exc
|
187
189
|
err_msg = Delorean::Engine.grok_runtime_exception(exc).symbolize_keys
|
@@ -189,9 +191,9 @@ class Marty::RpcController < ActionController::Base
|
|
189
191
|
return retval = err_msg
|
190
192
|
ensure
|
191
193
|
error = Hash === retval ? retval[:error] : nil
|
192
|
-
|
193
|
-
|
194
|
-
|
194
|
+
Marty::Log.write_log('api',
|
195
|
+
"#{sname} - #{node}",
|
196
|
+
{script: sname,
|
195
197
|
node: node,
|
196
198
|
attrs: (attrs_atom ? attrs.first : attrs),
|
197
199
|
input: orig_params,
|
@@ -200,8 +202,8 @@ class Marty::RpcController < ActionController::Base
|
|
200
202
|
end_time: Time.zone.now,
|
201
203
|
error: error,
|
202
204
|
remote_ip: request.remote_ip,
|
203
|
-
auth_name: auth
|
204
|
-
) if need_log.present?
|
205
|
+
auth_name: auth
|
206
|
+
}) if need_log.present?
|
205
207
|
end
|
206
208
|
end
|
207
209
|
end
|
@@ -152,11 +152,13 @@ class Marty::DataGrid < Marty::Base
|
|
152
152
|
PLV_DT_FMT = "%Y-%m-%d %H:%M:%S.%N6"
|
153
153
|
|
154
154
|
def plv_lookup_grid_distinct(h_passed, ret_grid_data=false, distinct=true)
|
155
|
-
row_info = {
|
156
|
-
|
157
|
-
|
158
|
-
|
159
|
-
|
155
|
+
row_info = {
|
156
|
+
"id" => id,
|
157
|
+
"group_id" => group_id,
|
158
|
+
"created_dt" => (
|
159
|
+
@@dtcache ||= {})[created_dt] ||= created_dt.strftime(PLV_DT_FMT)
|
160
|
+
}
|
161
|
+
|
160
162
|
h = metadata.each_with_object({}) do |m, h|
|
161
163
|
attr = m["attr"]
|
162
164
|
inc = h_passed.fetch(attr, :__nf__)
|
@@ -164,19 +166,19 @@ class Marty::DataGrid < Marty::Base
|
|
164
166
|
h[attr] = (defined? inc.name) ? inc.name : inc
|
165
167
|
end
|
166
168
|
|
167
|
-
fn
|
168
|
-
hjson
|
169
|
+
fn = "lookup_grid_distinct"
|
170
|
+
hjson = "'#{h.to_json}'::JSONB"
|
169
171
|
rijson = "'#{row_info.to_json}'::JSONB"
|
170
172
|
params = "#{hjson}, #{rijson}, #{ret_grid_data}, #{distinct}"
|
171
|
-
sql
|
172
|
-
raw
|
173
|
-
res
|
173
|
+
sql = "SELECT #{fn}(#{params})"
|
174
|
+
raw = ActiveRecord::Base.connection.execute(sql)[0][fn]
|
175
|
+
res = JSON.parse(raw)
|
174
176
|
|
175
177
|
if res["error"]
|
176
178
|
msg = res["error"]
|
177
179
|
parms, sqls, ress, dg = res["error_extra"].values_at(
|
178
|
-
|
179
|
-
|
180
|
+
"params", "sql", "results", "dg")
|
181
|
+
|
180
182
|
raise "DG #{name}: Error in PLV8 call: #{msg}\n"\
|
181
183
|
"params: #{parms}\n"\
|
182
184
|
"sqls: #{sqls}\n"\
|
data/app/models/marty/log.rb
CHANGED
@@ -6,9 +6,9 @@ class Marty::Log < Marty::Base
|
|
6
6
|
def self.write_log(type, message, details)
|
7
7
|
begin
|
8
8
|
create!(message_type: type,
|
9
|
-
|
10
|
-
|
11
|
-
|
9
|
+
message: message,
|
10
|
+
details: details,
|
11
|
+
timestamp: Time.zone.now)
|
12
12
|
rescue => e
|
13
13
|
Marty::Util.logger.error("Marty::Logger failure: #{e.message}")
|
14
14
|
end
|
data/config/locales/en.yml
CHANGED
data/config/routes.rb
CHANGED
data/lib/marty/data_exporter.rb
CHANGED
@@ -50,6 +50,9 @@ class Marty::DataExporter
|
|
50
50
|
# FIXME: very hacky to default row_sep to CRLF
|
51
51
|
conf[:row_sep] ||= "\r\n"
|
52
52
|
|
53
|
+
# remove non CSV.generate options before entering generate blocks
|
54
|
+
readable = conf.delete(:readable)
|
55
|
+
|
53
56
|
# FIXME: the following is ridiculously complex. We have different
|
54
57
|
# data paths for hashes and arrays. Also, arrays can turn into
|
55
58
|
# hashes is all their items are hashes! We map to complex objects
|
@@ -69,7 +72,7 @@ class Marty::DataExporter
|
|
69
72
|
csv << x.map { |v|
|
70
73
|
case v
|
71
74
|
when Array, Hash
|
72
|
-
encode_json(v.to_json)
|
75
|
+
readable ? v.to_s : encode_json(v.to_json)
|
73
76
|
when nil
|
74
77
|
nil
|
75
78
|
else
|
data/lib/marty/version.rb
CHANGED
@@ -46,7 +46,9 @@ A: M3::A
|
|
46
46
|
f =?
|
47
47
|
g = e * 5 + f
|
48
48
|
h = f + 1
|
49
|
+
i =?
|
49
50
|
ptest = p * 10
|
51
|
+
ii = i
|
50
52
|
result = [{"a": p, "b": 456}, {"a": 789, "b": p}]
|
51
53
|
eof
|
52
54
|
|
@@ -134,6 +136,10 @@ A:
|
|
134
136
|
}
|
135
137
|
d_ = { "type" : "integer" }
|
136
138
|
|
139
|
+
ii = {}
|
140
|
+
|
141
|
+
ii_ = { "type" : "integer" }
|
142
|
+
|
137
143
|
g = { "properties" : {
|
138
144
|
"e" : { "type" : "integer" },
|
139
145
|
"f" : { "type" : "integer" },
|
@@ -740,6 +746,35 @@ describe Marty::RpcController do
|
|
740
746
|
attr: nil,
|
741
747
|
logged: false,
|
742
748
|
input_validated: true,
|
749
|
+
output_validated: true,
|
750
|
+
strict_validate: true)
|
751
|
+
attrs = ["d", "g", "ii", "result"].to_json
|
752
|
+
params = {"p" => 132, "e" => 55, "f"=>16, "i"=>"string"}.to_json
|
753
|
+
get 'evaluate', {
|
754
|
+
format: :json,
|
755
|
+
script: "M4",
|
756
|
+
node: "A",
|
757
|
+
attrs: attrs,
|
758
|
+
params: params
|
759
|
+
}
|
760
|
+
res_hash = JSON.parse(response.body)
|
761
|
+
errpart = "of type string did not match the following type: integer"
|
762
|
+
expect(res_hash[0]).to eq(135)
|
763
|
+
expect(res_hash[1]).to eq(291)
|
764
|
+
expect(res_hash[2]["error"]).to include(errpart)
|
765
|
+
expect(res_hash[3]).to eq([{"a"=>132,"b"=>456},
|
766
|
+
{"a"=>789,"b"=>132}])
|
767
|
+
logs = Marty::Log.all
|
768
|
+
expect(logs.count).to eq(1)
|
769
|
+
expect(logs[0].details["error"][0]).to include(errpart)
|
770
|
+
end
|
771
|
+
it "validates output 2" do
|
772
|
+
# not all attrs being validated
|
773
|
+
Marty::ApiConfig.create!(script: "M4",
|
774
|
+
node: "A",
|
775
|
+
attr: "result",
|
776
|
+
logged: false,
|
777
|
+
input_validated: true,
|
743
778
|
output_validated: true)
|
744
779
|
attrs = ["d", "g", "result"].to_json
|
745
780
|
params = {"p" => 132, "e" => 55, "f"=>16}.to_json
|
@@ -968,25 +1003,25 @@ describe Marty::RpcController do
|
|
968
1003
|
node: "A",
|
969
1004
|
attr: nil,
|
970
1005
|
logged: true)
|
971
|
-
attrs = ["lc"]
|
1006
|
+
attrs = ["lc"]
|
972
1007
|
params = {"p" => 5}
|
973
1008
|
get 'evaluate', {
|
974
1009
|
format: :csv,
|
975
1010
|
script: "M3",
|
976
1011
|
node: "A",
|
977
|
-
attrs: attrs,
|
1012
|
+
attrs: attrs.to_json,
|
978
1013
|
params: params.to_json
|
979
1014
|
}
|
980
1015
|
expect(response.body).to eq("9\r\n9\r\n")
|
981
|
-
log = Marty::
|
1016
|
+
log = Marty::Log.order(id: :desc).first
|
982
1017
|
|
983
|
-
expect(log.script).to eq("M3")
|
984
|
-
expect(log.node).to eq("A")
|
985
|
-
expect(log.attrs).to eq(attrs)
|
986
|
-
expect(log.input).to eq(params)
|
987
|
-
expect(log.output).to eq([[9,
|
988
|
-
expect(log.remote_ip).to eq("0.0.0.0")
|
989
|
-
expect(log.error).to eq(nil)
|
1018
|
+
expect(log.details['script']).to eq("M3")
|
1019
|
+
expect(log.details['node']).to eq("A")
|
1020
|
+
expect(log.details['attrs']).to eq(attrs)
|
1021
|
+
expect(log.details['input']).to eq(params)
|
1022
|
+
expect(log.details['output']).to eq([[9,9]])
|
1023
|
+
expect(log.details['remote_ip']).to eq("0.0.0.0")
|
1024
|
+
expect(log.details['error']).to eq(nil)
|
990
1025
|
|
991
1026
|
end
|
992
1027
|
|
@@ -995,26 +1030,18 @@ describe Marty::RpcController do
|
|
995
1030
|
node: "A",
|
996
1031
|
attr: nil,
|
997
1032
|
logged: true)
|
998
|
-
attrs = ["lc"]
|
1033
|
+
attrs = ["lc"]
|
999
1034
|
params = {"p" => 5}
|
1000
1035
|
get 'evaluate', {
|
1001
1036
|
format: :csv,
|
1002
1037
|
script: "M3",
|
1003
1038
|
node: "A",
|
1004
|
-
attrs: attrs,
|
1039
|
+
attrs: attrs.to_json,
|
1005
1040
|
params: params.to_json,
|
1006
1041
|
background: true
|
1007
1042
|
}
|
1008
1043
|
expect(response.body).to match(/job_id,/)
|
1009
|
-
log = Marty::
|
1010
|
-
|
1011
|
-
expect(log.script).to eq("M3")
|
1012
|
-
expect(log.node).to eq("A")
|
1013
|
-
expect(log.attrs).to eq(attrs)
|
1014
|
-
expect(log.input).to eq(params)
|
1015
|
-
expect(log.output).to include("job_id")
|
1016
|
-
expect(log.remote_ip).to eq("0.0.0.0")
|
1017
|
-
expect(log.error).to eq(nil)
|
1044
|
+
log = Marty::Log.order(id: :desc).first
|
1018
1045
|
|
1019
1046
|
end
|
1020
1047
|
|
@@ -1026,7 +1053,7 @@ describe Marty::RpcController do
|
|
1026
1053
|
attrs: ["a", "b"].to_json,
|
1027
1054
|
tag: t1.name,
|
1028
1055
|
}
|
1029
|
-
expect(Marty::
|
1056
|
+
expect(Marty::Log.count).to eq(0)
|
1030
1057
|
end
|
1031
1058
|
|
1032
1059
|
it "should handle atom attribute" do
|
@@ -1043,14 +1070,16 @@ describe Marty::RpcController do
|
|
1043
1070
|
params: params.to_json
|
1044
1071
|
}
|
1045
1072
|
expect(response.body).to eq("9\r\n9\r\n")
|
1046
|
-
log = Marty::
|
1047
|
-
|
1048
|
-
expect(log.
|
1049
|
-
expect(log.
|
1050
|
-
expect(log.
|
1051
|
-
expect(log.
|
1052
|
-
expect(log.
|
1053
|
-
expect(log.
|
1073
|
+
log = Marty::Log.order(id: :desc).first
|
1074
|
+
|
1075
|
+
expect(log.details['script']).to eq("M3")
|
1076
|
+
expect(log.details['node']).to eq("A")
|
1077
|
+
expect(log.details['attrs']).to eq("lc")
|
1078
|
+
expect(log.details['input']).to eq(params)
|
1079
|
+
expect(log.details['output']).to eq([9, 9])
|
1080
|
+
expect(log.details['remote_ip']).to eq("0.0.0.0")
|
1081
|
+
expect(log.details['error']).to eq(nil)
|
1082
|
+
|
1054
1083
|
end
|
1055
1084
|
|
1056
1085
|
it "should support api authorization - api_key not required" do
|
@@ -1092,21 +1121,23 @@ describe Marty::RpcController do
|
|
1092
1121
|
apic = Marty::ApiConfig.create!(script: 'M3',
|
1093
1122
|
logged: true)
|
1094
1123
|
|
1124
|
+
attrs = ["pc"]
|
1095
1125
|
get 'evaluate', {
|
1096
1126
|
format: :json,
|
1097
1127
|
script: "M3",
|
1098
1128
|
node: "C",
|
1099
|
-
attrs:
|
1129
|
+
attrs: attrs.to_json,
|
1100
1130
|
api_key: api.api_key,
|
1101
1131
|
}
|
1102
1132
|
expect(response.body).to eq([7].to_json)
|
1103
|
-
log = Marty::
|
1104
|
-
|
1105
|
-
expect(log.
|
1106
|
-
expect(log.
|
1107
|
-
expect(log.
|
1108
|
-
expect(log.
|
1109
|
-
expect(log.
|
1133
|
+
log = Marty::Log.order(id: :desc).first
|
1134
|
+
|
1135
|
+
expect(log.details['script']).to eq("M3")
|
1136
|
+
expect(log.details['node']).to eq("C")
|
1137
|
+
expect(log.details['attrs']).to eq(attrs)
|
1138
|
+
expect(log.details['output']).to eq([7])
|
1139
|
+
expect(log.details['remote_ip']).to eq("0.0.0.0")
|
1140
|
+
expect(log.details['auth_name']).to eq("TestApp")
|
1110
1141
|
end
|
1111
1142
|
|
1112
1143
|
it "should support api authorization - api_key required but incorrect" do
|
@@ -100,6 +100,16 @@ DELOREAN
|
|
100
100
|
end
|
101
101
|
end
|
102
102
|
|
103
|
+
def generate_rep_url format: 'csv'
|
104
|
+
URI.encode("http://#{Capybara.current_session.server.host}"\
|
105
|
+
":#{Capybara.current_session.server.port}"\
|
106
|
+
'/report?data='\
|
107
|
+
'{"pt_name":"XYZ",'\
|
108
|
+
'"selected_script_name":"SomeReport",'\
|
109
|
+
'"selected_node":"AA",'\
|
110
|
+
"\"selected_testing\":\"true\"}&format=#{format}&reptitle=AA")
|
111
|
+
end
|
112
|
+
|
103
113
|
it 'run_script displays proper data' do
|
104
114
|
log_in_as('dev1')
|
105
115
|
go_to_reporting
|
@@ -249,4 +259,38 @@ DELOREAN
|
|
249
259
|
'---')
|
250
260
|
end
|
251
261
|
end
|
262
|
+
|
263
|
+
it 'can generate an url that can be used to access report' do
|
264
|
+
log_in_as('dev1')
|
265
|
+
go_to_reporting
|
266
|
+
|
267
|
+
tag_grid = netzke_find('tag_grid')
|
268
|
+
script_grid = netzke_find('script_grid')
|
269
|
+
|
270
|
+
and_by 'select SomeReport script & AA node' do
|
271
|
+
script_grid.select_row(1)
|
272
|
+
select_node('AA (csv)')
|
273
|
+
end
|
274
|
+
|
275
|
+
and_by 'fill form and navigate to generated link' do
|
276
|
+
wait_for_ajax
|
277
|
+
set_field_value('XYZ', '', 'pt_name')
|
278
|
+
set_field_value('true', 'textfield', 'selected_testing')
|
279
|
+
new_window = window_opened_by {press("Generate URL")}
|
280
|
+
within_window new_window do
|
281
|
+
url = generate_rep_url
|
282
|
+
expect(page).to have_content(url)
|
283
|
+
end
|
284
|
+
new_window.close
|
285
|
+
end
|
286
|
+
end
|
287
|
+
|
288
|
+
it 'can generate report through generated url' do
|
289
|
+
url = generate_rep_url(format: 'txt') + URI.encode('&disposition=inline')
|
290
|
+
visit url
|
291
|
+
wait_for_element do
|
292
|
+
expect(page).to have_content('XYZ1,XYZ2,XYZ3,XYZ4 1,2,3,4 2,4,6,8 ' +
|
293
|
+
'3,6,9,12 4,8,12,16')
|
294
|
+
end
|
295
|
+
end
|
252
296
|
end
|
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: marty
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 1.0.
|
4
|
+
version: 1.0.48
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Arman Bostani
|
@@ -14,7 +14,7 @@ authors:
|
|
14
14
|
autorequire:
|
15
15
|
bindir: bin
|
16
16
|
cert_chain: []
|
17
|
-
date: 2017-11-
|
17
|
+
date: 2017-11-06 00:00:00.000000000 Z
|
18
18
|
dependencies:
|
19
19
|
- !ruby/object:Gem::Dependency
|
20
20
|
name: pg
|
@@ -413,7 +413,6 @@ files:
|
|
413
413
|
- app/helpers/marty/script_set.rb
|
414
414
|
- app/models/marty/api_auth.rb
|
415
415
|
- app/models/marty/api_config.rb
|
416
|
-
- app/models/marty/api_log.rb
|
417
416
|
- app/models/marty/base.rb
|
418
417
|
- app/models/marty/config.rb
|
419
418
|
- app/models/marty/data_grid.rb
|
@@ -481,6 +480,7 @@ files:
|
|
481
480
|
- db/migrate/301_create_marty_api_log.rb
|
482
481
|
- db/migrate/302_add_api_configs_validate_result.rb
|
483
482
|
- db/migrate/303_create_marty_logs.rb
|
483
|
+
- db/migrate/304_drop_marty_api_logs.rb
|
484
484
|
- db/migrate/400_create_dg_plv8_v1_fns.rb
|
485
485
|
- db/seeds.rb
|
486
486
|
- delorean/script_report.dl
|