freezerwatch 0.1.0

Sign up to get free protection for your applications and to get access to all the features.
Files changed (314) hide show
  1. checksums.yaml +7 -0
  2. data/.gitignore +10 -0
  3. data/CODE_OF_CONDUCT.md +13 -0
  4. data/Gemfile +4 -0
  5. data/LICENSE.txt +21 -0
  6. data/README.md +40 -0
  7. data/Rakefile +1 -0
  8. data/bin/console +14 -0
  9. data/bin/freezerwatch +9 -0
  10. data/bin/setup +7 -0
  11. data/freezerwatch.gemspec +23 -0
  12. data/lib/freezerwatch.rb +5 -0
  13. data/lib/freezerwatch/version.rb +3 -0
  14. data/node_modules/.bin/freezerwatch +139 -0
  15. data/node_modules/freezerwatch/.npmignore +3 -0
  16. data/node_modules/freezerwatch/.ruby-version +1 -0
  17. data/node_modules/freezerwatch/Gemfile +4 -0
  18. data/node_modules/freezerwatch/Gemfile.lock +79 -0
  19. data/node_modules/freezerwatch/LICENSE +23 -0
  20. data/node_modules/freezerwatch/README.md +41 -0
  21. data/node_modules/freezerwatch/Rakefile +13 -0
  22. data/node_modules/freezerwatch/freezerwatch.js +139 -0
  23. data/node_modules/freezerwatch/metrics/bigfiles_high_water_mark +1 -0
  24. data/node_modules/freezerwatch/metrics/cane_high_water_mark +1 -0
  25. data/node_modules/freezerwatch/metrics/flay_high_water_mark +1 -0
  26. data/node_modules/freezerwatch/metrics/flog_high_water_mark +1 -0
  27. data/node_modules/freezerwatch/metrics/punchlist_high_water_mark +2 -0
  28. data/node_modules/freezerwatch/metrics/reek_high_water_mark +1 -0
  29. data/node_modules/freezerwatch/metrics/rubocop_high_water_mark +1 -0
  30. data/node_modules/freezerwatch/node_modules/async/.jshintrc +25 -0
  31. data/node_modules/freezerwatch/node_modules/async/.travis.yml +6 -0
  32. data/node_modules/freezerwatch/node_modules/async/CHANGELOG.md +65 -0
  33. data/node_modules/freezerwatch/node_modules/async/LICENSE +19 -0
  34. data/node_modules/freezerwatch/node_modules/async/README.md +1803 -0
  35. data/node_modules/freezerwatch/node_modules/async/bower.json +43 -0
  36. data/node_modules/freezerwatch/node_modules/async/component.json +17 -0
  37. data/node_modules/freezerwatch/node_modules/async/coverage/base.css +182 -0
  38. data/node_modules/freezerwatch/node_modules/async/coverage/index.html +73 -0
  39. data/node_modules/freezerwatch/node_modules/async/coverage/lcov-report/base.css +182 -0
  40. data/node_modules/freezerwatch/node_modules/async/coverage/lcov-report/index.html +73 -0
  41. data/node_modules/freezerwatch/node_modules/async/coverage/lcov-report/lib/async.js.html +3900 -0
  42. data/node_modules/freezerwatch/node_modules/async/coverage/lcov-report/lib/index.html +73 -0
  43. data/node_modules/freezerwatch/node_modules/async/coverage/lcov-report/prettify.css +1 -0
  44. data/node_modules/freezerwatch/node_modules/async/coverage/lcov-report/prettify.js +1 -0
  45. data/node_modules/freezerwatch/node_modules/async/coverage/lcov-report/sort-arrow-sprite.png +0 -0
  46. data/node_modules/freezerwatch/node_modules/async/coverage/lcov-report/sorter.js +156 -0
  47. data/node_modules/freezerwatch/node_modules/async/coverage/lcov.info +1452 -0
  48. data/node_modules/freezerwatch/node_modules/async/coverage/lib/async.js.html +3597 -0
  49. data/node_modules/freezerwatch/node_modules/async/coverage/lib/index.html +73 -0
  50. data/node_modules/freezerwatch/node_modules/async/coverage/prettify.css +1 -0
  51. data/node_modules/freezerwatch/node_modules/async/coverage/prettify.js +1 -0
  52. data/node_modules/freezerwatch/node_modules/async/coverage/sort-arrow-sprite.png +0 -0
  53. data/node_modules/freezerwatch/node_modules/async/coverage/sorter.js +156 -0
  54. data/node_modules/freezerwatch/node_modules/async/lib/async.js +1191 -0
  55. data/node_modules/freezerwatch/node_modules/async/nyc_output/5074.json +1 -0
  56. data/node_modules/freezerwatch/node_modules/async/package.json +96 -0
  57. data/node_modules/freezerwatch/node_modules/async/support/sync-package-managers.js +53 -0
  58. data/node_modules/freezerwatch/node_modules/lacrosse/.npmignore +15 -0
  59. data/node_modules/freezerwatch/node_modules/lacrosse/Client.js +60 -0
  60. data/node_modules/freezerwatch/node_modules/lacrosse/Device.js +38 -0
  61. data/node_modules/freezerwatch/node_modules/lacrosse/DeviceRawReadStream.js +36 -0
  62. data/node_modules/freezerwatch/node_modules/lacrosse/DeviceSingleRawReadStream.js +29 -0
  63. data/node_modules/freezerwatch/node_modules/lacrosse/DeviceStream.js +35 -0
  64. data/node_modules/freezerwatch/node_modules/lacrosse/LICENSE +23 -0
  65. data/node_modules/freezerwatch/node_modules/lacrosse/README.md +25 -0
  66. data/node_modules/freezerwatch/node_modules/lacrosse/index.js +1 -0
  67. data/node_modules/freezerwatch/node_modules/lacrosse/node_modules/request/.npmignore +2 -0
  68. data/node_modules/freezerwatch/node_modules/lacrosse/node_modules/request/.travis.yml +12 -0
  69. data/node_modules/freezerwatch/node_modules/lacrosse/node_modules/request/LICENSE +55 -0
  70. data/node_modules/freezerwatch/node_modules/lacrosse/node_modules/request/README.md +364 -0
  71. data/node_modules/freezerwatch/node_modules/lacrosse/node_modules/request/index.js +156 -0
  72. data/node_modules/freezerwatch/node_modules/lacrosse/node_modules/request/lib/copy.js +8 -0
  73. data/node_modules/freezerwatch/node_modules/lacrosse/node_modules/request/lib/debug.js +7 -0
  74. data/node_modules/freezerwatch/node_modules/lacrosse/node_modules/request/lib/getSafe.js +34 -0
  75. data/node_modules/freezerwatch/node_modules/lacrosse/node_modules/request/lib/optional.js +5 -0
  76. data/node_modules/freezerwatch/node_modules/lacrosse/node_modules/request/node_modules/.bin/uuid +26 -0
  77. data/node_modules/freezerwatch/node_modules/lacrosse/node_modules/request/node_modules/aws-sign2/LICENSE +55 -0
  78. data/node_modules/freezerwatch/node_modules/lacrosse/node_modules/request/node_modules/aws-sign2/README.md +4 -0
  79. data/node_modules/freezerwatch/node_modules/lacrosse/node_modules/request/node_modules/aws-sign2/index.js +202 -0
  80. data/node_modules/freezerwatch/node_modules/lacrosse/node_modules/request/node_modules/aws-sign2/package.json +46 -0
  81. data/node_modules/freezerwatch/node_modules/lacrosse/node_modules/request/node_modules/forever-agent/LICENSE +55 -0
  82. data/node_modules/freezerwatch/node_modules/lacrosse/node_modules/request/node_modules/forever-agent/README.md +4 -0
  83. data/node_modules/freezerwatch/node_modules/lacrosse/node_modules/request/node_modules/forever-agent/index.js +119 -0
  84. data/node_modules/freezerwatch/node_modules/lacrosse/node_modules/request/node_modules/forever-agent/package.json +45 -0
  85. data/node_modules/freezerwatch/node_modules/lacrosse/node_modules/request/node_modules/form-data/License +19 -0
  86. data/node_modules/freezerwatch/node_modules/lacrosse/node_modules/request/node_modules/form-data/Readme.md +175 -0
  87. data/node_modules/freezerwatch/node_modules/lacrosse/node_modules/request/node_modules/form-data/lib/form_data.js +351 -0
  88. data/node_modules/freezerwatch/node_modules/lacrosse/node_modules/request/node_modules/form-data/node_modules/async/.travis.yml +5 -0
  89. data/node_modules/freezerwatch/node_modules/lacrosse/node_modules/request/node_modules/form-data/node_modules/async/LICENSE +19 -0
  90. data/node_modules/freezerwatch/node_modules/lacrosse/node_modules/request/node_modules/form-data/node_modules/async/README.md +1647 -0
  91. data/node_modules/freezerwatch/node_modules/lacrosse/node_modules/request/node_modules/form-data/node_modules/async/bower.json +38 -0
  92. data/node_modules/freezerwatch/node_modules/lacrosse/node_modules/request/node_modules/form-data/node_modules/async/component.json +16 -0
  93. data/node_modules/freezerwatch/node_modules/lacrosse/node_modules/request/node_modules/form-data/node_modules/async/lib/async.js +1123 -0
  94. data/node_modules/freezerwatch/node_modules/lacrosse/node_modules/request/node_modules/form-data/node_modules/async/package.json +84 -0
  95. data/node_modules/freezerwatch/node_modules/lacrosse/node_modules/request/node_modules/form-data/node_modules/async/support/sync-package-managers.js +53 -0
  96. data/node_modules/freezerwatch/node_modules/lacrosse/node_modules/request/node_modules/form-data/node_modules/combined-stream/License +19 -0
  97. data/node_modules/freezerwatch/node_modules/lacrosse/node_modules/request/node_modules/form-data/node_modules/combined-stream/Readme.md +132 -0
  98. data/node_modules/freezerwatch/node_modules/lacrosse/node_modules/request/node_modules/form-data/node_modules/combined-stream/lib/combined_stream.js +188 -0
  99. data/node_modules/freezerwatch/node_modules/lacrosse/node_modules/request/node_modules/form-data/node_modules/combined-stream/node_modules/delayed-stream/.npmignore +2 -0
  100. data/node_modules/freezerwatch/node_modules/lacrosse/node_modules/request/node_modules/form-data/node_modules/combined-stream/node_modules/delayed-stream/License +19 -0
  101. data/node_modules/freezerwatch/node_modules/lacrosse/node_modules/request/node_modules/form-data/node_modules/combined-stream/node_modules/delayed-stream/Makefile +7 -0
  102. data/node_modules/freezerwatch/node_modules/lacrosse/node_modules/request/node_modules/form-data/node_modules/combined-stream/node_modules/delayed-stream/Readme.md +154 -0
  103. data/node_modules/freezerwatch/node_modules/lacrosse/node_modules/request/node_modules/form-data/node_modules/combined-stream/node_modules/delayed-stream/lib/delayed_stream.js +99 -0
  104. data/node_modules/freezerwatch/node_modules/lacrosse/node_modules/request/node_modules/form-data/node_modules/combined-stream/node_modules/delayed-stream/package.json +42 -0
  105. data/node_modules/freezerwatch/node_modules/lacrosse/node_modules/request/node_modules/form-data/node_modules/combined-stream/node_modules/delayed-stream/test/common.js +6 -0
  106. data/node_modules/freezerwatch/node_modules/lacrosse/node_modules/request/node_modules/form-data/node_modules/combined-stream/node_modules/delayed-stream/test/integration/test-delayed-http-upload.js +38 -0
  107. data/node_modules/freezerwatch/node_modules/lacrosse/node_modules/request/node_modules/form-data/node_modules/combined-stream/node_modules/delayed-stream/test/integration/test-delayed-stream-auto-pause.js +21 -0
  108. data/node_modules/freezerwatch/node_modules/lacrosse/node_modules/request/node_modules/form-data/node_modules/combined-stream/node_modules/delayed-stream/test/integration/test-delayed-stream-pause.js +14 -0
  109. data/node_modules/freezerwatch/node_modules/lacrosse/node_modules/request/node_modules/form-data/node_modules/combined-stream/node_modules/delayed-stream/test/integration/test-delayed-stream.js +48 -0
  110. data/node_modules/freezerwatch/node_modules/lacrosse/node_modules/request/node_modules/form-data/node_modules/combined-stream/node_modules/delayed-stream/test/integration/test-handle-source-errors.js +15 -0
  111. data/node_modules/freezerwatch/node_modules/lacrosse/node_modules/request/node_modules/form-data/node_modules/combined-stream/node_modules/delayed-stream/test/integration/test-max-data-size.js +18 -0
  112. data/node_modules/freezerwatch/node_modules/lacrosse/node_modules/request/node_modules/form-data/node_modules/combined-stream/node_modules/delayed-stream/test/integration/test-pipe-resumes.js +13 -0
  113. data/node_modules/freezerwatch/node_modules/lacrosse/node_modules/request/node_modules/form-data/node_modules/combined-stream/node_modules/delayed-stream/test/integration/test-proxy-readable.js +13 -0
  114. data/node_modules/freezerwatch/node_modules/lacrosse/node_modules/request/node_modules/form-data/node_modules/combined-stream/node_modules/delayed-stream/test/run.js +7 -0
  115. data/node_modules/freezerwatch/node_modules/lacrosse/node_modules/request/node_modules/form-data/node_modules/combined-stream/package.json +60 -0
  116. data/node_modules/freezerwatch/node_modules/lacrosse/node_modules/request/node_modules/form-data/package.json +80 -0
  117. data/node_modules/freezerwatch/node_modules/lacrosse/node_modules/request/node_modules/hawk/.npmignore +18 -0
  118. data/node_modules/freezerwatch/node_modules/lacrosse/node_modules/request/node_modules/hawk/.travis.yml +5 -0
  119. data/node_modules/freezerwatch/node_modules/lacrosse/node_modules/request/node_modules/hawk/LICENSE +24 -0
  120. data/node_modules/freezerwatch/node_modules/lacrosse/node_modules/request/node_modules/hawk/Makefile +10 -0
  121. data/node_modules/freezerwatch/node_modules/lacrosse/node_modules/request/node_modules/hawk/README.md +627 -0
  122. data/node_modules/freezerwatch/node_modules/lacrosse/node_modules/request/node_modules/hawk/example/usage.js +78 -0
  123. data/node_modules/freezerwatch/node_modules/lacrosse/node_modules/request/node_modules/hawk/images/hawk.png +0 -0
  124. data/node_modules/freezerwatch/node_modules/lacrosse/node_modules/request/node_modules/hawk/images/logo.png +0 -0
  125. data/node_modules/freezerwatch/node_modules/lacrosse/node_modules/request/node_modules/hawk/index.js +1 -0
  126. data/node_modules/freezerwatch/node_modules/lacrosse/node_modules/request/node_modules/hawk/lib/browser.js +485 -0
  127. data/node_modules/freezerwatch/node_modules/lacrosse/node_modules/request/node_modules/hawk/lib/client.js +367 -0
  128. data/node_modules/freezerwatch/node_modules/lacrosse/node_modules/request/node_modules/hawk/lib/crypto.js +111 -0
  129. data/node_modules/freezerwatch/node_modules/lacrosse/node_modules/request/node_modules/hawk/lib/index.js +15 -0
  130. data/node_modules/freezerwatch/node_modules/lacrosse/node_modules/request/node_modules/hawk/lib/server.js +524 -0
  131. data/node_modules/freezerwatch/node_modules/lacrosse/node_modules/request/node_modules/hawk/lib/utils.js +183 -0
  132. data/node_modules/freezerwatch/node_modules/lacrosse/node_modules/request/node_modules/hawk/node_modules/boom/.npmignore +18 -0
  133. data/node_modules/freezerwatch/node_modules/lacrosse/node_modules/request/node_modules/hawk/node_modules/boom/.travis.yml +5 -0
  134. data/node_modules/freezerwatch/node_modules/lacrosse/node_modules/request/node_modules/hawk/node_modules/boom/LICENSE +24 -0
  135. data/node_modules/freezerwatch/node_modules/lacrosse/node_modules/request/node_modules/hawk/node_modules/boom/Makefile +11 -0
  136. data/node_modules/freezerwatch/node_modules/lacrosse/node_modules/request/node_modules/hawk/node_modules/boom/README.md +6 -0
  137. data/node_modules/freezerwatch/node_modules/lacrosse/node_modules/request/node_modules/hawk/node_modules/boom/images/boom.png +0 -0
  138. data/node_modules/freezerwatch/node_modules/lacrosse/node_modules/request/node_modules/hawk/node_modules/boom/index.js +1 -0
  139. data/node_modules/freezerwatch/node_modules/lacrosse/node_modules/request/node_modules/hawk/node_modules/boom/lib/index.js +207 -0
  140. data/node_modules/freezerwatch/node_modules/lacrosse/node_modules/request/node_modules/hawk/node_modules/boom/package.json +64 -0
  141. data/node_modules/freezerwatch/node_modules/lacrosse/node_modules/request/node_modules/hawk/node_modules/boom/test/index.js +245 -0
  142. data/node_modules/freezerwatch/node_modules/lacrosse/node_modules/request/node_modules/hawk/node_modules/cryptiles/.npmignore +18 -0
  143. data/node_modules/freezerwatch/node_modules/lacrosse/node_modules/request/node_modules/hawk/node_modules/cryptiles/.travis.yml +5 -0
  144. data/node_modules/freezerwatch/node_modules/lacrosse/node_modules/request/node_modules/hawk/node_modules/cryptiles/LICENSE +24 -0
  145. data/node_modules/freezerwatch/node_modules/lacrosse/node_modules/request/node_modules/hawk/node_modules/cryptiles/Makefile +11 -0
  146. data/node_modules/freezerwatch/node_modules/lacrosse/node_modules/request/node_modules/hawk/node_modules/cryptiles/README.md +6 -0
  147. data/node_modules/freezerwatch/node_modules/lacrosse/node_modules/request/node_modules/hawk/node_modules/cryptiles/index.js +1 -0
  148. data/node_modules/freezerwatch/node_modules/lacrosse/node_modules/request/node_modules/hawk/node_modules/cryptiles/lib/index.js +68 -0
  149. data/node_modules/freezerwatch/node_modules/lacrosse/node_modules/request/node_modules/hawk/node_modules/cryptiles/package.json +65 -0
  150. data/node_modules/freezerwatch/node_modules/lacrosse/node_modules/request/node_modules/hawk/node_modules/cryptiles/test/index.js +101 -0
  151. data/node_modules/freezerwatch/node_modules/lacrosse/node_modules/request/node_modules/hawk/node_modules/hoek/.npmignore +18 -0
  152. data/node_modules/freezerwatch/node_modules/lacrosse/node_modules/request/node_modules/hawk/node_modules/hoek/.travis.yml +5 -0
  153. data/node_modules/freezerwatch/node_modules/lacrosse/node_modules/request/node_modules/hawk/node_modules/hoek/LICENSE +33 -0
  154. data/node_modules/freezerwatch/node_modules/lacrosse/node_modules/request/node_modules/hawk/node_modules/hoek/Makefile +10 -0
  155. data/node_modules/freezerwatch/node_modules/lacrosse/node_modules/request/node_modules/hawk/node_modules/hoek/README.md +436 -0
  156. data/node_modules/freezerwatch/node_modules/lacrosse/node_modules/request/node_modules/hawk/node_modules/hoek/images/hoek.png +0 -0
  157. data/node_modules/freezerwatch/node_modules/lacrosse/node_modules/request/node_modules/hawk/node_modules/hoek/index.js +1 -0
  158. data/node_modules/freezerwatch/node_modules/lacrosse/node_modules/request/node_modules/hawk/node_modules/hoek/lib/escape.js +132 -0
  159. data/node_modules/freezerwatch/node_modules/lacrosse/node_modules/request/node_modules/hawk/node_modules/hoek/lib/index.js +585 -0
  160. data/node_modules/freezerwatch/node_modules/lacrosse/node_modules/request/node_modules/hawk/node_modules/hoek/package.json +70 -0
  161. data/node_modules/freezerwatch/node_modules/lacrosse/node_modules/request/node_modules/hawk/node_modules/hoek/test/escaper.js +86 -0
  162. data/node_modules/freezerwatch/node_modules/lacrosse/node_modules/request/node_modules/hawk/node_modules/hoek/test/index.js +1078 -0
  163. data/node_modules/freezerwatch/node_modules/lacrosse/node_modules/request/node_modules/hawk/node_modules/hoek/test/modules/test1.js +1 -0
  164. data/node_modules/freezerwatch/node_modules/lacrosse/node_modules/request/node_modules/hawk/node_modules/hoek/test/modules/test2.js +1 -0
  165. data/node_modules/freezerwatch/node_modules/lacrosse/node_modules/request/node_modules/hawk/node_modules/hoek/test/modules/test3.js +1 -0
  166. data/node_modules/freezerwatch/node_modules/lacrosse/node_modules/request/node_modules/hawk/node_modules/sntp/.npmignore +18 -0
  167. data/node_modules/freezerwatch/node_modules/lacrosse/node_modules/request/node_modules/hawk/node_modules/sntp/.travis.yml +5 -0
  168. data/node_modules/freezerwatch/node_modules/lacrosse/node_modules/request/node_modules/hawk/node_modules/sntp/LICENSE +24 -0
  169. data/node_modules/freezerwatch/node_modules/lacrosse/node_modules/request/node_modules/hawk/node_modules/sntp/Makefile +11 -0
  170. data/node_modules/freezerwatch/node_modules/lacrosse/node_modules/request/node_modules/hawk/node_modules/sntp/README.md +68 -0
  171. data/node_modules/freezerwatch/node_modules/lacrosse/node_modules/request/node_modules/hawk/node_modules/sntp/examples/offset.js +16 -0
  172. data/node_modules/freezerwatch/node_modules/lacrosse/node_modules/request/node_modules/hawk/node_modules/sntp/examples/time.js +25 -0
  173. data/node_modules/freezerwatch/node_modules/lacrosse/node_modules/request/node_modules/hawk/node_modules/sntp/index.js +1 -0
  174. data/node_modules/freezerwatch/node_modules/lacrosse/node_modules/request/node_modules/hawk/node_modules/sntp/lib/index.js +409 -0
  175. data/node_modules/freezerwatch/node_modules/lacrosse/node_modules/request/node_modules/hawk/node_modules/sntp/package.json +65 -0
  176. data/node_modules/freezerwatch/node_modules/lacrosse/node_modules/request/node_modules/hawk/node_modules/sntp/test/index.js +359 -0
  177. data/node_modules/freezerwatch/node_modules/lacrosse/node_modules/request/node_modules/hawk/package.json +70 -0
  178. data/node_modules/freezerwatch/node_modules/lacrosse/node_modules/request/node_modules/hawk/test/browser.js +771 -0
  179. data/node_modules/freezerwatch/node_modules/lacrosse/node_modules/request/node_modules/hawk/test/client.js +206 -0
  180. data/node_modules/freezerwatch/node_modules/lacrosse/node_modules/request/node_modules/hawk/test/crypto.js +86 -0
  181. data/node_modules/freezerwatch/node_modules/lacrosse/node_modules/request/node_modules/hawk/test/index.js +316 -0
  182. data/node_modules/freezerwatch/node_modules/lacrosse/node_modules/request/node_modules/hawk/test/message.js +246 -0
  183. data/node_modules/freezerwatch/node_modules/lacrosse/node_modules/request/node_modules/hawk/test/readme.js +98 -0
  184. data/node_modules/freezerwatch/node_modules/lacrosse/node_modules/request/node_modules/hawk/test/server.js +686 -0
  185. data/node_modules/freezerwatch/node_modules/lacrosse/node_modules/request/node_modules/hawk/test/uri.js +456 -0
  186. data/node_modules/freezerwatch/node_modules/lacrosse/node_modules/request/node_modules/hawk/test/utils.js +120 -0
  187. data/node_modules/freezerwatch/node_modules/lacrosse/node_modules/request/node_modules/http-signature/.dir-locals.el +6 -0
  188. data/node_modules/freezerwatch/node_modules/lacrosse/node_modules/request/node_modules/http-signature/.npmignore +7 -0
  189. data/node_modules/freezerwatch/node_modules/lacrosse/node_modules/request/node_modules/http-signature/LICENSE +18 -0
  190. data/node_modules/freezerwatch/node_modules/lacrosse/node_modules/request/node_modules/http-signature/README.md +79 -0
  191. data/node_modules/freezerwatch/node_modules/lacrosse/node_modules/request/node_modules/http-signature/http_signing.md +296 -0
  192. data/node_modules/freezerwatch/node_modules/lacrosse/node_modules/request/node_modules/http-signature/lib/index.js +26 -0
  193. data/node_modules/freezerwatch/node_modules/lacrosse/node_modules/request/node_modules/http-signature/lib/parser.js +304 -0
  194. data/node_modules/freezerwatch/node_modules/lacrosse/node_modules/request/node_modules/http-signature/lib/signer.js +178 -0
  195. data/node_modules/freezerwatch/node_modules/lacrosse/node_modules/request/node_modules/http-signature/lib/util.js +304 -0
  196. data/node_modules/freezerwatch/node_modules/lacrosse/node_modules/request/node_modules/http-signature/lib/verify.js +42 -0
  197. data/node_modules/freezerwatch/node_modules/lacrosse/node_modules/request/node_modules/http-signature/node_modules/asn1/.npmignore +2 -0
  198. data/node_modules/freezerwatch/node_modules/lacrosse/node_modules/request/node_modules/http-signature/node_modules/asn1/LICENSE +19 -0
  199. data/node_modules/freezerwatch/node_modules/lacrosse/node_modules/request/node_modules/http-signature/node_modules/asn1/README.md +50 -0
  200. data/node_modules/freezerwatch/node_modules/lacrosse/node_modules/request/node_modules/http-signature/node_modules/asn1/lib/ber/errors.js +13 -0
  201. data/node_modules/freezerwatch/node_modules/lacrosse/node_modules/request/node_modules/http-signature/node_modules/asn1/lib/ber/index.js +27 -0
  202. data/node_modules/freezerwatch/node_modules/lacrosse/node_modules/request/node_modules/http-signature/node_modules/asn1/lib/ber/reader.js +267 -0
  203. data/node_modules/freezerwatch/node_modules/lacrosse/node_modules/request/node_modules/http-signature/node_modules/asn1/lib/ber/types.js +36 -0
  204. data/node_modules/freezerwatch/node_modules/lacrosse/node_modules/request/node_modules/http-signature/node_modules/asn1/lib/ber/writer.js +317 -0
  205. data/node_modules/freezerwatch/node_modules/lacrosse/node_modules/request/node_modules/http-signature/node_modules/asn1/lib/index.js +20 -0
  206. data/node_modules/freezerwatch/node_modules/lacrosse/node_modules/request/node_modules/http-signature/node_modules/asn1/package.json +63 -0
  207. data/node_modules/freezerwatch/node_modules/lacrosse/node_modules/request/node_modules/http-signature/node_modules/asn1/tst/ber/reader.test.js +172 -0
  208. data/node_modules/freezerwatch/node_modules/lacrosse/node_modules/request/node_modules/http-signature/node_modules/asn1/tst/ber/writer.test.js +296 -0
  209. data/node_modules/freezerwatch/node_modules/lacrosse/node_modules/request/node_modules/http-signature/node_modules/assert-plus/README.md +126 -0
  210. data/node_modules/freezerwatch/node_modules/lacrosse/node_modules/request/node_modules/http-signature/node_modules/assert-plus/assert.js +245 -0
  211. data/node_modules/freezerwatch/node_modules/lacrosse/node_modules/request/node_modules/http-signature/node_modules/assert-plus/package.json +45 -0
  212. data/node_modules/freezerwatch/node_modules/lacrosse/node_modules/request/node_modules/http-signature/node_modules/ctype/.npmignore +1 -0
  213. data/node_modules/freezerwatch/node_modules/lacrosse/node_modules/request/node_modules/http-signature/node_modules/ctype/CHANGELOG +78 -0
  214. data/node_modules/freezerwatch/node_modules/lacrosse/node_modules/request/node_modules/http-signature/node_modules/ctype/LICENSE +24 -0
  215. data/node_modules/freezerwatch/node_modules/lacrosse/node_modules/request/node_modules/http-signature/node_modules/ctype/README +82 -0
  216. data/node_modules/freezerwatch/node_modules/lacrosse/node_modules/request/node_modules/http-signature/node_modules/ctype/README.old +298 -0
  217. data/node_modules/freezerwatch/node_modules/lacrosse/node_modules/request/node_modules/http-signature/node_modules/ctype/ctf.js +245 -0
  218. data/node_modules/freezerwatch/node_modules/lacrosse/node_modules/request/node_modules/http-signature/node_modules/ctype/ctio.js +1485 -0
  219. data/node_modules/freezerwatch/node_modules/lacrosse/node_modules/request/node_modules/http-signature/node_modules/ctype/ctype.js +944 -0
  220. data/node_modules/freezerwatch/node_modules/lacrosse/node_modules/request/node_modules/http-signature/node_modules/ctype/man/man3ctype/ctio.3ctype +241 -0
  221. data/node_modules/freezerwatch/node_modules/lacrosse/node_modules/request/node_modules/http-signature/node_modules/ctype/package.json +42 -0
  222. data/node_modules/freezerwatch/node_modules/lacrosse/node_modules/request/node_modules/http-signature/node_modules/ctype/tools/jsl.conf +129 -0
  223. data/node_modules/freezerwatch/node_modules/lacrosse/node_modules/request/node_modules/http-signature/node_modules/ctype/tools/jsstyle +839 -0
  224. data/node_modules/freezerwatch/node_modules/lacrosse/node_modules/request/node_modules/http-signature/package.json +72 -0
  225. data/node_modules/freezerwatch/node_modules/lacrosse/node_modules/request/node_modules/json-stringify-safe/.npmignore +1 -0
  226. data/node_modules/freezerwatch/node_modules/lacrosse/node_modules/request/node_modules/json-stringify-safe/CHANGELOG.md +14 -0
  227. data/node_modules/freezerwatch/node_modules/lacrosse/node_modules/request/node_modules/json-stringify-safe/LICENSE +15 -0
  228. data/node_modules/freezerwatch/node_modules/lacrosse/node_modules/request/node_modules/json-stringify-safe/Makefile +35 -0
  229. data/node_modules/freezerwatch/node_modules/lacrosse/node_modules/request/node_modules/json-stringify-safe/README.md +52 -0
  230. data/node_modules/freezerwatch/node_modules/lacrosse/node_modules/request/node_modules/json-stringify-safe/package.json +68 -0
  231. data/node_modules/freezerwatch/node_modules/lacrosse/node_modules/request/node_modules/json-stringify-safe/stringify.js +27 -0
  232. data/node_modules/freezerwatch/node_modules/lacrosse/node_modules/request/node_modules/json-stringify-safe/test/mocha.opts +2 -0
  233. data/node_modules/freezerwatch/node_modules/lacrosse/node_modules/request/node_modules/json-stringify-safe/test/stringify_test.js +246 -0
  234. data/node_modules/freezerwatch/node_modules/lacrosse/node_modules/request/node_modules/mime/LICENSE +19 -0
  235. data/node_modules/freezerwatch/node_modules/lacrosse/node_modules/request/node_modules/mime/README.md +66 -0
  236. data/node_modules/freezerwatch/node_modules/lacrosse/node_modules/request/node_modules/mime/mime.js +114 -0
  237. data/node_modules/freezerwatch/node_modules/lacrosse/node_modules/request/node_modules/mime/package.json +57 -0
  238. data/node_modules/freezerwatch/node_modules/lacrosse/node_modules/request/node_modules/mime/test.js +84 -0
  239. data/node_modules/freezerwatch/node_modules/lacrosse/node_modules/request/node_modules/mime/types/mime.types +1588 -0
  240. data/node_modules/freezerwatch/node_modules/lacrosse/node_modules/request/node_modules/mime/types/node.types +77 -0
  241. data/node_modules/freezerwatch/node_modules/lacrosse/node_modules/request/node_modules/node-uuid/.npmignore +2 -0
  242. data/node_modules/freezerwatch/node_modules/lacrosse/node_modules/request/node_modules/node-uuid/LICENSE.md +21 -0
  243. data/node_modules/freezerwatch/node_modules/lacrosse/node_modules/request/node_modules/node-uuid/README.md +243 -0
  244. data/node_modules/freezerwatch/node_modules/lacrosse/node_modules/request/node_modules/node-uuid/benchmark/README.md +53 -0
  245. data/node_modules/freezerwatch/node_modules/lacrosse/node_modules/request/node_modules/node-uuid/benchmark/bench.gnu +174 -0
  246. data/node_modules/freezerwatch/node_modules/lacrosse/node_modules/request/node_modules/node-uuid/benchmark/bench.sh +34 -0
  247. data/node_modules/freezerwatch/node_modules/lacrosse/node_modules/request/node_modules/node-uuid/benchmark/benchmark-native.c +34 -0
  248. data/node_modules/freezerwatch/node_modules/lacrosse/node_modules/request/node_modules/node-uuid/benchmark/benchmark.js +84 -0
  249. data/node_modules/freezerwatch/node_modules/lacrosse/node_modules/request/node_modules/node-uuid/bin/uuid +26 -0
  250. data/node_modules/freezerwatch/node_modules/lacrosse/node_modules/request/node_modules/node-uuid/bower.json +23 -0
  251. data/node_modules/freezerwatch/node_modules/lacrosse/node_modules/request/node_modules/node-uuid/component.json +18 -0
  252. data/node_modules/freezerwatch/node_modules/lacrosse/node_modules/request/node_modules/node-uuid/package.json +65 -0
  253. data/node_modules/freezerwatch/node_modules/lacrosse/node_modules/request/node_modules/node-uuid/test/compare_v1.js +63 -0
  254. data/node_modules/freezerwatch/node_modules/lacrosse/node_modules/request/node_modules/node-uuid/test/test.html +17 -0
  255. data/node_modules/freezerwatch/node_modules/lacrosse/node_modules/request/node_modules/node-uuid/test/test.js +228 -0
  256. data/node_modules/freezerwatch/node_modules/lacrosse/node_modules/request/node_modules/node-uuid/uuid.js +247 -0
  257. data/node_modules/freezerwatch/node_modules/lacrosse/node_modules/request/node_modules/oauth-sign/LICENSE +55 -0
  258. data/node_modules/freezerwatch/node_modules/lacrosse/node_modules/request/node_modules/oauth-sign/README.md +4 -0
  259. data/node_modules/freezerwatch/node_modules/lacrosse/node_modules/request/node_modules/oauth-sign/index.js +43 -0
  260. data/node_modules/freezerwatch/node_modules/lacrosse/node_modules/request/node_modules/oauth-sign/package.json +48 -0
  261. data/node_modules/freezerwatch/node_modules/lacrosse/node_modules/request/node_modules/oauth-sign/test.js +49 -0
  262. data/node_modules/freezerwatch/node_modules/lacrosse/node_modules/request/node_modules/qs/.gitmodules +6 -0
  263. data/node_modules/freezerwatch/node_modules/lacrosse/node_modules/request/node_modules/qs/.npmignore +7 -0
  264. data/node_modules/freezerwatch/node_modules/lacrosse/node_modules/request/node_modules/qs/Readme.md +58 -0
  265. data/node_modules/freezerwatch/node_modules/lacrosse/node_modules/request/node_modules/qs/index.js +366 -0
  266. data/node_modules/freezerwatch/node_modules/lacrosse/node_modules/request/node_modules/qs/package.json +55 -0
  267. data/node_modules/freezerwatch/node_modules/lacrosse/node_modules/request/node_modules/tough-cookie/.jshintrc +72 -0
  268. data/node_modules/freezerwatch/node_modules/lacrosse/node_modules/request/node_modules/tough-cookie/.npmignore +3 -0
  269. data/node_modules/freezerwatch/node_modules/lacrosse/node_modules/request/node_modules/tough-cookie/LICENSE +78 -0
  270. data/node_modules/freezerwatch/node_modules/lacrosse/node_modules/request/node_modules/tough-cookie/README.md +380 -0
  271. data/node_modules/freezerwatch/node_modules/lacrosse/node_modules/request/node_modules/tough-cookie/generate-pubsuffix.js +230 -0
  272. data/node_modules/freezerwatch/node_modules/lacrosse/node_modules/request/node_modules/tough-cookie/lib/cookie.js +947 -0
  273. data/node_modules/freezerwatch/node_modules/lacrosse/node_modules/request/node_modules/tough-cookie/lib/memstore.js +102 -0
  274. data/node_modules/freezerwatch/node_modules/lacrosse/node_modules/request/node_modules/tough-cookie/lib/pubsuffix.js +69 -0
  275. data/node_modules/freezerwatch/node_modules/lacrosse/node_modules/request/node_modules/tough-cookie/node_modules/punycode/LICENSE-MIT.txt +20 -0
  276. data/node_modules/freezerwatch/node_modules/lacrosse/node_modules/request/node_modules/tough-cookie/node_modules/punycode/README.md +176 -0
  277. data/node_modules/freezerwatch/node_modules/lacrosse/node_modules/request/node_modules/tough-cookie/node_modules/punycode/package.json +81 -0
  278. data/node_modules/freezerwatch/node_modules/lacrosse/node_modules/request/node_modules/tough-cookie/node_modules/punycode/punycode.js +530 -0
  279. data/node_modules/freezerwatch/node_modules/lacrosse/node_modules/request/node_modules/tough-cookie/package.json +63 -0
  280. data/node_modules/freezerwatch/node_modules/lacrosse/node_modules/request/node_modules/tough-cookie/public-suffix.txt +5229 -0
  281. data/node_modules/freezerwatch/node_modules/lacrosse/node_modules/request/node_modules/tough-cookie/test.js +1340 -0
  282. data/node_modules/freezerwatch/node_modules/lacrosse/node_modules/request/node_modules/tunnel-agent/LICENSE +55 -0
  283. data/node_modules/freezerwatch/node_modules/lacrosse/node_modules/request/node_modules/tunnel-agent/README.md +4 -0
  284. data/node_modules/freezerwatch/node_modules/lacrosse/node_modules/request/node_modules/tunnel-agent/index.js +227 -0
  285. data/node_modules/freezerwatch/node_modules/lacrosse/node_modules/request/node_modules/tunnel-agent/package.json +45 -0
  286. data/node_modules/freezerwatch/node_modules/lacrosse/node_modules/request/package.json +74 -0
  287. data/node_modules/freezerwatch/node_modules/lacrosse/node_modules/request/request.js +1244 -0
  288. data/node_modules/freezerwatch/node_modules/lacrosse/package.json +34 -0
  289. data/node_modules/freezerwatch/node_modules/optparse/README.md +163 -0
  290. data/node_modules/freezerwatch/node_modules/optparse/TODO +1 -0
  291. data/node_modules/freezerwatch/node_modules/optparse/examples/browser-test.html +75 -0
  292. data/node_modules/freezerwatch/node_modules/optparse/examples/nodejs-test.js +86 -0
  293. data/node_modules/freezerwatch/node_modules/optparse/lib/optparse.js +309 -0
  294. data/node_modules/freezerwatch/node_modules/optparse/package.json +46 -0
  295. data/node_modules/freezerwatch/node_modules/optparse/seed.yml +5 -0
  296. data/node_modules/freezerwatch/node_modules/osenv/.npmignore +13 -0
  297. data/node_modules/freezerwatch/node_modules/osenv/.travis.yml +9 -0
  298. data/node_modules/freezerwatch/node_modules/osenv/LICENSE +15 -0
  299. data/node_modules/freezerwatch/node_modules/osenv/README.md +63 -0
  300. data/node_modules/freezerwatch/node_modules/osenv/node_modules/os-homedir/index.js +24 -0
  301. data/node_modules/freezerwatch/node_modules/osenv/node_modules/os-homedir/license +21 -0
  302. data/node_modules/freezerwatch/node_modules/osenv/node_modules/os-homedir/package.json +70 -0
  303. data/node_modules/freezerwatch/node_modules/osenv/node_modules/os-homedir/readme.md +33 -0
  304. data/node_modules/freezerwatch/node_modules/osenv/node_modules/os-tmpdir/index.js +25 -0
  305. data/node_modules/freezerwatch/node_modules/osenv/node_modules/os-tmpdir/license +21 -0
  306. data/node_modules/freezerwatch/node_modules/osenv/node_modules/os-tmpdir/package.json +70 -0
  307. data/node_modules/freezerwatch/node_modules/osenv/node_modules/os-tmpdir/readme.md +36 -0
  308. data/node_modules/freezerwatch/node_modules/osenv/osenv.js +72 -0
  309. data/node_modules/freezerwatch/node_modules/osenv/package.json +76 -0
  310. data/node_modules/freezerwatch/node_modules/osenv/test/unix.js +71 -0
  311. data/node_modules/freezerwatch/node_modules/osenv/test/windows.js +74 -0
  312. data/node_modules/freezerwatch/node_modules/osenv/x.tap +39 -0
  313. data/node_modules/freezerwatch/package.json +37 -0
  314. metadata +384 -0
