speakeasy_ruby_sdk 0.0.2

Sign up to get free protection for your applications and to get access to all the features.
Files changed (41) hide show
  1. checksums.yaml +7 -0
  2. data/LICENSE +201 -0
  3. data/README.md +184 -0
  4. data/lib/speakeasy_ruby_sdk/config.rb +60 -0
  5. data/lib/speakeasy_ruby_sdk/har_builder.rb +242 -0
  6. data/lib/speakeasy_ruby_sdk/http_transaction.rb +122 -0
  7. data/lib/speakeasy_ruby_sdk/masker.rb +166 -0
  8. data/lib/speakeasy_ruby_sdk/time.rb +42 -0
  9. data/lib/speakeasy_ruby_sdk/url_utils.rb +24 -0
  10. data/lib/speakeasy_ruby_sdk/version.rb +3 -0
  11. data/lib/speakeasy_ruby_sdk.rb +112 -0
  12. data/test/bulk_test.rb +176 -0
  13. data/test/http_test.rb +32 -0
  14. data/test/masker_test.rb +124 -0
  15. data/test/testdata/captures_basic_request_and_no_response_body_input.json +15 -0
  16. data/test/testdata/captures_basic_request_and_no_response_body_output.json +61 -0
  17. data/test/testdata/captures_basic_request_and_response_input.json +21 -0
  18. data/test/testdata/captures_basic_request_and_response_output.json +70 -0
  19. data/test/testdata/captures_basic_request_and_response_with_different_content_types_input.json +22 -0
  20. data/test/testdata/captures_basic_request_and_response_with_different_content_types_output.json +74 -0
  21. data/test/testdata/captures_basic_request_and_response_with_no_response_header_set_input.json +21 -0
  22. data/test/testdata/captures_basic_request_and_response_with_no_response_header_set_output.json +70 -0
  23. data/test/testdata/captures_basic_request_with_nano_precision_input.json +23 -0
  24. data/test/testdata/captures_basic_request_with_nano_precision_output.json +70 -0
  25. data/test/testdata/captures_cookies_input.json +35 -0
  26. data/test/testdata/captures_cookies_output.json +165 -0
  27. data/test/testdata/captures_masked_request_response_input.json +73 -0
  28. data/test/testdata/captures_masked_request_response_output.json +156 -0
  29. data/test/testdata/captures_no_response_body_when_not_modified_input.json +17 -0
  30. data/test/testdata/captures_no_response_body_when_not_modified_output.json +60 -0
  31. data/test/testdata/captures_post_request_with_body_input.json +24 -0
  32. data/test/testdata/captures_post_request_with_body_output.json +81 -0
  33. data/test/testdata/captures_query_params_input.json +21 -0
  34. data/test/testdata/captures_query_params_output.json +75 -0
  35. data/test/testdata/captures_redirect_input.json +22 -0
  36. data/test/testdata/captures_redirect_output.json +74 -0
  37. data/test/testdata/drops_request_and_response_bodies_when_request_body_too_large_input.json +24 -0
  38. data/test/testdata/drops_request_and_response_bodies_when_request_body_too_large_output.json +81 -0
  39. data/test/testdata/drops_response_body_when_too_large_input.json +24 -0
  40. data/test/testdata/drops_response_body_when_too_large_output.json +81 -0
  41. metadata +240 -0
