@skyramp/skyramp 0.5.23 → 0.5.25

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.
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@skyramp/skyramp",
3
- "version": "0.5.23",
3
+ "version": "0.5.25",
4
4
  "description": "module for leveraging skyramp cli functionality",
5
5
  "scripts": {
6
6
  "lint": "eslint 'src/**/*.js' 'src/**/*.ts' --fix",
@@ -34,9 +34,10 @@ class RequestV2 {
34
34
  this.queryParams = options.queryParams || {};
35
35
  this.formParams = options.formParams || {};
36
36
  this.expectedCode = options.expectedCode || '';
37
+ this.description = options.description || '';
38
+ this.insecure = options.insecure || false;
37
39
  this.funcHandler = options.funcHandler || '';
38
40
  this.funcHandlerType = options.funcHandlerType || '';
39
- this.insecure = options.insecure || false;
40
41
  }
41
42
 
42
43
  toYaml() {
@@ -53,9 +54,10 @@ class RequestV2 {
53
54
  queryParams: 'query_params',
54
55
  formParams: 'form_params',
55
56
  expectedCode: 'expected_code',
57
+ description: 'description',
58
+ insecure: 'insecure',
56
59
  funcHandler: 'func_handler',
57
- funcHandlerType: 'func_handler_type',
58
- insecure: 'insecure'
60
+ funcHandlerType: 'func_handler_type'
59
61
  };
60
62
 
61
63
  const { body, ...rest } = this;
@@ -92,9 +94,10 @@ class RequestV2 {
92
94
  queryParams: 'query_params',
93
95
  formParams: 'form_params',
94
96
  expectedCode: 'expected_code',
97
+ description: 'description',
98
+ insecure: 'insecure',
95
99
  funcHandler: 'func_handler',
96
- funcHandlerType: 'func_handler_type',
97
- insecure: 'insecure'
100
+ funcHandlerType: 'func_handler_type'
98
101
  };
99
102
 
100
103
  const { ...rest } = this;
@@ -2,6 +2,8 @@
2
2
  * Represents a REST response.
3
3
  */
4
4
  interface ResponseV2Options {
5
+ description?: string;
6
+ error?: string;
5
7
  path?: string;
6
8
  method?: string;
7
9
  statusCode?: string;
@@ -25,6 +25,8 @@ class ResponseV2 {
25
25
  this.requestHeaders = options.request_headers || {};
26
26
  this.requestBody = options.request_body || '';
27
27
  this.duration = options.duration || '';
28
+ this.error = options.error || '';
29
+ this.description = options.description || '';
28
30
  }
29
31
 
30
32
  toYaml() {
@@ -37,7 +39,9 @@ class ResponseV2 {
37
39
  responseBody: 'response_body',
38
40
  requestHeaders: 'request_headers',
39
41
  requestBody: 'request_body',
40
- duration: 'duration'
42
+ duration: 'duration',
43
+ error: 'error',
44
+ description: 'description'
41
45
  };
42
46
 
43
47
  const { body, ...rest } = this;
@@ -70,7 +74,9 @@ class ResponseV2 {
70
74
  responseBody: 'response_body',
71
75
  requestHeaders: 'request_headers',
72
76
  requestBody: 'request_body',
73
- duration: 'duration'
77
+ duration: 'duration',
78
+ error: 'error',
79
+ description: 'description'
74
80
  };
75
81
 
76
82
  const { ...rest } = this;
@@ -42,6 +42,8 @@ interface SendRequestV2Options {
42
42
  queryParams?: {[queryName: string]: string | number | boolean | object | null};
43
43
  formParams?: {[formParamName: string]: string | number | boolean | object | null};
44
44
  expectedCode?: string;
45
+ description?: string;
46
+ insecure?: boolean;
45
47
  funcHandler?: string;
46
48
  funcHandlerType?: string;
47
49
  }
@@ -138,6 +138,7 @@ class SkyrampClient {
138
138
  this.workerNamespaces = [];
139
139
  this.userToken = userToken;
140
140
  this.projectPath = directory;
141
+ this.failedResponses = [];
141
142
  }
142
143
  }
143
144
 
@@ -629,10 +630,18 @@ class SkyrampClient {
629
630
  reject(err);
630
631
  } else if (res) {
631
632
  if (res.error != null) {
633
+ if (res.response != null) {
634
+ const jsonResponse = JSON.parse(res.response);
635
+ const response = new ResponseV2(jsonResponse);
636
+ this.failedResponses.push(response)
637
+ }
632
638
  reject(res.error);
633
639
  } else if (res.response != null) {
634
640
  const jsonResponse = JSON.parse(res.response);
635
641
  const response = new ResponseV2(jsonResponse);
642
+ if (response.error != "") {
643
+ this.failedResponses.push(response)
644
+ }
636
645
  resolve(response);
637
646
  } else {
638
647
  reject(new Error('failed to send request'));
@@ -644,6 +653,14 @@ class SkyrampClient {
644
653
  });
645
654
  }
646
655
 
656
+ isSuccess() {
657
+ return this.failedResponses.length == 0
658
+ }
659
+
660
+ getFailedResponses() {
661
+ return this.failedResponses
662
+ }
663
+
647
664
  async deployDashboard(network) {
648
665
  if (network === undefined || network === null || network === "") {
649
666
  network = "skyramp-dashboard"
package/src/index.js CHANGED
@@ -12,7 +12,7 @@ const Asserts= require('./classes/Asserts');
12
12
  const Step = require('./classes/Step');
13
13
  const RequestV2 = require('./classes/RequestV2');
14
14
  const ResponseV2 = require('./classes/ResponseV2');
15
- const { getValue, checkSchema } = require('./utils');
15
+ const { getValue, checkSchema, iterate } = require('./utils');
16
16
  const { checkStatusCode } = require('./function');
17
17
 
18
18
  module.exports = {
@@ -33,4 +33,5 @@ module.exports = {
33
33
  getValue,
34
34
  checkStatusCode,
35
35
  checkSchema,
36
+ iterate,
36
37
  }
package/src/utils.js CHANGED
@@ -12,6 +12,7 @@ const responseType = koffi.struct({
12
12
 
13
13
  const getJSONValueWrapper = lib.func('getJSONValueWrapper', responseType, ['string', 'string']);
14
14
  const checkSchemaWrapper = lib.func('checkSchemaWrapper', responseType, ['string', 'string']);
15
+ const iterateWrapper = lib.func('generateJsonTreePathsFromBlob', 'string', ['string']);
15
16
 
16
17
  function isJSONString(value) {
17
18
  if (typeof value !== "string") {
@@ -177,11 +178,30 @@ function checkSchema(response, expectedSchema) {
177
178
  return parsed.result;
178
179
  }
179
180
 
181
+ /**
182
+ * Iterate over json blob and generates list of json paths
183
+ *
184
+ * @param {Object} Dict - an object the represents json blob
185
+ * @returns {array} list of json paths
186
+ */
187
+ function iterate(fuzz_body) {
188
+ const jsonString = JSON.stringify(fuzz_body);
189
+ const result = iterateWrapper(jsonString);
190
+
191
+ if (!result) {
192
+ return []
193
+ }
194
+
195
+ const parsed = JSON.parse(result);
196
+ return parsed
197
+ }
198
+
180
199
  module.exports = {
181
200
  createTestDescriptionFromScenario,
182
201
  getYamlBytes,
183
202
  readDataFromFile,
184
203
  getValue,
185
204
  checkSchema,
205
+ iterate,
186
206
  SKYRAMP_YAML_VERSION
187
207
  }