@@ -0,0 +1,246 @@
1
+ // Load modules
2
+
3
+ var Url = require('url');
4
+ var Lab = require('lab');
5
+ var Hoek = require('hoek');
6
+ var Hawk = require('../lib');
7
+
8
+
9
+ // Declare internals
10
+
11
+ var internals = {};
12
+
13
+
14
+ // Test shortcuts
15
+
16
+ var expect = Lab.expect;
17
+ var before = Lab.before;
18
+ var after = Lab.after;
19
+ var describe = Lab.experiment;
20
+ var it = Lab.test;
21
+
22
+
23
+ describe('Hawk', function () {
24
+
25
+ var credentialsFunc = function (id, callback) {
26
+
27
+ var credentials = {
28
+ id: id,
29
+ key: 'werxhqb98rpaxn39848xrunpaw3489ruxnpa98w4rxn',
30
+ algorithm: (id === '1' ? 'sha1' : 'sha256'),
31
+ user: 'steve'
32
+ };
33
+
34
+ return callback(null, credentials);
35
+ };
36
+
37
+ it('should generate an authorization then successfully parse it', function (done) {
38
+
39
+ credentialsFunc('123456', function (err, credentials) {
40
+
41
+ var auth = Hawk.client.message('example.com', 8080, 'some message', { credentials: credentials });
42
+ expect(auth).to.exist;
43
+
44
+ Hawk.server.authenticateMessage('example.com', 8080, 'some message', auth, credentialsFunc, {}, function (err, credentials) {
45
+
46
+ expect(err).to.not.exist;
47
+ expect(credentials.user).to.equal('steve');
48
+ done();
49
+ });
50
+ });
51
+ });
52
+
53
+ it('should fail authorization on mismatching host', function (done) {
54
+
55
+ credentialsFunc('123456', function (err, credentials) {
56
+
57
+ var auth = Hawk.client.message('example.com', 8080, 'some message', { credentials: credentials });
58
+ expect(auth).to.exist;
59
+
60
+ Hawk.server.authenticateMessage('example1.com', 8080, 'some message', auth, credentialsFunc, {}, function (err, credentials) {
61
+
62
+ expect(err).to.exist;
63
+ expect(err.message).to.equal('Bad mac');
64
+ done();
65
+ });
66
+ });
67
+ });
68
+
69
+ it('should fail authorization on stale timestamp', function (done) {
70
+
71
+ credentialsFunc('123456', function (err, credentials) {
72
+
73
+ var auth = Hawk.client.message('example.com', 8080, 'some message', { credentials: credentials });
74
+ expect(auth).to.exist;
75
+
76
+ Hawk.server.authenticateMessage('example.com', 8080, 'some message', auth, credentialsFunc, { localtimeOffsetMsec: 100000 }, function (err, credentials) {
77
+
78
+ expect(err).to.exist;
79
+ expect(err.message).to.equal('Stale timestamp');
80
+ done();
81
+ });
82
+ });
83
+ });
84
+
85
+ it('should fail authorization on invalid authorization', function (done) {
86
+
87
+ credentialsFunc('123456', function (err, credentials) {
88
+
89
+ var auth = Hawk.client.message('example.com', 8080, 'some message', { credentials: credentials });
90
+ expect(auth).to.exist;
91
+ delete auth.id;
92
+
93
+ Hawk.server.authenticateMessage('example.com', 8080, 'some message', auth, credentialsFunc, {}, function (err, credentials) {
94
+
95
+ expect(err).to.exist;
96
+ expect(err.message).to.equal('Invalid authorization');
97
+ done();
98
+ });
99
+ });
100
+ });
101
+
102
+ it('should fail authorization on bad hash', function (done) {
103
+
104
+ credentialsFunc('123456', function (err, credentials) {
105
+
106
+ var auth = Hawk.client.message('example.com', 8080, 'some message', { credentials: credentials });
107
+ expect(auth).to.exist;
108
+
109
+ Hawk.server.authenticateMessage('example.com', 8080, 'some message1', auth, credentialsFunc, {}, function (err, credentials) {
110
+
111
+ expect(err).to.exist;
112
+ expect(err.message).to.equal('Bad message hash');
113
+ done();
114
+ });
115
+ });
116
+ });
117
+
118
+ it('should fail authorization on nonce error', function (done) {
119
+
120
+ credentialsFunc('123456', function (err, credentials) {
121
+
122
+ var auth = Hawk.client.message('example.com', 8080, 'some message', { credentials: credentials });
123
+ expect(auth).to.exist;
124
+
125
+ Hawk.server.authenticateMessage('example.com', 8080, 'some message', auth, credentialsFunc, { nonceFunc: function (nonce, ts, callback) { callback (new Error('kaboom')); } }, function (err, credentials) {
126
+
127
+ expect(err).to.exist;
128
+ expect(err.message).to.equal('Invalid nonce');
129
+ done();
130
+ });
131
+ });
132
+ });
133
+
134
+ it('should fail authorization on credentials error', function (done) {
135
+
136
+ credentialsFunc('123456', function (err, credentials) {
137
+
138
+ var auth = Hawk.client.message('example.com', 8080, 'some message', { credentials: credentials });
139
+ expect(auth).to.exist;
140
+
141
+ var errFunc = function (id, callback) {
142
+
143
+ callback(new Error('kablooey'));
144
+ };
145
+
146
+ Hawk.server.authenticateMessage('example.com', 8080, 'some message', auth, errFunc, {}, function (err, credentials) {
147
+
148
+ expect(err).to.exist;
149
+ expect(err.message).to.equal('kablooey');
150
+ done();
151
+ });
152
+ });
153
+ });
154
+
155
+ it('should fail authorization on missing credentials', function (done) {
156
+
157
+ credentialsFunc('123456', function (err, credentials) {
158
+
159
+ var auth = Hawk.client.message('example.com', 8080, 'some message', { credentials: credentials });
160
+ expect(auth).to.exist;
161
+
162
+ var errFunc = function (id, callback) {
163
+
164
+ callback();
165
+ };
166
+
167
+ Hawk.server.authenticateMessage('example.com', 8080, 'some message', auth, errFunc, {}, function (err, credentials) {
168
+
169
+ expect(err).to.exist;
170
+ expect(err.message).to.equal('Unknown credentials');
171
+ done();
172
+ });
173
+ });
174
+ });
175
+
176
+ it('should fail authorization on invalid credentials', function (done) {
177
+
178
+ credentialsFunc('123456', function (err, credentials) {
179
+
180
+ var auth = Hawk.client.message('example.com', 8080, 'some message', { credentials: credentials });
181
+ expect(auth).to.exist;
182
+
183
+ var errFunc = function (id, callback) {
184
+
185
+ callback(null, {});
186
+ };
187
+
188
+ Hawk.server.authenticateMessage('example.com', 8080, 'some message', auth, errFunc, {}, function (err, credentials) {
189
+
190
+ expect(err).to.exist;
191
+ expect(err.message).to.equal('Invalid credentials');
192
+ done();
193
+ });
194
+ });
195
+ });
196
+
197
+ it('should fail authorization on invalid credentials algorithm', function (done) {
198
+
199
+ credentialsFunc('123456', function (err, credentials) {
200
+
201
+ var auth = Hawk.client.message('example.com', 8080, 'some message', { credentials: credentials });
202
+ expect(auth).to.exist;
203
+
204
+ var errFunc = function (id, callback) {
205
+
206
+ callback(null, { key: '123', algorithm: '456' });
207
+ };
208
+
209
+ Hawk.server.authenticateMessage('example.com', 8080, 'some message', auth, errFunc, {}, function (err, credentials) {
210
+
211
+ expect(err).to.exist;
212
+ expect(err.message).to.equal('Unknown algorithm');
213
+ done();
214
+ });
215
+ });
216
+ });
217
+
218
+ it('should fail on missing host', function (done) {
219
+
220
+ credentialsFunc('123456', function (err, credentials) {
221
+
222
+ var auth = Hawk.client.message(null, 8080, 'some message', { credentials: credentials });
223
+ expect(auth).to.not.exist;
224
+ done();
225
+ });
226
+ });
227
+
228
+ it('should fail on missing credentials', function (done) {
229
+
230
+ var auth = Hawk.client.message('example.com', 8080, 'some message', {});
231
+ expect(auth).to.not.exist;
232
+ done();
233
+ });
234
+
235
+ it('should fail on invalid algorithm', function (done) {
236
+
237
+ credentialsFunc('123456', function (err, credentials) {
238
+
239
+ var creds = Hoek.clone(credentials);
240
+ creds.algorithm = 'blah';
241
+ var auth = Hawk.client.message('example.com', 8080, 'some message', { credentials: creds });
242
+ expect(auth).to.not.exist;
243
+ done();
244
+ });
245
+ });
246
+ });
@@ -0,0 +1,98 @@
1
+ // Load modules
2
+
3
+ var Lab = require('lab');
4
+ var Hoek = require('hoek');
5
+ var Hawk = require('../lib');
6
+
7
+
8
+ // Declare internals
9
+
10
+ var internals = {};
11
+
12
+
13
+ // Test shortcuts
14
+
15
+ var expect = Lab.expect;
16
+ var before = Lab.before;
17
+ var after = Lab.after;
18
+ var describe = Lab.experiment;
19
+ var it = Lab.test;
20
+
21
+
22
+ describe('Hawk', function () {
23
+
24
+ describe('README', function () {
25
+
26
+ describe('core', function () {
27
+
28
+ var credentials = {
29
+ id: 'dh37fgj492je',
30
+ key: 'werxhqb98rpaxn39848xrunpaw3489ruxnpa98w4rxn',
31
+ algorithm: 'sha256'
32
+ };
33
+
34
+ var options = {
35
+ credentials: credentials,
36
+ timestamp: 1353832234,
37
+ nonce: 'j4h3g2',
38
+ ext: 'some-app-ext-data'
39
+ };
40
+
41
+ it('should generate a header protocol example', function (done) {
42
+
43
+ var header = Hawk.client.header('http://example.com:8000/resource/1?b=1&a=2', 'GET', options).field;
44
+
45
+ expect(header).to.equal('Hawk id="dh37fgj492je", ts="1353832234", nonce="j4h3g2", ext="some-app-ext-data", mac="6R4rV5iE+NPoym+WwjeHzjAGXUtLNIxmo1vpMofpLAE="');
46
+ done();
47
+ });
48
+
49
+ it('should generate a normalized string protocol example', function (done) {
50
+
51
+ var normalized = Hawk.crypto.generateNormalizedString('header', {
52
+ credentials: credentials,
53
+ ts: options.timestamp,
54
+ nonce: options.nonce,
55
+ method: 'GET',
56
+ resource: '/resource?a=1&b=2',
57
+ host: 'example.com',
58
+ port: 8000,
59
+ ext: options.ext
60
+ });
61
+
62
+ expect(normalized).to.equal('hawk.1.header\n1353832234\nj4h3g2\nGET\n/resource?a=1&b=2\nexample.com\n8000\n\nsome-app-ext-data\n');
63
+ done();
64
+ });
65
+
66
+ var payloadOptions = Hoek.clone(options);
67
+ payloadOptions.payload = 'Thank you for flying Hawk';
68
+ payloadOptions.contentType = 'text/plain';
69
+
70
+ it('should generate a header protocol example (with payload)', function (done) {
71
+
72
+ var header = Hawk.client.header('http://example.com:8000/resource/1?b=1&a=2', 'POST', payloadOptions).field;
73
+
74
+ expect(header).to.equal('Hawk id="dh37fgj492je", ts="1353832234", nonce="j4h3g2", hash="Yi9LfIIFRtBEPt74PVmbTF/xVAwPn7ub15ePICfgnuY=", ext="some-app-ext-data", mac="aSe1DERmZuRl3pI36/9BdZmnErTw3sNzOOAUlfeKjVw="');
75
+ done();
76
+ });
77
+
78
+ it('should generate a normalized string protocol example (with payload)', function (done) {
79
+
80
+ var normalized = Hawk.crypto.generateNormalizedString('header', {
81
+ credentials: credentials,
82
+ ts: options.timestamp,
83
+ nonce: options.nonce,
84
+ method: 'POST',
85
+ resource: '/resource?a=1&b=2',
86
+ host: 'example.com',
87
+ port: 8000,
88
+ hash: Hawk.crypto.calculatePayloadHash(payloadOptions.payload, credentials.algorithm, payloadOptions.contentType),
89
+ ext: options.ext
90
+ });
91
+
92
+ expect(normalized).to.equal('hawk.1.header\n1353832234\nj4h3g2\nPOST\n/resource?a=1&b=2\nexample.com\n8000\nYi9LfIIFRtBEPt74PVmbTF/xVAwPn7ub15ePICfgnuY=\nsome-app-ext-data\n');
93
+ done();
94
+ });
95
+ });
96
+ });
97
+ });
98
+
@@ -0,0 +1,686 @@
1
+ // Load modules
2
+
3
+ var Url = require('url');
4
+ var Lab = require('lab');
5
+ var Hawk = require('../lib');
6
+
7
+
8
+ // Declare internals
9
+
10
+ var internals = {};
11
+
12
+
13
+ // Test shortcuts
14
+
15
+ var expect = Lab.expect;
16
+ var before = Lab.before;
17
+ var after = Lab.after;
18
+ var describe = Lab.experiment;
19
+ var it = Lab.test;
20
+
21
+
22
+ describe('Hawk', function () {
23
+
24
+ describe('server', function () {
25
+
26
+ var credentialsFunc = function (id, callback) {
27
+
28
+ var credentials = {
29
+ id: id,
30
+ key: 'werxhqb98rpaxn39848xrunpaw3489ruxnpa98w4rxn',
31
+ algorithm: (id === '1' ? 'sha1' : 'sha256'),
32
+ user: 'steve'
33
+ };
34
+
35
+ return callback(null, credentials);
36
+ };
37
+
38
+ describe('#authenticate', function () {
39
+
40
+ it('should parse a valid authentication header (sha1)', function (done) {
41
+
42
+ var req = {
43
+ method: 'GET',
44
+ url: '/resource/4?filter=a',
45
+ host: 'example.com',
46
+ port: 8080,
47
+ authorization: 'Hawk id="1", ts="1353788437", nonce="k3j4h2", mac="zy79QQ5/EYFmQqutVnYb73gAc/U=", ext="hello"'
48
+ };
49
+
50
+ Hawk.server.authenticate(req, credentialsFunc, { localtimeOffsetMsec: 1353788437000 - Hawk.utils.now() }, function (err, credentials, artifacts) {
51
+
52
+ expect(err).to.not.exist;
53
+ expect(credentials.user).to.equal('steve');
54
+ done();
55
+ });
56
+ });
57
+
58
+ it('should parse a valid authentication header (sha256)', function (done) {
59
+
60
+ var req = {
61
+ method: 'GET',
62
+ url: '/resource/1?b=1&a=2',
63
+ host: 'example.com',
64
+ port: 8000,
65
+ authorization: 'Hawk id="dh37fgj492je", ts="1353832234", nonce="j4h3g2", mac="m8r1rHbXN6NgO+KIIhjO7sFRyd78RNGVUwehe8Cp2dU=", ext="some-app-data"'
66
+ };
67
+
68
+ Hawk.server.authenticate(req, credentialsFunc, { localtimeOffsetMsec: 1353832234000 - Hawk.utils.now() }, function (err, credentials, artifacts) {
69
+
70
+ expect(err).to.not.exist;
71
+ expect(credentials.user).to.equal('steve');
72
+ done();
73
+ });
74
+ });
75
+
76
+ it('should parse a valid authentication header (host override)', function (done) {
77
+
78
+ var req = {
79
+ method: 'GET',
80
+ url: '/resource/4?filter=a',
81
+ headers: {
82
+ host: 'example1.com:8080',
83
+ authorization: 'Hawk id="1", ts="1353788437", nonce="k3j4h2", mac="zy79QQ5/EYFmQqutVnYb73gAc/U=", ext="hello"'
84
+ }
85
+ };
86
+
87
+ Hawk.server.authenticate(req, credentialsFunc, { host: 'example.com', localtimeOffsetMsec: 1353788437000 - Hawk.utils.now() }, function (err, credentials, artifacts) {
88
+
89
+ expect(err).to.not.exist;
90
+ expect(credentials.user).to.equal('steve');
91
+ done();
92
+ });
93
+ });
94
+
95
+ it('should parse a valid authentication header (host port override)', function (done) {
96
+
97
+ var req = {
98
+ method: 'GET',
99
+ url: '/resource/4?filter=a',
100
+ headers: {
101
+ host: 'example1.com:80',
102
+ authorization: 'Hawk id="1", ts="1353788437", nonce="k3j4h2", mac="zy79QQ5/EYFmQqutVnYb73gAc/U=", ext="hello"'
103
+ }
104
+ };
105
+
106
+ Hawk.server.authenticate(req, credentialsFunc, { host: 'example.com', port: 8080, localtimeOffsetMsec: 1353788437000 - Hawk.utils.now() }, function (err, credentials, artifacts) {
107
+
108
+ expect(err).to.not.exist;
109
+ expect(credentials.user).to.equal('steve');
110
+ done();
111
+ });
112
+ });
113
+
114
+ it('should parse a valid authentication header (POST with payload)', function (done) {
115
+
116
+ var req = {
117
+ method: 'POST',
118
+ url: '/resource/4?filter=a',
119
+ host: 'example.com',
120
+ port: 8080,
121
+ authorization: 'Hawk id="123456", ts="1357926341", nonce="1AwuJD", hash="qAiXIVv+yjDATneWxZP2YCTa9aHRgQdnH9b3Wc+o3dg=", ext="some-app-data", mac="UeYcj5UoTVaAWXNvJfLVia7kU3VabxCqrccXP8sUGC4="'
122
+ };
123
+
124
+ Hawk.server.authenticate(req, credentialsFunc, { localtimeOffsetMsec: 1357926341000 - Hawk.utils.now() }, function (err, credentials, artifacts) {
125
+
126
+ expect(err).to.not.exist;
127
+ expect(credentials.user).to.equal('steve');
128
+ done();
129
+ });
130
+ });
131
+
132
+ it('should fail on missing hash', function (done) {
133
+
134
+ var req = {
135
+ method: 'GET',
136
+ url: '/resource/1?b=1&a=2',
137
+ host: 'example.com',
138
+ port: 8000,
139
+ authorization: 'Hawk id="dh37fgj492je", ts="1353832234", nonce="j4h3g2", mac="m8r1rHbXN6NgO+KIIhjO7sFRyd78RNGVUwehe8Cp2dU=", ext="some-app-data"'
140
+ };
141
+
142
+ Hawk.server.authenticate(req, credentialsFunc, { payload: 'body', localtimeOffsetMsec: 1353832234000 - Hawk.utils.now() }, function (err, credentials, artifacts) {
143
+
144
+ expect(err).to.exist;
145
+ expect(err.response.payload.message).to.equal('Missing required payload hash');
146
+ done();
147
+ });
148
+ });
149
+
150
+ it('should fail on a stale timestamp', function (done) {
151
+
152
+ var req = {
153
+ method: 'GET',
154
+ url: '/resource/4?filter=a',
155
+ host: 'example.com',
156
+ port: 8080,
157
+ authorization: 'Hawk id="123456", ts="1362337299", nonce="UzmxSs", ext="some-app-data", mac="wnNUxchvvryMH2RxckTdZ/gY3ijzvccx4keVvELC61w="'
158
+ };
159
+
160
+ Hawk.server.authenticate(req, credentialsFunc, {}, function (err, credentials, artifacts) {
161
+
162
+ expect(err).to.exist;
163
+ expect(err.response.payload.message).to.equal('Stale timestamp');
164
+ var header = err.response.headers['WWW-Authenticate'];
165
+ var ts = header.match(/^Hawk ts\=\"(\d+)\"\, tsm\=\"([^\"]+)\"\, error=\"Stale timestamp\"$/);
166
+ var now = Hawk.utils.now();
167
+ expect(parseInt(ts[1], 10) * 1000).to.be.within(now - 1000, now + 1000);
168
+
169
+ var res = {
170
+ headers: {
171
+ 'www-authenticate': header
172
+ }
173
+ };
174
+
175
+ expect(Hawk.client.authenticate(res, credentials, artifacts)).to.equal(true);
176
+ done();
177
+ });
178
+ });
179
+
180
+ it('should fail on a replay', function (done) {
181
+
182
+ var req = {
183
+ method: 'GET',
184
+ url: '/resource/4?filter=a',
185
+ host: 'example.com',
186
+ port: 8080,
187
+ authorization: 'Hawk id="123", ts="1353788437", nonce="k3j4h2", mac="bXx7a7p1h9QYQNZ8x7QhvDQym8ACgab4m3lVSFn4DBw=", ext="hello"'
188
+ };
189
+
190
+ var memoryCache = {};
191
+ var options = {
192
+ localtimeOffsetMsec: 1353788437000 - Hawk.utils.now(),
193
+ nonceFunc: function (nonce, ts, callback) {
194
+
195
+ if (memoryCache[nonce]) {
196
+ return callback(new Error());
197
+ }
198
+
199
+ memoryCache[nonce] = true;
200
+ return callback();
201
+ }
202
+ };
203
+
204
+ Hawk.server.authenticate(req, credentialsFunc, options, function (err, credentials, artifacts) {
205
+
206
+ expect(err).to.not.exist;
207
+ expect(credentials.user).to.equal('steve');
208
+
209
+ Hawk.server.authenticate(req, credentialsFunc, options, function (err, credentials, artifacts) {
210
+
211
+ expect(err).to.exist;
212
+ expect(err.response.payload.message).to.equal('Invalid nonce');
213
+ done();
214
+ });
215
+ });
216
+ });
217
+
218
+ it('should fail on an invalid authentication header: wrong scheme', function (done) {
219
+
220
+ var req = {
221
+ method: 'GET',
222
+ url: '/resource/4?filter=a',
223
+ host: 'example.com',
224
+ port: 8080,
225
+ authorization: 'Basic asdasdasdasd'
226
+ };
227
+
228
+ Hawk.server.authenticate(req, credentialsFunc, { localtimeOffsetMsec: 1353788437000 - Hawk.utils.now() }, function (err, credentials, artifacts) {
229
+
230
+ expect(err).to.exist;
231
+ expect(err.response.payload.message).to.not.exist;
232
+ done();
233
+ });
234
+ });
235
+
236
+ it('should fail on an invalid authentication header: no scheme', function (done) {
237
+
238
+ var req = {
239
+ method: 'GET',
240
+ url: '/resource/4?filter=a',
241
+ host: 'example.com',
242
+ port: 8080,
243
+ authorization: '!@#'
244
+ };
245
+
246
+ Hawk.server.authenticate(req, credentialsFunc, { localtimeOffsetMsec: 1353788437000 - Hawk.utils.now() }, function (err, credentials, artifacts) {
247
+
248
+ expect(err).to.exist;
249
+ expect(err.response.payload.message).to.equal('Invalid header syntax');
250
+ done();
251
+ });
252
+ });
253
+
254
+ it('should fail on an missing authorization header', function (done) {
255
+
256
+ var req = {
257
+ method: 'GET',
258
+ url: '/resource/4?filter=a',
259
+ host: 'example.com',
260
+ port: 8080
261
+ };
262
+
263
+ Hawk.server.authenticate(req, credentialsFunc, {}, function (err, credentials, artifacts) {
264
+
265
+ expect(err).to.exist;
266
+ expect(err.isMissing).to.equal(true);
267
+ done();
268
+ });
269
+ });
270
+
271
+ it('should fail on an missing host header', function (done) {
272
+
273
+ var req = {
274
+ method: 'GET',
275
+ url: '/resource/4?filter=a',
276
+ headers: {
277
+ authorization: 'Hawk id="123", ts="1353788437", nonce="k3j4h2", mac="/qwS4UjfVWMcUyW6EEgUH4jlr7T/wuKe3dKijvTvSos=", ext="hello"'
278
+ }
279
+ };
280
+
281
+ Hawk.server.authenticate(req, credentialsFunc, { localtimeOffsetMsec: 1353788437000 - Hawk.utils.now() }, function (err, credentials, artifacts) {
282
+
283
+ expect(err).to.exist;
284
+ expect(err.response.payload.message).to.equal('Invalid Host header');
285
+ done();
286
+ });
287
+ });
288
+
289
+ it('should fail on an missing authorization attribute (id)', function (done) {
290
+
291
+ var req = {
292
+ method: 'GET',
293
+ url: '/resource/4?filter=a',
294
+ host: 'example.com',
295
+ port: 8080,
296
+ authorization: 'Hawk ts="1353788437", nonce="k3j4h2", mac="/qwS4UjfVWMcUyW6EEgUH4jlr7T/wuKe3dKijvTvSos=", ext="hello"'
297
+ };
298
+
299
+ Hawk.server.authenticate(req, credentialsFunc, { localtimeOffsetMsec: 1353788437000 - Hawk.utils.now() }, function (err, credentials, artifacts) {
300
+
301
+ expect(err).to.exist;
302
+ expect(err.response.payload.message).to.equal('Missing attributes');
303
+ done();
304
+ });
305
+ });
306
+
307
+ it('should fail on an missing authorization attribute (ts)', function (done) {
308
+
309
+ var req = {
310
+ method: 'GET',
311
+ url: '/resource/4?filter=a',
312
+ host: 'example.com',
313
+ port: 8080,
314
+ authorization: 'Hawk id="123", nonce="k3j4h2", mac="/qwS4UjfVWMcUyW6EEgUH4jlr7T/wuKe3dKijvTvSos=", ext="hello"'
315
+ };
316
+
317
+ Hawk.server.authenticate(req, credentialsFunc, { localtimeOffsetMsec: 1353788437000 - Hawk.utils.now() }, function (err, credentials, artifacts) {
318
+
319
+ expect(err).to.exist;
320
+ expect(err.response.payload.message).to.equal('Missing attributes');
321
+ done();
322
+ });
323
+ });
324
+
325
+ it('should fail on an missing authorization attribute (nonce)', function (done) {
326
+
327
+ var req = {
328
+ method: 'GET',
329
+ url: '/resource/4?filter=a',
330
+ host: 'example.com',
331
+ port: 8080,
332
+ authorization: 'Hawk id="123", ts="1353788437", mac="/qwS4UjfVWMcUyW6EEgUH4jlr7T/wuKe3dKijvTvSos=", ext="hello"'
333
+ };
334
+
335
+ Hawk.server.authenticate(req, credentialsFunc, { localtimeOffsetMsec: 1353788437000 - Hawk.utils.now() }, function (err, credentials, artifacts) {
336
+
337
+ expect(err).to.exist;
338
+ expect(err.response.payload.message).to.equal('Missing attributes');
339
+ done();
340
+ });
341
+ });
342
+
343
+ it('should fail on an missing authorization attribute (mac)', function (done) {
344
+
345
+ var req = {
346
+ method: 'GET',
347
+ url: '/resource/4?filter=a',
348
+ host: 'example.com',
349
+ port: 8080,
350
+ authorization: 'Hawk id="123", ts="1353788437", nonce="k3j4h2", ext="hello"'
351
+ };
352
+
353
+ Hawk.server.authenticate(req, credentialsFunc, { localtimeOffsetMsec: 1353788437000 - Hawk.utils.now() }, function (err, credentials, artifacts) {
354
+
355
+ expect(err).to.exist;
356
+ expect(err.response.payload.message).to.equal('Missing attributes');
357
+ done();
358
+ });
359
+ });
360
+
361
+ it('should fail on an unknown authorization attribute', function (done) {
362
+
363
+ var req = {
364
+ method: 'GET',
365
+ url: '/resource/4?filter=a',
366
+ host: 'example.com',
367
+ port: 8080,
368
+ authorization: 'Hawk id="123", ts="1353788437", nonce="k3j4h2", x="3", mac="/qwS4UjfVWMcUyW6EEgUH4jlr7T/wuKe3dKijvTvSos=", ext="hello"'
369
+ };
370
+
371
+ Hawk.server.authenticate(req, credentialsFunc, { localtimeOffsetMsec: 1353788437000 - Hawk.utils.now() }, function (err, credentials, artifacts) {
372
+
373
+ expect(err).to.exist;
374
+ expect(err.response.payload.message).to.equal('Unknown attribute: x');
375
+ done();
376
+ });
377
+ });
378
+
379
+ it('should fail on an bad authorization header format', function (done) {
380
+
381
+ var req = {
382
+ method: 'GET',
383
+ url: '/resource/4?filter=a',
384
+ host: 'example.com',
385
+ port: 8080,
386
+ authorization: 'Hawk id="123\\", ts="1353788437", nonce="k3j4h2", mac="/qwS4UjfVWMcUyW6EEgUH4jlr7T/wuKe3dKijvTvSos=", ext="hello"'
387
+ };
388
+
389
+ Hawk.server.authenticate(req, credentialsFunc, { localtimeOffsetMsec: 1353788437000 - Hawk.utils.now() }, function (err, credentials, artifacts) {
390
+
391
+ expect(err).to.exist;
392
+ expect(err.response.payload.message).to.equal('Bad header format');
393
+ done();
394
+ });
395
+ });
396
+
397
+ it('should fail on an bad authorization attribute value', function (done) {
398
+
399
+ var req = {
400
+ method: 'GET',
401
+ url: '/resource/4?filter=a',
402
+ host: 'example.com',
403
+ port: 8080,
404
+ authorization: 'Hawk id="\t", ts="1353788437", nonce="k3j4h2", mac="/qwS4UjfVWMcUyW6EEgUH4jlr7T/wuKe3dKijvTvSos=", ext="hello"'
405
+ };
406
+
407
+ Hawk.server.authenticate(req, credentialsFunc, { localtimeOffsetMsec: 1353788437000 - Hawk.utils.now() }, function (err, credentials, artifacts) {
408
+
409
+ expect(err).to.exist;
410
+ expect(err.response.payload.message).to.equal('Bad attribute value: id');
411
+ done();
412
+ });
413
+ });
414
+
415
+ it('should fail on an empty authorization attribute value', function (done) {
416
+
417
+ var req = {
418
+ method: 'GET',
419
+ url: '/resource/4?filter=a',
420
+ host: 'example.com',
421
+ port: 8080,
422
+ authorization: 'Hawk id="", ts="1353788437", nonce="k3j4h2", mac="/qwS4UjfVWMcUyW6EEgUH4jlr7T/wuKe3dKijvTvSos=", ext="hello"'
423
+ };
424
+
425
+ Hawk.server.authenticate(req, credentialsFunc, { localtimeOffsetMsec: 1353788437000 - Hawk.utils.now() }, function (err, credentials, artifacts) {
426
+
427
+ expect(err).to.exist;
428
+ expect(err.response.payload.message).to.equal('Bad attribute value: id');
429
+ done();
430
+ });
431
+ });
432
+
433
+ it('should fail on duplicated authorization attribute key', function (done) {
434
+
435
+ var req = {
436
+ method: 'GET',
437
+ url: '/resource/4?filter=a',
438
+ host: 'example.com',
439
+ port: 8080,
440
+ authorization: 'Hawk id="123", id="456", ts="1353788437", nonce="k3j4h2", mac="/qwS4UjfVWMcUyW6EEgUH4jlr7T/wuKe3dKijvTvSos=", ext="hello"'
441
+ };
442
+
443
+ Hawk.server.authenticate(req, credentialsFunc, { localtimeOffsetMsec: 1353788437000 - Hawk.utils.now() }, function (err, credentials, artifacts) {
444
+
445
+ expect(err).to.exist;
446
+ expect(err.response.payload.message).to.equal('Duplicate attribute: id');
447
+ done();
448
+ });
449
+ });
450
+
451
+ it('should fail on an invalid authorization header format', function (done) {
452
+
453
+ var req = {
454
+ method: 'GET',
455
+ url: '/resource/4?filter=a',
456
+ host: 'example.com',
457
+ port: 8080,
458
+ authorization: 'Hawk'
459
+ };
460
+
461
+ Hawk.server.authenticate(req, credentialsFunc, { localtimeOffsetMsec: 1353788437000 - Hawk.utils.now() }, function (err, credentials, artifacts) {
462
+
463
+ expect(err).to.exist;
464
+ expect(err.response.payload.message).to.equal('Invalid header syntax');
465
+ done();
466
+ });
467
+ });
468
+
469
+ it('should fail on an bad host header (missing host)', function (done) {
470
+
471
+ var req = {
472
+ method: 'GET',
473
+ url: '/resource/4?filter=a',
474
+ headers: {
475
+ host: ':8080',
476
+ authorization: 'Hawk id="123", ts="1353788437", nonce="k3j4h2", mac="/qwS4UjfVWMcUyW6EEgUH4jlr7T/wuKe3dKijvTvSos=", ext="hello"'
477
+ }
478
+ };
479
+
480
+ Hawk.server.authenticate(req, credentialsFunc, { localtimeOffsetMsec: 1353788437000 - Hawk.utils.now() }, function (err, credentials, artifacts) {
481
+
482
+ expect(err).to.exist;
483
+ expect(err.response.payload.message).to.equal('Invalid Host header');
484
+ done();
485
+ });
486
+ });
487
+
488
+ it('should fail on an bad host header (pad port)', function (done) {
489
+
490
+ var req = {
491
+ method: 'GET',
492
+ url: '/resource/4?filter=a',
493
+ headers: {
494
+ host: 'example.com:something',
495
+ authorization: 'Hawk id="123", ts="1353788437", nonce="k3j4h2", mac="/qwS4UjfVWMcUyW6EEgUH4jlr7T/wuKe3dKijvTvSos=", ext="hello"'
496
+ }
497
+ };
498
+
499
+ Hawk.server.authenticate(req, credentialsFunc, { localtimeOffsetMsec: 1353788437000 - Hawk.utils.now() }, function (err, credentials, artifacts) {
500
+
501
+ expect(err).to.exist;
502
+ expect(err.response.payload.message).to.equal('Invalid Host header');
503
+ done();
504
+ });
505
+ });
506
+
507
+ it('should fail on credentialsFunc error', function (done) {
508
+
509
+ var req = {
510
+ method: 'GET',
511
+ url: '/resource/4?filter=a',
512
+ host: 'example.com',
513
+ port: 8080,
514
+ authorization: 'Hawk id="123", ts="1353788437", nonce="k3j4h2", mac="/qwS4UjfVWMcUyW6EEgUH4jlr7T/wuKe3dKijvTvSos=", ext="hello"'
515
+ };
516
+
517
+ var credentialsFunc = function (id, callback) {
518
+
519
+ return callback(new Error('Unknown user'));
520
+ };
521
+
522
+ Hawk.server.authenticate(req, credentialsFunc, { localtimeOffsetMsec: 1353788437000 - Hawk.utils.now() }, function (err, credentials, artifacts) {
523
+
524
+ expect(err).to.exist;
525
+ expect(err.message).to.equal('Unknown user');
526
+ done();
527
+ });
528
+ });
529
+
530
+ it('should fail on missing credentials', function (done) {
531
+
532
+ var req = {
533
+ method: 'GET',
534
+ url: '/resource/4?filter=a',
535
+ host: 'example.com',
536
+ port: 8080,
537
+ authorization: 'Hawk id="123", ts="1353788437", nonce="k3j4h2", mac="/qwS4UjfVWMcUyW6EEgUH4jlr7T/wuKe3dKijvTvSos=", ext="hello"'
538
+ };
539
+
540
+ var credentialsFunc = function (id, callback) {
541
+
542
+ return callback(null, null);
543
+ };
544
+
545
+ Hawk.server.authenticate(req, credentialsFunc, { localtimeOffsetMsec: 1353788437000 - Hawk.utils.now() }, function (err, credentials, artifacts) {
546
+
547
+ expect(err).to.exist;
548
+ expect(err.response.payload.message).to.equal('Unknown credentials');
549
+ done();
550
+ });
551
+ });
552
+
553
+ it('should fail on invalid credentials', function (done) {
554
+
555
+ var req = {
556
+ method: 'GET',
557
+ url: '/resource/4?filter=a',
558
+ host: 'example.com',
559
+ port: 8080,
560
+ authorization: 'Hawk id="123", ts="1353788437", nonce="k3j4h2", mac="/qwS4UjfVWMcUyW6EEgUH4jlr7T/wuKe3dKijvTvSos=", ext="hello"'
561
+ };
562
+
563
+ var credentialsFunc = function (id, callback) {
564
+
565
+ var credentials = {
566
+ key: 'werxhqb98rpaxn39848xrunpaw3489ruxnpa98w4rxn',
567
+ user: 'steve'
568
+ };
569
+
570
+ return callback(null, credentials);
571
+ };
572
+
573
+ Hawk.server.authenticate(req, credentialsFunc, { localtimeOffsetMsec: 1353788437000 - Hawk.utils.now() }, function (err, credentials, artifacts) {
574
+
575
+ expect(err).to.exist;
576
+ expect(err.message).to.equal('Invalid credentials');
577
+ expect(err.response.payload.message).to.equal('An internal server error occurred');
578
+ done();
579
+ });
580
+ });
581
+
582
+ it('should fail on unknown credentials algorithm', function (done) {
583
+
584
+ var req = {
585
+ method: 'GET',
586
+ url: '/resource/4?filter=a',
587
+ host: 'example.com',
588
+ port: 8080,
589
+ authorization: 'Hawk id="123", ts="1353788437", nonce="k3j4h2", mac="/qwS4UjfVWMcUyW6EEgUH4jlr7T/wuKe3dKijvTvSos=", ext="hello"'
590
+ };
591
+
592
+ var credentialsFunc = function (id, callback) {
593
+
594
+ var credentials = {
595
+ key: 'werxhqb98rpaxn39848xrunpaw3489ruxnpa98w4rxn',
596
+ algorithm: 'hmac-sha-0',
597
+ user: 'steve'
598
+ };
599
+
600
+ return callback(null, credentials);
601
+ };
602
+
603
+ Hawk.server.authenticate(req, credentialsFunc, { localtimeOffsetMsec: 1353788437000 - Hawk.utils.now() }, function (err, credentials, artifacts) {
604
+
605
+ expect(err).to.exist;
606
+ expect(err.message).to.equal('Unknown algorithm');
607
+ expect(err.response.payload.message).to.equal('An internal server error occurred');
608
+ done();
609
+ });
610
+ });
611
+
612
+ it('should fail on unknown bad mac', function (done) {
613
+
614
+ var req = {
615
+ method: 'GET',
616
+ url: '/resource/4?filter=a',
617
+ host: 'example.com',
618
+ port: 8080,
619
+ authorization: 'Hawk id="123", ts="1353788437", nonce="k3j4h2", mac="/qwS4UjfVWMcU4jlr7T/wuKe3dKijvTvSos=", ext="hello"'
620
+ };
621
+
622
+ var credentialsFunc = function (id, callback) {
623
+
624
+ var credentials = {
625
+ key: 'werxhqb98rpaxn39848xrunpaw3489ruxnpa98w4rxn',
626
+ algorithm: 'sha256',
627
+ user: 'steve'
628
+ };
629
+
630
+ return callback(null, credentials);
631
+ };
632
+
633
+ Hawk.server.authenticate(req, credentialsFunc, { localtimeOffsetMsec: 1353788437000 - Hawk.utils.now() }, function (err, credentials, artifacts) {
634
+
635
+ expect(err).to.exist;
636
+ expect(err.response.payload.message).to.equal('Bad mac');
637
+ done();
638
+ });
639
+ });
640
+ });
641
+
642
+ describe('#header', function () {
643
+
644
+ it('should return an empty authorization header on missing options', function (done) {
645
+
646
+ var header = Hawk.server.header();
647
+ expect(header).to.equal('');
648
+ done();
649
+ });
650
+
651
+ it('should return an empty authorization header on missing credentials', function (done) {
652
+
653
+ var header = Hawk.server.header(null, {});
654
+ expect(header).to.equal('');
655
+ done();
656
+ });
657
+
658
+ it('should return an empty authorization header on invalid credentials', function (done) {
659
+
660
+ var credentials = {
661
+ key: '2983d45yun89q'
662
+ };
663
+
664
+ var header = Hawk.server.header(credentials);
665
+ expect(header).to.equal('');
666
+ done();
667
+ });
668
+
669
+ it('should return an empty authorization header on invalid algorithm', function (done) {
670
+
671
+ var artifacts = {
672
+ id: '123456'
673
+ };
674
+
675
+ var credentials = {
676
+ key: '2983d45yun89q',
677
+ algorithm: 'hmac-sha-0'
678
+ };
679
+
680
+ var header = Hawk.server.header(credentials, artifacts);
681
+ expect(header).to.equal('');
682
+ done();
683
+ });
684
+ });
685
+ });
686
+ });