rabid 0.0.1

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.
Files changed (58) hide show
  1. checksums.yaml +7 -0
  2. data/.gitignore +7 -0
  3. data/.rubocop.yml +22 -0
  4. data/.yardopts +4 -0
  5. data/.yardopts-dev +6 -0
  6. data/Gemfile +6 -0
  7. data/Gemfile.lock +56 -0
  8. data/LICENSE.txt +21 -0
  9. data/README.md +15 -0
  10. data/Rakefile +10 -0
  11. data/bigipcookie.gemspec +49 -0
  12. data/bin/rabid +67 -0
  13. data/bin/rabid_console +7 -0
  14. data/bin/rabid_setup +6 -0
  15. data/docs/.nojekyll +0 -0
  16. data/docs/About.md +11 -0
  17. data/docs/CHANGELOG.md +1 -0
  18. data/docs/README.md +13 -0
  19. data/docs/_coverpage.md +14 -0
  20. data/docs/_media/logo.png +0 -0
  21. data/docs/_navbar.md +2 -0
  22. data/docs/_sidebar.md +15 -0
  23. data/docs/index.html +31 -0
  24. data/docs/pages/demo.md +3 -0
  25. data/docs/pages/documentation.md +34 -0
  26. data/docs/pages/install.md +60 -0
  27. data/docs/pages/publishing.md +38 -0
  28. data/docs/pages/quick-start.md +30 -0
  29. data/docs/pages/usage.md +53 -0
  30. data/docs/vendor/docsify.js +1 -0
  31. data/docs/vendor/plugins/emoji.min.js +1 -0
  32. data/docs/vendor/plugins/search.min.js +1 -0
  33. data/docs/vendor/prismjs/components/prism-ruby.min.js +1 -0
  34. data/docs/vendor/themes/vue.css +1 -0
  35. data/docs/why.md +46 -0
  36. data/docs/yard/BigIPCookie/Decode.html +782 -0
  37. data/docs/yard/BigIPCookie.html +159 -0
  38. data/docs/yard/Version.html +126 -0
  39. data/docs/yard/_index.html +138 -0
  40. data/docs/yard/class_list.html +51 -0
  41. data/docs/yard/css/common.css +1 -0
  42. data/docs/yard/css/full_list.css +58 -0
  43. data/docs/yard/css/style.css +496 -0
  44. data/docs/yard/file.LICENSE.html +70 -0
  45. data/docs/yard/file.README.html +109 -0
  46. data/docs/yard/file_list.html +61 -0
  47. data/docs/yard/frames.html +17 -0
  48. data/docs/yard/index.html +109 -0
  49. data/docs/yard/js/app.js +303 -0
  50. data/docs/yard/js/full_list.js +216 -0
  51. data/docs/yard/js/jquery.js +4 -0
  52. data/docs/yard/method_list.html +99 -0
  53. data/docs/yard/top-level-namespace.html +112 -0
  54. data/lib/bigipcookie/version.rb +5 -0
  55. data/lib/bigipcookie.rb +246 -0
  56. data/package-lock.json +154 -0
  57. data/test/test_bigipcookie.rb +54 -0
  58. metadata +248 -0