@@ -0,0 +1,17 @@
1
+ {
2
+ "name": "captures no response body when not modified",
3
+ "fields": {
4
+ "max_capture_size": 9437184
5
+ },
6
+ "args": {
7
+ "method": "GET",
8
+ "url": "http://test.com/test",
9
+ "headers": [
10
+ { "key": "Host", "values": ["test.com"] },
11
+ { "key": "Accept-Encoding", "values": ["gzip, deflate"] },
12
+ { "key": "Connection", "values": ["close"] }
13
+ ],
14
+ "response_status": 304,
15
+ "response_body": "test"
16
+ }
17
+ }
@@ -0,0 +1,60 @@
1
+ {
2
+ "log": {
3
+ "version": "1.2",
4
+ "creator": {
5
+ "name": "SpeakeasyRubySdk",
6
+ "version": "0.0.1"
7
+ },
8
+ "entries": [
9
+ {
10
+ "startedDateTime": "2020-01-01T00:00:00.000000000Z",
11
+ "time": 1,
12
+ "request": {
13
+ "method": "GET",
14
+ "url": "http://test.com/test",
15
+ "httpVersion": "HTTP/1.1",
16
+ "cookies": [],
17
+ "headers": [
18
+ {
19
+ "name": "accept-encoding",
20
+ "value": "gzip, deflate"
21
+ },
22
+ {
23
+ "name": "connection",
24
+ "value": "close"
25
+ },
26
+ {
27
+ "name": "host",
28
+ "value": "test.com"
29
+ }
30
+ ],
31
+ "queryString": [],
32
+ "headersSize": 67,
33
+ "bodySize": -1
34
+ },
35
+ "response": {
36
+ "status": 304,
37
+ "statusText": "Not Modified",
38
+ "httpVersion": "HTTP/1.1",
39
+ "cookies": [],
40
+ "headers": [],
41
+ "content": {
42
+ "size": -1,
43
+ "mimeType": "application/octet-stream"
44
+ },
45
+ "redirectURL": "",
46
+ "headersSize": 0,
47
+ "bodySize": 0
48
+ },
49
+ "cache": {},
50
+ "timings": {
51
+ "send": -1,
52
+ "wait": -1,
53
+ "receive": -1
54
+ },
55
+ "serverIPAddress": "test.com"
56
+ }
57
+ ],
58
+ "comment": "request capture for http://test.com/test"
59
+ }
60
+ }
@@ -0,0 +1,24 @@
1
+ {
2
+ "name": "captures post request with Body",
3
+ "fields": {
4
+ "max_capture_size": 9437184
5
+ },
6
+ "args": {
7
+ "method": "POST",
8
+ "url": "http://test.com/test",
9
+ "headers": [
10
+ { "key": "Content-Type", "values": ["application/json"] },
11
+ { "key": "Content-Length", "values": ["15"] },
12
+ { "key": "Host", "values": ["test.com"] },
13
+ { "key": "Accept-Encoding", "values": ["gzip, deflate"] },
14
+ { "key": "Connection", "values": ["close"] }
15
+ ],
16
+ "body": "{\"test\":\"test\"}",
17
+ "response_status": -1,
18
+ "response_body": "test",
19
+ "response_headers": [
20
+ { "key": "Content-Type", "values": ["text/plain; charset=utf-8"] },
21
+ { "key": "Content-Length", "values": ["4"] }
22
+ ]
23
+ }
24
+ }
@@ -0,0 +1,81 @@
1
+ {
2
+ "log": {
3
+ "version": "1.2",
4
+ "creator": {
5
+ "name": "SpeakeasyRubySdk",
6
+ "version": "0.0.1"
7
+ },
8
+ "entries": [
9
+ {
10
+ "startedDateTime": "2020-01-01T00:00:00.000000000Z",
11
+ "time": 1,
12
+ "request": {
13
+ "method": "POST",
14
+ "url": "http://test.com/test",
15
+ "httpVersion": "HTTP/1.1",
16
+ "cookies": [],
17
+ "headers": [
18
+ {
19
+ "name": "accept-encoding",
20
+ "value": "gzip, deflate"
21
+ },
22
+ {
23
+ "name": "connection",
24
+ "value": "close"
25
+ },
26
+ {
27
+ "name": "content-length",
28
+ "value": "15"
29
+ },
30
+ {
31
+ "name": "content-type",
32
+ "value": "application/json"
33
+ },
34
+ {
35
+ "name": "host",
36
+ "value": "test.com"
37
+ }
38
+ ],
39
+ "queryString": [],
40
+ "postData": {
41
+ "mimeType": "application/json","text": "{\"test\":\"test\"}"
42
+ },
43
+ "headersSize": 119,
44
+ "bodySize": 15
45
+ },
46
+ "response": {
47
+ "status": 200,
48
+ "statusText": "OK",
49
+ "httpVersion": "HTTP/1.1",
50
+ "cookies": [],
51
+ "headers": [
52
+ {
53
+ "name": "content-length",
54
+ "value": "4"
55
+ },
56
+ {
57
+ "name": "content-type",
58
+ "value": "text/plain; charset=utf-8"
59
+ }
60
+ ],
61
+ "content": {
62
+ "size": 4,
63
+ "mimeType": "text/plain; charset=utf-8",
64
+ "text": "test"
65
+ },
66
+ "redirectURL": "",
67
+ "headersSize": 60,
68
+ "bodySize": 4
69
+ },
70
+ "cache": {},
71
+ "timings": {
72
+ "send": -1,
73
+ "wait": -1,
74
+ "receive": -1
75
+ },
76
+ "serverIPAddress": "test.com"
77
+ }
78
+ ],
79
+ "comment": "request capture for http://test.com/test"
80
+ }
81
+ }
@@ -0,0 +1,21 @@
1
+ {
2
+ "name": "captures query params",
3
+ "fields": {
4
+ "max_capture_size": 9437184
5
+ },
6
+ "args": {
7
+ "method": "GET",
8
+ "url": "http://test.com/test?param1=value1",
9
+ "headers": [
10
+ { "key": "Host", "values": ["test.com"] },
11
+ { "key": "Accept-Encoding", "values": ["gzip, deflate"] },
12
+ { "key": "Connection", "values": ["close"] }
13
+ ],
14
+ "response_status": 200,
15
+ "response_body": "test",
16
+ "response_headers": [
17
+ { "key": "Content-Type", "values": ["text/html; charset=utf-8"] },
18
+ { "key": "Content-Length", "values": ["4"] }
19
+ ]
20
+ }
21
+ }
@@ -0,0 +1,75 @@
1
+ {
2
+ "log": {
3
+ "version": "1.2",
4
+ "creator": {
5
+ "name": "SpeakeasyRubySdk",
6
+ "version": "0.0.1"
7
+ },
8
+ "entries": [
9
+ {
10
+ "startedDateTime": "2020-01-01T00:00:00.000000000Z",
11
+ "time": 1,
12
+ "request": {
13
+ "method": "GET",
14
+ "url": "http://test.com/test?param1=value1",
15
+ "httpVersion": "HTTP/1.1",
16
+ "cookies": [],
17
+ "headers": [
18
+ {
19
+ "name": "accept-encoding",
20
+ "value": "gzip, deflate"
21
+ },
22
+ {
23
+ "name": "connection",
24
+ "value": "close"
25
+ },
26
+ {
27
+ "name": "host",
28
+ "value": "test.com"
29
+ }
30
+ ],
31
+ "queryString": [
32
+ {
33
+ "name": "param1",
34
+ "value": "value1"
35
+ }
36
+ ],
37
+ "headersSize": 67,
38
+ "bodySize": -1
39
+ },
40
+ "response": {
41
+ "status": 200,
42
+ "statusText": "OK",
43
+ "httpVersion": "HTTP/1.1",
44
+ "cookies": [],
45
+ "headers": [
46
+ {
47
+ "name": "content-length",
48
+ "value": "4"
49
+ },
50
+ {
51
+ "name": "content-type",
52
+ "value": "text/html; charset=utf-8"
53
+ }
54
+ ],
55
+ "content": {
56
+ "size": 4,
57
+ "mimeType": "text/html; charset=utf-8",
58
+ "text": "test"
59
+ },
60
+ "redirectURL": "",
61
+ "headersSize": 59,
62
+ "bodySize": 4
63
+ },
64
+ "cache": {},
65
+ "timings": {
66
+ "send": -1,
67
+ "wait": -1,
68
+ "receive": -1
69
+ },
70
+ "serverIPAddress": "test.com"
71
+ }
72
+ ],
73
+ "comment": "request capture for http://test.com/test?param1=value1"
74
+ }
75
+ }
@@ -0,0 +1,22 @@
1
+ {
2
+ "name": "captures redirect",
3
+ "fields": {
4
+ "max_capture_size": 9437184
5
+ },
6
+ "args": {
7
+ "method": "GET",
8
+ "url": "http://test.com/test",
9
+ "headers": [
10
+ { "key": "Host", "values": ["test.com"] },
11
+ { "key": "Accept-Encoding", "values": ["gzip, deflate"] },
12
+ { "key": "Connection", "values": ["close"] }
13
+ ],
14
+ "response_status": 200,
15
+ "response_body": "test",
16
+ "response_headers": [
17
+ { "key": "Location", "values": ["http://test.com/test2"] },
18
+ { "key": "Content-Type", "values": ["text/html; charset=utf-8"] },
19
+ { "key": "Content-Length", "values": ["4"] }
20
+ ]
21
+ }
22
+ }
@@ -0,0 +1,74 @@
1
+ {
2
+ "log": {
3
+ "version": "1.2",
4
+ "creator": {
5
+ "name": "SpeakeasyRubySdk",
6
+ "version": "0.0.1"
7
+ },
8
+ "entries": [
9
+ {
10
+ "startedDateTime": "2020-01-01T00:00:00.000000000Z",
11
+ "time": 1,
12
+ "request": {
13
+ "method": "GET",
14
+ "url": "http://test.com/test",
15
+ "httpVersion": "HTTP/1.1",
16
+ "cookies": [],
17
+ "headers": [
18
+ {
19
+ "name": "accept-encoding",
20
+ "value": "gzip, deflate"
21
+ },
22
+ {
23
+ "name": "connection",
24
+ "value": "close"
25
+ },
26
+ {
27
+ "name": "host",
28
+ "value": "test.com"
29
+ }
30
+ ],
31
+ "queryString": [],
32
+ "headersSize": 67,
33
+ "bodySize": -1
34
+ },
35
+ "response": {
36
+ "status": 200,
37
+ "statusText": "OK",
38
+ "httpVersion": "HTTP/1.1",
39
+ "cookies": [],
40
+ "headers": [
41
+ {
42
+ "name": "content-length",
43
+ "value": "4"
44
+ },
45
+ {
46
+ "name": "content-type",
47
+ "value": "text/html; charset=utf-8"
48
+ },
49
+ {
50
+ "name": "location",
51
+ "value": "http://test.com/test2"
52
+ }
53
+ ],
54
+ "content": {
55
+ "size": 4,
56
+ "mimeType": "text/html; charset=utf-8",
57
+ "text": "test"
58
+ },
59
+ "redirectURL": "http://test.com/test2",
60
+ "headersSize": 92,
61
+ "bodySize": 4
62
+ },
63
+ "cache": {},
64
+ "timings": {
65
+ "send": -1,
66
+ "wait": -1,
67
+ "receive": -1
68
+ },
69
+ "serverIPAddress": "test.com"
70
+ }
71
+ ],
72
+ "comment": "request capture for http://test.com/test"
73
+ }
74
+ }
@@ -0,0 +1,24 @@
1
+ {
2
+ "name": "drops request and response bodies when request Body too large",
3
+ "fields": {
4
+ "max_capture_size": 10
5
+ },
6
+ "args": {
7
+ "method": "POST",
8
+ "url": "http://test.com/test",
9
+ "headers": [
10
+ { "key": "Content-Type", "values": ["application/json"] },
11
+ { "key": "Content-Length", "values": ["24"] },
12
+ { "key": "Host", "values": ["test.com"] },
13
+ { "key": "Accept-Encoding", "values": ["gzip, deflate"] },
14
+ { "key": "Connection", "values": ["close"] }
15
+ ],
16
+ "body": "{\"tooLarge\":\"veryLarge\"}",
17
+ "response_status": 200,
18
+ "response_body": "no room left for response to be captured",
19
+ "response_headers": [
20
+ { "key": "Content-Type", "values": ["text/plain; charset=utf-8"] },
21
+ { "key": "Content-Length", "values": ["40"] }
22
+ ]
23
+ }
24
+ }
@@ -0,0 +1,81 @@
1
+ {
2
+ "log": {
3
+ "version": "1.2",
4
+ "creator": {
5
+ "name": "SpeakeasyRubySdk",
6
+ "version": "0.0.1"
7
+ },
8
+ "entries": [
9
+ {
10
+ "startedDateTime": "2020-01-01T00:00:00.000000000Z",
11
+ "time": 1,
12
+ "request": {
13
+ "method": "POST",
14
+ "url": "http://test.com/test",
15
+ "httpVersion": "HTTP/1.1",
16
+ "cookies": [],
17
+ "headers": [
18
+ {
19
+ "name": "accept-encoding",
20
+ "value": "gzip, deflate"
21
+ },
22
+ {
23
+ "name": "connection",
24
+ "value": "close"
25
+ },
26
+ {
27
+ "name": "content-length",
28
+ "value": "24"
29
+ },
30
+ {
31
+ "name": "content-type",
32
+ "value": "application/json"
33
+ },
34
+ {
35
+ "name": "host",
36
+ "value": "test.com"
37
+ }
38
+ ],
39
+ "queryString": [],
40
+ "postData": {
41
+ "mimeType": "application/json","text": "--dropped--"
42
+ },
43
+ "headersSize": 119,
44
+ "bodySize": 24
45
+ },
46
+ "response": {
47
+ "status": 200,
48
+ "statusText": "OK",
49
+ "httpVersion": "HTTP/1.1",
50
+ "cookies": [],
51
+ "headers": [
52
+ {
53
+ "name": "content-length",
54
+ "value": "40"
55
+ },
56
+ {
57
+ "name": "content-type",
58
+ "value": "text/plain; charset=utf-8"
59
+ }
60
+ ],
61
+ "content": {
62
+ "size": -1,
63
+ "mimeType": "text/plain; charset=utf-8",
64
+ "text": "--dropped--"
65
+ },
66
+ "redirectURL": "",
67
+ "headersSize": 61,
68
+ "bodySize": 40
69
+ },
70
+ "cache": {},
71
+ "timings": {
72
+ "send": -1,
73
+ "wait": -1,
74
+ "receive": -1
75
+ },
76
+ "serverIPAddress": "test.com"
77
+ }
78
+ ],
79
+ "comment": "request capture for http://test.com/test"
80
+ }
81
+ }
@@ -0,0 +1,24 @@
1
+ {
2
+ "name": "drops response Body when too large",
3
+ "fields": {
4
+ "max_capture_size": 10
5
+ },
6
+ "args": {
7
+ "method": "POST",
8
+ "url": "http://test.com/test",
9
+ "headers": [
10
+ { "key": "Content-Type", "values": ["application/json"] },
11
+ { "key": "Content-Length", "values": ["9"] },
12
+ { "key": "Host", "values": ["test.com"] },
13
+ { "key": "Accept-Encoding", "values": ["gzip, deflate"] },
14
+ { "key": "Connection", "values": ["close"] }
15
+ ],
16
+ "body": "{\"a\":\"b\"}",
17
+ "response_status": 200,
18
+ "response_body": "response is way too large to be captured",
19
+ "response_headers": [
20
+ { "key": "Content-Type", "values": ["text/plain; charset=utf-8"] },
21
+ { "key": "Content-Length", "values": ["40"] }
22
+ ]
23
+ }
24
+ }
@@ -0,0 +1,81 @@
1
+ {
2
+ "log": {
3
+ "version": "1.2",
4
+ "creator": {
5
+ "name": "SpeakeasyRubySdk",
6
+ "version": "0.0.1"
7
+ },
8
+ "entries": [
9
+ {
10
+ "startedDateTime": "2020-01-01T00:00:00.000000000Z",
11
+ "time": 1,
12
+ "request": {
13
+ "method": "POST",
14
+ "url": "http://test.com/test",
15
+ "httpVersion": "HTTP/1.1",
16
+ "cookies": [],
17
+ "headers": [
18
+ {
19
+ "name": "accept-encoding",
20
+ "value": "gzip, deflate"
21
+ },
22
+ {
23
+ "name": "connection",
24
+ "value": "close"
25
+ },
26
+ {
27
+ "name": "content-length",
28
+ "value": "9"
29
+ },
30
+ {
31
+ "name": "content-type",
32
+ "value": "application/json"
33
+ },
34
+ {
35
+ "name": "host",
36
+ "value": "test.com"
37
+ }
38
+ ],
39
+ "queryString": [],
40
+ "postData": {
41
+ "mimeType": "application/json","text": "{\"a\":\"b\"}"
42
+ },
43
+ "headersSize": 118,
44
+ "bodySize": 9
45
+ },
46
+ "response": {
47
+ "status": 200,
48
+ "statusText": "OK",
49
+ "httpVersion": "HTTP/1.1",
50
+ "cookies": [],
51
+ "headers": [
52
+ {
53
+ "name": "content-length",
54
+ "value": "40"
55
+ },
56
+ {
57
+ "name": "content-type",
58
+ "value": "text/plain; charset=utf-8"
59
+ }
60
+ ],
61
+ "content": {
62
+ "size": -1,
63
+ "mimeType": "text/plain; charset=utf-8",
64
+ "text": "--dropped--"
65
+ },
66
+ "redirectURL": "",
67
+ "headersSize": 61,
68
+ "bodySize": 40
69
+ },
70
+ "cache": {},
71
+ "timings": {
72
+ "send": -1,
73
+ "wait": -1,
74
+ "receive": -1
75
+ },
76
+ "serverIPAddress": "test.com"
77
+ }
78
+ ],
79
+ "comment": "request capture for http://test.com/test"
80
+ }
81
+ }