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,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": "content-type",
28
+ "value": "application/json"
29
+ },
30
+ {
31
+ "name": "host",
32
+ "value": "test.com"
33
+ }
34
+ ],
35
+ "queryString": [],
36
+ "headersSize": 99,
37
+ "bodySize": -1
38
+ },
39
+ "response": {
40
+ "status": 200,
41
+ "statusText": "OK",
42
+ "httpVersion": "HTTP/1.1",
43
+ "cookies": [],
44
+ "headers": [
45
+ {
46
+ "name": "content-length",
47
+ "value": "4"
48
+ },
49
+ {
50
+ "name": "content-type",
51
+ "value": "text/plain; charset=utf-8"
52
+ }
53
+ ],
54
+ "content": {
55
+ "size": 4,
56
+ "mimeType": "text/plain; charset=utf-8",
57
+ "text": "test"
58
+ },
59
+ "redirectURL": "",
60
+ "headersSize": 60,
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,21 @@
1
+ {
2
+ "name": "captures basic request and response with no response header set",
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": -1,
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,70 @@
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
+ "content": {
51
+ "size": 4,
52
+ "mimeType": "text/html; charset=utf-8",
53
+ "text": "test"
54
+ },
55
+ "redirectURL": "",
56
+ "headersSize": 59,
57
+ "bodySize": 4
58
+ },
59
+ "cache": {},
60
+ "timings": {
61
+ "send": -1,
62
+ "wait": -1,
63
+ "receive": -1
64
+ },
65
+ "serverIPAddress": "test.com"
66
+ }
67
+ ],
68
+ "comment": "request capture for http://test.com/test"
69
+ }
70
+ }
@@ -0,0 +1,23 @@
1
+ {
2
+ "name": "captures basic request with nano precision",
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
+ "request_start_time": "2020-01-01T00:00:00.0000005Z",
15
+ "elapsed_time": 2,
16
+ "response_status": 200,
17
+ "response_body": "test",
18
+ "response_headers": [
19
+ { "key": "Content-Type", "values": ["text/html; charset=utf-8"] },
20
+ { "key": "Content-Length", "values": ["4"] }
21
+ ]
22
+ }
23
+ }
@@ -0,0 +1,70 @@
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.000000500Z",
11
+ "time": 2,
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
+ "content": {
51
+ "size": 4,
52
+ "mimeType": "text/html; charset=utf-8",
53
+ "text": "test"
54
+ },
55
+ "redirectURL": "",
56
+ "headersSize": 59,
57
+ "bodySize": 4
58
+ },
59
+ "cache": {},
60
+ "timings": {
61
+ "send": -1,
62
+ "wait": -1,
63
+ "receive": -1
64
+ },
65
+ "serverIPAddress": "test.com"
66
+ }
67
+ ],
68
+ "comment": "request capture for http://test.com/test"
69
+ }
70
+ }
@@ -0,0 +1,35 @@
1
+ {
2
+ "name": "captures cookies",
3
+ "fields": {
4
+ "max_capture_size": 9437184
5
+ },
6
+ "args": {
7
+ "method": "GET",
8
+ "url": "http://test.com/test",
9
+ "headers": [
10
+ { "key": "Cookie", "values": ["cookie1=value1; cookie2=value2"] },
11
+ { "key": "Host", "values": ["test.com"] },
12
+ { "key": "Accept-Encoding", "values": ["gzip, deflate"] },
13
+ { "key": "Connection", "values": ["close"] }
14
+ ],
15
+ "response_status": 200,
16
+ "response_body": "test",
17
+ "response_headers": [
18
+ {
19
+ "key": "Set-Cookie",
20
+ "values": [
21
+ "cookie1=value1",
22
+ "cookie2=value2; Max-Age=3600",
23
+ "cookie3=value3; Expires=Wed, 21 Oct 2035 07:28:00 GMT",
24
+ "cookie4=value4; Domain=test.com",
25
+ "cookie5=value5; Path=/test",
26
+ "cookie6=value6; Secure",
27
+ "cookie7=value7; HttpOnly",
28
+ "cookie8=value8; Max-Age=3600; Domain=test.com; Path=/test; Secure; HttpOnly"
29
+ ]
30
+ },
31
+ { "key": "Content-Type", "values": ["text/html; charset=utf-8"] },
32
+ { "key": "Content-Length", "values": ["4"] }
33
+ ]
34
+ }
35
+ }
@@ -0,0 +1,165 @@
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
+ {
18
+ "name": "cookie1",
19
+ "value": "value1"
20
+ },
21
+ {
22
+ "name": "cookie2",
23
+ "value": "value2"
24
+ }
25
+ ],
26
+ "headers": [
27
+ {
28
+ "name": "accept-encoding",
29
+ "value": "gzip, deflate"
30
+ },
31
+ {
32
+ "name": "connection",
33
+ "value": "close"
34
+ },
35
+ {
36
+ "name": "cookie",
37
+ "value": "cookie1=value1; cookie2=value2"
38
+ },
39
+ {
40
+ "name": "host",
41
+ "value": "test.com"
42
+ }
43
+ ],
44
+ "queryString": [],
45
+ "headersSize": 107,
46
+ "bodySize": -1
47
+ },
48
+ "response": {
49
+ "status": 200,
50
+ "statusText": "OK",
51
+ "httpVersion": "HTTP/1.1",
52
+ "cookies": [
53
+ {
54
+ "name": "cookie1",
55
+ "value": "value1",
56
+ "domain": "test.com"
57
+ },
58
+ {
59
+ "name": "cookie2",
60
+ "value": "value2",
61
+ "expires": "2020-01-01T01:00:00.000000000Z",
62
+ "domain": "test.com"
63
+ },
64
+ {
65
+ "name": "cookie3",
66
+ "value": "value3",
67
+ "expires": "2035-10-21T07:28:00.000000000Z",
68
+ "domain": "test.com"
69
+ },
70
+ {
71
+ "name": "cookie4",
72
+ "value": "value4",
73
+ "domain": "test.com"
74
+ },
75
+ {
76
+ "name": "cookie5",
77
+ "value": "value5",
78
+ "path": "/test",
79
+ "domain": "test.com"
80
+ },
81
+ {
82
+ "name": "cookie6",
83
+ "value": "value6",
84
+ "secure": true,
85
+ "domain": "test.com"
86
+ },
87
+ {
88
+ "name": "cookie7",
89
+ "value": "value7",
90
+ "httpOnly": true,
91
+ "domain": "test.com"
92
+ },
93
+ {
94
+ "name": "cookie8",
95
+ "value": "value8",
96
+ "path": "/test",
97
+ "domain": "test.com",
98
+ "expires": "2020-01-01T01:00:00.000000000Z",
99
+ "httpOnly": true,
100
+ "secure": true
101
+ }
102
+ ],
103
+ "headers": [
104
+ {
105
+ "name": "content-length",
106
+ "value": "4"
107
+ },
108
+ {
109
+ "name": "content-type",
110
+ "value": "text/html; charset=utf-8"
111
+ },
112
+ {
113
+ "name": "set-cookie",
114
+ "value": "cookie1=value1"
115
+ },
116
+ {
117
+ "name": "set-cookie",
118
+ "value": "cookie2=value2; Max-Age=3600"
119
+ },
120
+ {
121
+ "name": "set-cookie",
122
+ "value": "cookie3=value3; Expires=Wed, 21 Oct 2035 07:28:00 GMT"
123
+ },
124
+ {
125
+ "name": "set-cookie",
126
+ "value": "cookie4=value4; Domain=test.com"
127
+ },
128
+ {
129
+ "name": "set-cookie",
130
+ "value": "cookie5=value5; Path=/test"
131
+ },
132
+ {
133
+ "name": "set-cookie",
134
+ "value": "cookie6=value6; Secure"
135
+ },
136
+ {
137
+ "name": "set-cookie",
138
+ "value": "cookie7=value7; HttpOnly"
139
+ },
140
+ {
141
+ "name": "set-cookie",
142
+ "value": "cookie8=value8; Max-Age=3600; Domain=test.com; Path=/test; Secure; HttpOnly"
143
+ }
144
+ ],
145
+ "content": {
146
+ "size": 4,
147
+ "mimeType": "text/html; charset=utf-8",
148
+ "text": "test"
149
+ },
150
+ "redirectURL": "",
151
+ "headersSize": 444,
152
+ "bodySize": 4
153
+ },
154
+ "cache": {},
155
+ "timings": {
156
+ "send": -1,
157
+ "wait": -1,
158
+ "receive": -1
159
+ },
160
+ "serverIPAddress": "test.com"
161
+ }
162
+ ],
163
+ "comment": "request capture for http://test.com/test"
164
+ }
165
+ }
@@ -0,0 +1,73 @@
1
+ {
2
+ "name": "captures masked request and response",
3
+ "fields": {
4
+ "max_capture_size": 9437184
5
+ },
6
+ "args": {
7
+ "method": "POST",
8
+ "url": "http://test.com/test?querytest1=test1&querytest2=test2&querytest3=test3",
9
+ "headers": [
10
+ {
11
+ "key": "Cookie",
12
+ "values": ["cookie1=value1; cookie2=value2; cookie3=value3"]
13
+ },
14
+ { "key": "Content-Type", "values": ["application/json"] },
15
+ { "key": "Content-Length", "values": ["93"] },
16
+ { "key": "Host", "values": ["test.com"] },
17
+ { "key": "Accept-Encoding", "values": ["gzip, deflate"] },
18
+ { "key": "Connection", "values": ["close"] },
19
+ { "key": "Authorization", "values": ["Basic dXNlcjpwYXNzd29yZA=="] }
20
+ ],
21
+ "body": "{\"test\":\"test\",\"test1\":123.456,\"address\":{\"line1\":\"line1\",\"line2\":\"line2\",\"street\":\"street\"}}",
22
+ "response_status": -1,
23
+ "response_body": "{\"test\":\"test\",\"test1\":123.456,\"address\":{\"line1\":\"line1\",\"line2\":\"line2\",\"street\":\"street\"}}",
24
+ "response_headers": [
25
+ {
26
+ "key": "Set-Cookie",
27
+ "values": [
28
+ "cookie1=value1",
29
+ "cookie2=value2; Max-Age=3600",
30
+ "cookie3=value3"
31
+ ]
32
+ },
33
+ { "key": "Content-Type", "values": ["application/json; charset=utf-8"] },
34
+ { "key": "Content-Length", "values": ["93"] },
35
+ { "key": "Session", "values": ["session_data"] },
36
+ { "key": "X-Custom-Header", "values": ["1", "2", "3"] }
37
+ ],
38
+ "query_string_masks": {
39
+ "querytest2": "__masked__",
40
+ "querytest3": "_____"
41
+ },
42
+ "request_header_masks": {
43
+ "host": "__masked__",
44
+ "authorization": "_____"
45
+ },
46
+ "request_cookie_masks": {
47
+ "cookie2": "__masked__",
48
+ "cookie3": "_____"
49
+ },
50
+ "request_field_masks_string": {
51
+ "line1": "__masked__",
52
+ "street": "_____"
53
+ },
54
+ "request_field_masks_number": {
55
+ "test1": "-12321"
56
+ },
57
+ "response_header_masks": {
58
+ "session": "_____",
59
+ "x-custom-header": "__masked__"
60
+ },
61
+ "response_cookie_masks": {
62
+ "cookie2": "__masked__",
63
+ "cookie3": "_____"
64
+ },
65
+ "response_field_masks_string": {
66
+ "line1": "__masked__",
67
+ "street": "_____"
68
+ },
69
+ "response_field_masks_number": {
70
+ "test1": "-12321"
71
+ }
72
+ }
73
+ }
@@ -0,0 +1,156 @@
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?querytest1=test1\u0026querytest2=__masked__\u0026querytest3=_____",
15
+ "httpVersion": "HTTP/1.1",
16
+ "cookies": [
17
+ {
18
+ "name": "cookie1",
19
+ "value": "value1"
20
+ },
21
+ {
22
+ "name": "cookie2",
23
+ "value": "__masked__"
24
+ },
25
+ {
26
+ "name": "cookie3",
27
+ "value": "_____"
28
+ }
29
+ ],
30
+ "headers": [
31
+ {
32
+ "name": "accept-encoding",
33
+ "value": "gzip, deflate"
34
+ },
35
+ {
36
+ "name": "authorization",
37
+ "value": "_____"
38
+ },
39
+ {
40
+ "name": "connection",
41
+ "value": "close"
42
+ },
43
+ {
44
+ "name": "content-length",
45
+ "value": "93"
46
+ },
47
+ {
48
+ "name": "content-type",
49
+ "value": "application/json"
50
+ },
51
+ {
52
+ "name": "cookie",
53
+ "value": "cookie1=value1; cookie2=value2; cookie3=value3"
54
+ },
55
+ {
56
+ "name": "host",
57
+ "value": "__masked__"
58
+ }
59
+ ],
60
+ "queryString": [
61
+ {
62
+ "name": "querytest1",
63
+ "value": "test1"
64
+ },
65
+ {
66
+ "name": "querytest2",
67
+ "value": "__masked__"
68
+ },
69
+ {
70
+ "name": "querytest3",
71
+ "value": "_____"
72
+ }
73
+ ],
74
+ "postData": {
75
+ "mimeType": "application/json","text": "{\"test\":\"test\",\"test1\":-12321,\"address\":{\"line1\":\"__masked__\",\"line2\":\"line2\",\"street\":\"_____\"}}"
76
+ },
77
+ "headersSize": 199,
78
+ "bodySize": 93
79
+ },
80
+ "response": {
81
+ "status": 200,
82
+ "statusText": "OK",
83
+ "httpVersion": "HTTP/1.1",
84
+ "cookies": [
85
+ {
86
+ "name": "cookie1",
87
+ "value": "value1",
88
+ "domain": "test.com"
89
+ },
90
+ {
91
+ "name": "cookie2",
92
+ "value": "__masked__",
93
+ "domain": "test.com",
94
+ "expires": "2020-01-01T01:00:00.000000000Z"
95
+ },
96
+ {
97
+ "name": "cookie3",
98
+ "value": "_____",
99
+ "domain": "test.com"
100
+ }
101
+ ],
102
+ "headers": [
103
+ {
104
+ "name": "content-length",
105
+ "value": "93"
106
+ },
107
+ {
108
+ "name": "content-type",
109
+ "value": "application/json; charset=utf-8"
110
+ },
111
+ {
112
+ "name": "session",
113
+ "value": "_____"
114
+ },
115
+ {
116
+ "name": "set-cookie",
117
+ "value": "cookie1=value1"
118
+ },
119
+ {
120
+ "name": "set-cookie",
121
+ "value": "cookie2=value2; Max-Age=3600"
122
+ },
123
+ {
124
+ "name": "set-cookie",
125
+ "value": "cookie3=value3"
126
+ },
127
+ {
128
+ "name": "x-custom-header",
129
+ "value": "__masked__"
130
+ },
131
+ {
132
+ "name": "x-custom-header",
133
+ "value": "__masked__"
134
+ },
135
+ {
136
+ "name": "x-custom-header",
137
+ "value": "__masked__"
138
+ }
139
+ ],
140
+ "content": {
141
+ "size": 93,
142
+ "mimeType": "application/json; charset=utf-8",
143
+ "text": "{\"test\":\"test\",\"test1\":-12321,\"address\":{\"line1\":\"__masked__\",\"line2\":\"line2\",\"street\":\"_____\"}}"
144
+ },
145
+ "redirectURL": "",
146
+ "headersSize": 268,
147
+ "bodySize": 96
148
+ },
149
+ "cache": {},
150
+ "timings": { "send": -1, "wait": -1, "receive": -1 },
151
+ "serverIPAddress": "test.com"
152
+ }
153
+ ],
154
+ "comment": "request capture for http://test.com/test?querytest1=test1\u0026querytest2=__masked__\u0026querytest3=_____"
155
+ }
156
+ }