@@ -0,0 +1,112 @@
1
+ <!DOCTYPE html>
2
+ <html>
3
+ <head>
4
+ <meta charset="utf-8">
5
+ <meta name="viewport" content="width=device-width, initial-scale=1.0">
6
+ <title>
7
+ Top Level Namespace
8
+
9
+ &mdash; Documentation by YARD 0.9.20
10
+
11
+ </title>
12
+
13
+ <link rel="stylesheet" href="css/style.css" type="text/css" charset="utf-8" />
14
+
15
+ <link rel="stylesheet" href="css/common.css" type="text/css" charset="utf-8" />
16
+
17
+ <script type="text/javascript" charset="utf-8">
18
+ pathId = "";
19
+ relpath = '';
20
+ </script>
21
+
22
+
23
+ <script type="text/javascript" charset="utf-8" src="js/jquery.js"></script>
24
+
25
+ <script type="text/javascript" charset="utf-8" src="js/app.js"></script>
26
+
27
+
28
+ </head>
29
+ <body>
30
+ <div class="nav_wrap">
31
+ <iframe id="nav" src="class_list.html?1"></iframe>
32
+ <div id="resizer"></div>
33
+ </div>
34
+
35
+ <div id="main" tabindex="-1">
36
+ <div id="header">
37
+ <div id="menu">
38
+
39
+ <a href="_index.html">Index</a> &raquo;
40
+
41
+
42
+ <span class="title">Top Level Namespace</span>
43
+
44
+ </div>
45
+
46
+ <div id="search">
47
+
48
+ <a class="full_list_link" id="class_list_link"
49
+ href="class_list.html">
50
+
51
+ <svg width="24" height="24">
52
+ <rect x="0" y="4" width="24" height="4" rx="1" ry="1"></rect>
53
+ <rect x="0" y="12" width="24" height="4" rx="1" ry="1"></rect>
54
+ <rect x="0" y="20" width="24" height="4" rx="1" ry="1"></rect>
55
+ </svg>
56
+ </a>
57
+
58
+ </div>
59
+ <div class="clear"></div>
60
+ </div>
61
+
62
+ <div id="content"><h1>Top Level Namespace
63
+
64
+
65
+
66
+ </h1>
67
+ <div class="box_info">
68
+
69
+
70
+
71
+
72
+
73
+
74
+
75
+
76
+
77
+
78
+
79
+ </div>
80
+
81
+ <h2>Defined Under Namespace</h2>
82
+ <p class="children">
83
+
84
+
85
+ <strong class="modules">Modules:</strong> <span class='object_link'><a href="Version.html" title="Version (module)">Version</a></span>
86
+
87
+
88
+
89
+ <strong class="classes">Classes:</strong> <span class='object_link'><a href="BigIPCookie.html" title="BigIPCookie (class)">BigIPCookie</a></span>
90
+
91
+
92
+ </p>
93
+
94
+
95
+
96
+
97
+
98
+
99
+
100
+
101
+
102
+ </div>
103
+
104
+ <div id="footer">
105
+ Generated on Fri Jul 26 19:42:16 2019 by
106
+ <a href="http://yardoc.org" title="Yay! A Ruby Documentation Tool" target="_parent">yard</a>
107
+ 0.9.20 (ruby-2.6.2).
108
+ </div>
109
+
110
+ </div>
111
+ </body>
112
+ </html>
@@ -0,0 +1,5 @@
1
+ # frozen_string_literal: true
2
+
3
+ module Version
4
+ VERSION = '0.0.1'
5
+ end
@@ -0,0 +1,246 @@
1
+ # frozen_string_literal: true
2
+
3
+ # Ruby internal
4
+ require 'ipaddr'
5
+ # Project internal
6
+ require 'bigipcookie/version'
7
+
8
+ # The global BigIP cookie class
9
+ class BigIPCookie
10
+ # Load constant
11
+ include Version
12
+
13
+ # The class to decode BigIP cookies
14
+ # @example
15
+ # bip = BigIPCookie::Decode.new(
16
+ # 'CustomeCookieName=vi20010112000000000000000000000030.20480'
17
+ # )
18
+ # bip.auto_decode(ipv6compression: 0)
19
+ # bip.decoded_cookie
20
+ # bip.pool_name
21
+ # bip.cookie_type
22
+ class Decode
23
+ # @return [String] the raw cookie (as provided)
24
+ # @example
25
+ # 'BIGipServer~SuperPool=rd3o20010112000000000000000000000030o80'
26
+ attr_reader :raw_cookie
27
+
28
+ # @return [String] the pool name
29
+ attr_reader :pool_name
30
+
31
+ # @return [String] the decoded cookie value
32
+ # @example
33
+ # '[2001:112::30%3]:80'
34
+ attr_reader :decoded_cookie
35
+
36
+ # @return [String] the type of the cookie
37
+ # @example
38
+ # 'IPv6 pool members in non-default route domains'
39
+ attr_reader :cookie_type
40
+
41
+ # A new instance of cookie
42
+ # @param cookie [String] the raw cookie, either key/value or only the value
43
+ def initialize(cookie)
44
+ @raw_cookie = cookie
45
+ @pool_name = nil
46
+ @decoded_cookie = nil
47
+ @cookie_type = nil
48
+ end
49
+
50
+ # Decode IP address
51
+ # @!visibility public
52
+ # @param ip [String] the encoded IP address
53
+ # @param opts [Hash] options for the decoding process (only
54
+ # :ipv6compression should be used, others are for developers)
55
+ # @option opts [Integer] :default default behavior, default value is 1, if
56
+ # value is set to 0 it disables :ip2hex and :reverse
57
+ # @option opts [Integer] :ipversion 4 for IPv4 and 6 for IPv6, default is 4,
58
+ # 4 set :joinchar to '.' and :scanby to 2, 6 set :joinchar to ':' and
59
+ # :scanby to 6
60
+ # @option opts [Integer] :ip2hex encode IP address groups into hexadecimal,
61
+ # default is 1, set to 0 disable
62
+ # @option opts [Integer] :joinchar the character used to join the IP
63
+ # address groups, default is '.' (IPv4), for example it can be set to
64
+ # ':' for IPv6
65
+ # @option opts [Integer] :hex2ip decode hexadecimal IP address groups to
66
+ # decimal, default is 1, set 0 to disable
67
+ # @option opts [Integer] :reverse reverse the IP address groups if set to 1,
68
+ # default is 1
69
+ # @option opts [Integer] :ipv6compression compress IPv6 address if set to 1,
70
+ # default is 1
71
+ # @option opts [Integer] :scanby parse the raw cookie value by n to find IP
72
+ # address groups, default is 2 for IPv4 and 4 for IPv6
73
+ # @return [String] the decoded IP address
74
+ def decode_ip(ip, opts = {})
75
+ opts[:default] ||= 1
76
+ opts[:ipversion] ||= 4
77
+ opts[:ip2hex] ||= 1
78
+ opts[:joinchar] ||= '.'
79
+ opts[:hex2ip] ||= 1
80
+ opts[:reverse] ||= 1
81
+ opts[:ipv6compression] ||= 1
82
+
83
+ if opts[:default].zero?
84
+ opts[:ip2hex] = 0
85
+ opts[:reverse] = 0
86
+ end
87
+
88
+ if opts[:ipversion] == 4
89
+ opts[:joinchar] = '.'
90
+ opts[:scanby] = 2
91
+ elsif opts[:ipversion] == 6
92
+ opts[:joinchar] = ':'
93
+ opts[:scanby] = 4
94
+ end
95
+
96
+ ip = format('%02x', ip) if opts[:ip2hex] == 1 # ip to hex
97
+ ip = ip.scan(/.{#{opts[:scanby]}}/) # split by n
98
+ ip.reverse! if opts[:reverse] == 1 # reverse array
99
+ ip = ip.map { |i| i.to_i(16) } if opts[:hex2ip] == 1 # hex to ip
100
+ ip = ip.join(opts[:joinchar]) # rejoin
101
+ ip = IPAddr.new(ip).to_s if opts[:ipv6compression] == 1 # ipv6 compression
102
+ return ip
103
+ end
104
+
105
+ # Decode the port for IP pool members in default route domains
106
+ # @param port [String] the encoded port
107
+ # @return [String] the decoded decimal port
108
+ def decode_port(port)
109
+ port = format('%02x', port) # port to hex
110
+ port = port.scan(/.{2}/) # split by 2
111
+ port.reverse! # reverse array
112
+ port = port.join # rejoin
113
+ port = port.to_i(16) # hex to port
114
+ return port
115
+ end
116
+
117
+ # Decode cookie value for IPv4 pool members
118
+ # @param cookie [String] raw cookie value
119
+ # @return [String] the decoded cookie value
120
+ def ipv4_pm(cookie)
121
+ ip, port, _reserved = cookie.split('.')
122
+ ip = decode_ip(ip)
123
+ port = decode_port(port)
124
+ return "#{ip}:#{port}"
125
+ end
126
+
127
+ # Decode cookie value for IPv4 pool members in non-default route domains
128
+ # @param cookie [String] raw cookie value
129
+ # @return [String] the decoded cookie value
130
+ def ipv4_pm_ndrd(cookie)
131
+ id, ip, port = cookie.match(
132
+ /rd([0-9]+)o00000000000000000000ffff([0-9a-zA-Z]{8})o([0-9]{1,5})/
133
+ ).captures
134
+ ip = decode_ip(ip, default: 0)
135
+ return "#{ip}%#{id}:#{port}"
136
+ end
137
+
138
+ # Decode cookie value for IPv6 pool members
139
+ # @param cookie [String] raw cookie value
140
+ # @param opts [Hahs] see {decode_ip}
141
+ # @return [String] the decoded cookie value
142
+ def ipv6_pm(cookie, opts = {})
143
+ opts[:default] = 0
144
+ opts[:ipversion] = 6
145
+ opts[:hex2ip] = 0
146
+ ip, port = cookie.match(/vi([0-9a-zA-Z]+).([0-9]+)/).captures
147
+ ip = decode_ip(ip, opts)
148
+ port = decode_port(port)
149
+ return "[#{ip}]:#{port}"
150
+ end
151
+
152
+ # Decode cookie value for IPv6 pool members in non-default route domains
153
+ # @param cookie [String] raw cookie value
154
+ # @param opts [Hahs] see {decode_ip}
155
+ # @return [String] the decoded cookie value
156
+ def ipv6_pm_ndrd(cookie, opts = {})
157
+ opts[:default] = 0
158
+ opts[:ipversion] = 6
159
+ opts[:hex2ip] = 0
160
+ id, ip, port = cookie.match(
161
+ /rd([0-9]+)o([0-9a-zA-Z]{32})o([0-9]{1,5})/
162
+ ).captures
163
+ ip = decode_ip(ip, opts)
164
+ return "[#{ip}%#{id}]:#{port}"
165
+ end
166
+
167
+ # Automatically detect the BigIP cookie type
168
+ # @param cookie [String] raw cookie value
169
+ # @return [Integer] detected cookie code (mapped with {decode_cookie})
170
+ def detect_cookie_type(cookie)
171
+ ## IPv4 pool members
172
+ return 400 if /[0-9]{10}\.[0-9]{5}\.0000/.match?(cookie)
173
+
174
+ ## IPv4 pool members in non-default route domains
175
+ return 401 if /rd([0-9]+)o00000000000000000000ffff([0-9a-zA-Z]{8})o
176
+ ([0-9]{1,5})/x.match?(cookie)
177
+
178
+ ## IPv6 pool members
179
+ return 600 if /vi([0-9a-zA-Z]+).([0-9]+)/.match?(cookie)
180
+
181
+ ## IPv6 pool members in non-default route domains
182
+ return 601 if /rd([0-9]+)o([0-9a-zA-Z]{32})o([0-9]{1,5})/.match?(cookie)
183
+
184
+ raise 'Unrecognized cookie'
185
+ end
186
+
187
+ # Decode the cookie value automatically
188
+ # @param cookie [String] raw cookie value
189
+ # @param opts [Hahs] see {decode_ip}
190
+ # @return [String] the decoded cookie value
191
+ def decode_cookie(cookie, opts = {})
192
+ number = detect_cookie_type(cookie)
193
+ if number == 400
194
+ @cookie_type = 'IPv4 pool members'
195
+ ipv4_pm(cookie)
196
+ elsif number == 401
197
+ @cookie_type = 'IPv4 pool members in non-default route domains'
198
+ ipv4_pm_ndrd(cookie)
199
+ elsif number == 600
200
+ @cookie_type = 'IPv6 pool members'
201
+ ipv6_pm(cookie, opts)
202
+ elsif number == 601
203
+ @cookie_type = 'IPv6 pool members in non-default route domains'
204
+ ipv6_pm_ndrd(cookie, opts)
205
+ else
206
+ raise "Wrong cookie type numer: #{number}"
207
+ end
208
+ end
209
+
210
+ # Get pool name for default cookie name, it can't be called if a default
211
+ # cookie name is used or if no cookie key was provided
212
+ # @return the pool name
213
+ def retrieve_pool_name
214
+ pool_name = /BIGipServer(.+)=.+/.match(@raw_cookie).captures[0]
215
+ return pool_name
216
+ end
217
+
218
+ # Automatically decode the raw cookie, detects if there is a cookie key
219
+ # (custom or default) or only the value
220
+ # @param opts [Hahs] see {decode_ip}
221
+ # @note
222
+ # .yardopts-dev must be used to get {decode_ip} documentation
223
+ def auto_decode(opts = {})
224
+ if /\=/.match?(@raw_cookie) # if there is a key
225
+ if /^BIGipServer/.match?(@raw_cookie) # if default cookie name
226
+ pool_name = retrieve_pool_name
227
+ cookie_value = /^BIGipServer.+=(.+)/.match(@raw_cookie).captures[0]
228
+ decoded_cookie = decode_cookie(cookie_value, opts)
229
+ @pool_name = pool_name
230
+ else # custom cookie name
231
+ cookie_value = /.+=(.+)/.match(@raw_cookie).captures[0]
232
+ decoded_cookie = decode_cookie(cookie_value, opts)
233
+ @pool_name = 'unknown'
234
+ end
235
+ else # cookie value only
236
+ decoded_cookie = decode_cookie(@raw_cookie, opts)
237
+ @pool_name = 'unknown'
238
+ end
239
+ @decoded_cookie = decoded_cookie
240
+ end
241
+
242
+ private :retrieve_pool_name, :decode_cookie, :detect_cookie_type,
243
+ :ipv6_pm_ndrd, :ipv6_pm, :ipv4_pm_ndrd, :ipv4_pm, :decode_port,
244
+ :decode_ip
245
+ end
246
+ end
data/package-lock.json ADDED
@@ -0,0 +1,154 @@
1
+ {
2
+ "requires": true,
3
+ "lockfileVersion": 1,
4
+ "dependencies": {
5
+ "babel-helper-vue-jsx-merge-props": {
6
+ "version": "2.0.3",
7
+ "resolved": "https://registry.npmjs.org/babel-helper-vue-jsx-merge-props/-/babel-helper-vue-jsx-merge-props-2.0.3.tgz",
8
+ "integrity": "sha512-gsLiKK7Qrb7zYJNgiXKpXblxbV5ffSwR0f5whkPAaBAR4fhi6bwRZxX9wBlIc5M/v8CCkXUbXZL4N/nSE97cqg=="
9
+ },
10
+ "clipboard": {
11
+ "version": "2.0.4",
12
+ "resolved": "https://registry.npmjs.org/clipboard/-/clipboard-2.0.4.tgz",
13
+ "integrity": "sha512-Vw26VSLRpJfBofiVaFb/I8PVfdI1OxKcYShe6fm0sP/DtmiWQNCjhM/okTvdCo0G+lMMm1rMYbk4IK4x1X+kgQ==",
14
+ "optional": true,
15
+ "requires": {
16
+ "good-listener": "^1.2.2",
17
+ "select": "^1.1.2",
18
+ "tiny-emitter": "^2.0.0"
19
+ }
20
+ },
21
+ "de-indent": {
22
+ "version": "1.0.2",
23
+ "resolved": "https://registry.npmjs.org/de-indent/-/de-indent-1.0.2.tgz",
24
+ "integrity": "sha1-sgOOhG3DO6pXlhKNCAS0VbjB4h0="
25
+ },
26
+ "delegate": {
27
+ "version": "3.2.0",
28
+ "resolved": "https://registry.npmjs.org/delegate/-/delegate-3.2.0.tgz",
29
+ "integrity": "sha512-IofjkYBZaZivn0V8nnsMJGBr4jVLxHDheKSW88PyxS5QC4Vo9ZbZVvhzlSxY87fVq3STR6r+4cGepyHkcWOQSw==",
30
+ "optional": true
31
+ },
32
+ "docute": {
33
+ "version": "4.21.2",
34
+ "resolved": "https://registry.npmjs.org/docute/-/docute-4.21.2.tgz",
35
+ "integrity": "sha512-wdPKSEHLkb51ubf73/t/rzN9ePp5Oa0KaFU/SYkYxqZ5+svpzlt2S+dz6hoyzqrT428azygRed3hbhgZlcs6wQ==",
36
+ "requires": {
37
+ "jump.js": "^1.0.2",
38
+ "loadjs": "^3.5.4",
39
+ "marked": "^0.6.1",
40
+ "medium-zoom": "^1.0.2",
41
+ "prismjs": "^1.15.0",
42
+ "throttle-debounce": "^2.1.0",
43
+ "vue": "^2.6.10",
44
+ "vue-content-loader": "^0.2.1",
45
+ "vue-router": "^3.0.1",
46
+ "vue-router-prefetch": "^1.1.1",
47
+ "vue-template-compiler": "^2.6.10",
48
+ "vuex": "^3.0.1",
49
+ "vuex-router-sync": "^5.0.0"
50
+ }
51
+ },
52
+ "good-listener": {
53
+ "version": "1.2.2",
54
+ "resolved": "https://registry.npmjs.org/good-listener/-/good-listener-1.2.2.tgz",
55
+ "integrity": "sha1-1TswzfkxPf+33JoNR3CWqm0UXFA=",
56
+ "optional": true,
57
+ "requires": {
58
+ "delegate": "^3.1.2"
59
+ }
60
+ },
61
+ "he": {
62
+ "version": "1.2.0",
63
+ "resolved": "https://registry.npmjs.org/he/-/he-1.2.0.tgz",
64
+ "integrity": "sha512-F/1DnUGPopORZi0ni+CvrCgHQ5FyEAHRLSApuYWMmrbSwoN2Mn/7k+Gl38gJnR7yyDZk6WLXwiGod1JOWNDKGw=="
65
+ },
66
+ "jump.js": {
67
+ "version": "1.0.2",
68
+ "resolved": "https://registry.npmjs.org/jump.js/-/jump.js-1.0.2.tgz",
69
+ "integrity": "sha1-4GQbR/QKOPITnCX9oFAL8o5DAVo="
70
+ },
71
+ "loadjs": {
72
+ "version": "3.6.1",
73
+ "resolved": "https://registry.npmjs.org/loadjs/-/loadjs-3.6.1.tgz",
74
+ "integrity": "sha512-AZEBw2GWdJk2IzBgQ+Wohoao5j+t0rajqK8dJu8jQqgYxDTxhmCt0ayMo/vCa0ZAMvZxnJcam6uLICfnVd8KAw=="
75
+ },
76
+ "marked": {
77
+ "version": "0.6.3",
78
+ "resolved": "https://registry.npmjs.org/marked/-/marked-0.6.3.tgz",
79
+ "integrity": "sha512-Fqa7eq+UaxfMriqzYLayfqAE40WN03jf+zHjT18/uXNuzjq3TY0XTbrAoPeqSJrAmPz11VuUA+kBPYOhHt9oOQ=="
80
+ },
81
+ "medium-zoom": {
82
+ "version": "1.0.4",
83
+ "resolved": "https://registry.npmjs.org/medium-zoom/-/medium-zoom-1.0.4.tgz",
84
+ "integrity": "sha512-BjE+00gQku3XQfgHDcqyYwQaBtFddzh6Lnj1RZOliqJ9HS0mh/P2IaqVJ25/j9EbnjAUf27mLeLZBRxnd00bfA=="
85
+ },
86
+ "prismjs": {
87
+ "version": "1.17.1",
88
+ "resolved": "https://registry.npmjs.org/prismjs/-/prismjs-1.17.1.tgz",
89
+ "integrity": "sha512-PrEDJAFdUGbOP6xK/UsfkC5ghJsPJviKgnQOoxaDbBjwc8op68Quupwt1DeAFoG8GImPhiKXAvvsH7wDSLsu1Q==",
90
+ "requires": {
91
+ "clipboard": "^2.0.0"
92
+ }
93
+ },
94
+ "select": {
95
+ "version": "1.1.2",
96
+ "resolved": "https://registry.npmjs.org/select/-/select-1.1.2.tgz",
97
+ "integrity": "sha1-DnNQrN7ICxEIUoeG7B1EGNEbOW0=",
98
+ "optional": true
99
+ },
100
+ "throttle-debounce": {
101
+ "version": "2.1.0",
102
+ "resolved": "https://registry.npmjs.org/throttle-debounce/-/throttle-debounce-2.1.0.tgz",
103
+ "integrity": "sha512-AOvyNahXQuU7NN+VVvOOX+uW6FPaWdAOdRP5HfwYxAfCzXTFKRMoIMk+n+po318+ktcChx+F1Dd91G3YHeMKyg=="
104
+ },
105
+ "tiny-emitter": {
106
+ "version": "2.1.0",
107
+ "resolved": "https://registry.npmjs.org/tiny-emitter/-/tiny-emitter-2.1.0.tgz",
108
+ "integrity": "sha512-NB6Dk1A9xgQPMoGqC5CVXn123gWyte215ONT5Pp5a0yt4nlEoO1ZWeCwpncaekPHXO60i47ihFnZPiRPjRMq4Q==",
109
+ "optional": true
110
+ },
111
+ "vue": {
112
+ "version": "2.6.10",
113
+ "resolved": "https://registry.npmjs.org/vue/-/vue-2.6.10.tgz",
114
+ "integrity": "sha512-ImThpeNU9HbdZL3utgMCq0oiMzAkt1mcgy3/E6zWC/G6AaQoeuFdsl9nDhTDU3X1R6FK7nsIUuRACVcjI+A2GQ=="
115
+ },
116
+ "vue-content-loader": {
117
+ "version": "0.2.2",
118
+ "resolved": "https://registry.npmjs.org/vue-content-loader/-/vue-content-loader-0.2.2.tgz",
119
+ "integrity": "sha512-8jcb0dJFiVAz7EPwpQjOd/GnswUiSDeKihEABkq/iAYxAI2MHSS7+VWlRblQDH3D1rm3Lewt7fDJoOpJKbYHjw==",
120
+ "requires": {
121
+ "babel-helper-vue-jsx-merge-props": "^2.0.3"
122
+ }
123
+ },
124
+ "vue-router": {
125
+ "version": "3.0.7",
126
+ "resolved": "https://registry.npmjs.org/vue-router/-/vue-router-3.0.7.tgz",
127
+ "integrity": "sha512-utJ+QR3YlIC/6x6xq17UMXeAfxEvXA0VKD3PiSio7hBOZNusA1jXcbxZxVEfJunLp48oonjTepY8ORoIlRx/EQ=="
128
+ },
129
+ "vue-router-prefetch": {
130
+ "version": "1.6.0",
131
+ "resolved": "https://registry.npmjs.org/vue-router-prefetch/-/vue-router-prefetch-1.6.0.tgz",
132
+ "integrity": "sha512-mLoh5on0GlO3ag0GWt+J8FkcalSAZJGJ/dNpA8PQ8X7pAoFht683FOJZlqdV7vXwKH7BjP+UfKcK09tHtNeDbw=="
133
+ },
134
+ "vue-template-compiler": {
135
+ "version": "2.6.10",
136
+ "resolved": "https://registry.npmjs.org/vue-template-compiler/-/vue-template-compiler-2.6.10.tgz",
137
+ "integrity": "sha512-jVZkw4/I/HT5ZMvRnhv78okGusqe0+qH2A0Em0Cp8aq78+NK9TII263CDVz2QXZsIT+yyV/gZc/j/vlwa+Epyg==",
138
+ "requires": {
139
+ "de-indent": "^1.0.2",
140
+ "he": "^1.1.0"
141
+ }
142
+ },
143
+ "vuex": {
144
+ "version": "3.1.1",
145
+ "resolved": "https://registry.npmjs.org/vuex/-/vuex-3.1.1.tgz",
146
+ "integrity": "sha512-ER5moSbLZuNSMBFnEBVGhQ1uCBNJslH9W/Dw2W7GZN23UQA69uapP5GTT9Vm8Trc0PzBSVt6LzF3hGjmv41xcg=="
147
+ },
148
+ "vuex-router-sync": {
149
+ "version": "5.0.0",
150
+ "resolved": "https://registry.npmjs.org/vuex-router-sync/-/vuex-router-sync-5.0.0.tgz",
151
+ "integrity": "sha512-Mry2sO4kiAG64714X1CFpTA/shUH1DmkZ26DFDtwoM/yyx6OtMrc+MxrU+7vvbNLO9LSpgwkiJ8W+rlmRtsM+w=="
152
+ }
153
+ }
154
+ }
@@ -0,0 +1,54 @@
1
+ # frozen_string_literal: true
2
+
3
+ require 'minitest/autorun'
4
+ require 'bigipcookie'
5
+
6
+ class BigIPCookieTest < Minitest::Test
7
+ # IPv4 pool members, with pool name
8
+ def test_bigipcookie_decode_ipv4_pm
9
+ bip = BigIPCookie::Decode.new('BIGipServer<pool_name>=1677787402.36895.0000')
10
+ bip.auto_decode
11
+ # Decoded cookie
12
+ assert_equal('10.1.1.100:8080', bip.decoded_cookie)
13
+ # Pool name
14
+ assert_equal('<pool_name>', bip.pool_name)
15
+ # Cookie type
16
+ assert_equal('IPv4 pool members', bip.cookie_type)
17
+ end
18
+
19
+ # IPv4 pool members in non-default route domains, only cookie value
20
+ def test_bigipcookie_decode_ipv4_pm_ndrd
21
+ bip = BigIPCookie::Decode.new('rd5o00000000000000000000ffffc0000201o80')
22
+ bip.auto_decode
23
+ # Decoded cookie
24
+ assert_equal('192.0.2.1%5:80', bip.decoded_cookie)
25
+ # Pool name
26
+ assert_equal('unknown', bip.pool_name)
27
+ # Cookie type
28
+ assert_equal('IPv4 pool members in non-default route domains', bip.cookie_type)
29
+ end
30
+
31
+ # IPv6 pool members, custom cookie name, long ipv6 format
32
+ def test_bigipcookie_decode_ipv6_pm
33
+ bip = BigIPCookie::Decode.new('CustomeCookieName=vi20010112000000000000000000000030.20480')
34
+ bip.auto_decode(ipv6compression: 0)
35
+ # Decoded cookie
36
+ assert_equal('[2001:0112:0000:0000:0000:0000:0000:0030]:80', bip.decoded_cookie)
37
+ # Pool name
38
+ assert_equal('unknown', bip.pool_name)
39
+ # Cookie type
40
+ assert_equal('IPv6 pool members', bip.cookie_type)
41
+ end
42
+
43
+ # IPv6 pool members in non-default route domains
44
+ def test_bigipcookie_decode_ipv6_pm_ndrd
45
+ bip = BigIPCookie::Decode.new('BIGipServer~SuperPool=rd3o20010112000000000000000000000030o80')
46
+ bip.auto_decode
47
+ # Decoded cookie
48
+ assert_equal('[2001:112::30%3]:80', bip.decoded_cookie)
49
+ # Pool name
50
+ assert_equal('~SuperPool', bip.pool_name)
51
+ # Cookie type
52
+ assert_equal('IPv6 pool members in non-default route domains', bip.cookie_type)
53
+ end
54
+ end