Permalink
Browse files

Initial commit to factoring out mock server

  • Loading branch information...
1 parent e6f803f commit e876a91f5813e2fee051e9b7e3e57b1199556b79 Andre Rodrigues committed Dec 27, 2012
Showing with 7,932 additions and 1,164 deletions.
  1. +1 −0 .gitignore
  2. +1 −0 lib/services/blob/blobservice.js
  3. +23 −14 lib/services/core/serviceclient.js
  4. +2 −1 package.json
  5. +1 −0 prefix4424.bmp
  6. +0 −47 test/mockserver/index.html
  7. +0 −489 test/mockserver/mockserver.js
  8. +0 −172 test/mockserver/mockserverclient.js
  9. +1 −0 test/recordings/batchserviceclient-tests1/index.json
  10. +1 −0 test/recordings/batchserviceclient-tests1/x1.dat
  11. +16 −0 test/recordings/batchserviceclient-tests1/x2.dat
  12. +15 −0 test/recordings/batchserviceclient-tests1/x3.dat
  13. +38 −0 test/recordings/batchserviceclient-tests1/x4.dat
  14. +1 −0 test/recordings/batchserviceclient-tests2/index.json
  15. +1 −0 test/recordings/sharedkeytable-tests1/index.json
  16. +1 −0 test/recordings/sharedkeytable-tests1/x1.dat
  17. +16 −0 test/recordings/sharedkeytable-tests1/x2.dat
  18. +16 −0 test/recordings/sharedkeytable-tests1/x3.dat
  19. +1 −0 test/recordings/tableservice-batch-tests1/index.json
  20. +1 −0 test/recordings/tableservice-batch-tests1/x1.dat
  21. +16 −0 test/recordings/tableservice-batch-tests1/x2.dat
  22. +205 −0 test/recordings/tableservice-batch-tests1/x3.dat
  23. +625 −0 test/recordings/tableservice-batch-tests1/x4.dat
  24. +367 −0 test/recordings/tableservice-batch-tests1/x5.dat
  25. +22 −0 test/recordings/tableservice-batch-tests1/x6.dat
  26. +1 −0 test/recordings/tableservice-batch-tests2/index.json
  27. +1 −0 test/recordings/tableservice-batch-tests2/x1.dat
  28. +16 −0 test/recordings/tableservice-batch-tests2/x2.dat
  29. +205 −0 test/recordings/tableservice-batch-tests2/x3.dat
  30. +625 −0 test/recordings/tableservice-batch-tests2/x4.dat
  31. +19 −0 test/recordings/tableservice-batch-tests2/x5.dat
  32. +22 −0 test/recordings/tableservice-batch-tests2/x6.dat
  33. +1 −0 test/recordings/tableservice-batch-tests3/index.json
  34. +1 −0 test/recordings/tableservice-batch-tests3/x1.dat
  35. +16 −0 test/recordings/tableservice-batch-tests3/x2.dat
  36. +205 −0 test/recordings/tableservice-batch-tests3/x3.dat
  37. +625 −0 test/recordings/tableservice-batch-tests3/x4.dat
  38. +19 −0 test/recordings/tableservice-batch-tests3/x5.dat
  39. +22 −0 test/recordings/tableservice-batch-tests3/x6.dat
  40. +1 −0 test/recordings/tableservice-batch-tests4/index.json
  41. +1 −0 test/recordings/tableservice-batch-tests4/x1.dat
  42. +16 −0 test/recordings/tableservice-batch-tests4/x2.dat
  43. +205 −0 test/recordings/tableservice-batch-tests4/x3.dat
  44. +625 −0 test/recordings/tableservice-batch-tests4/x4.dat
  45. +25 −0 test/recordings/tableservice-batch-tests4/x5.dat
  46. +22 −0 test/recordings/tableservice-batch-tests4/x6.dat
  47. +1 −0 test/recordings/tableservice-batch-tests5/index.json
  48. +1 −0 test/recordings/tableservice-batch-tests5/x1.dat
  49. +16 −0 test/recordings/tableservice-batch-tests5/x2.dat
  50. +205 −0 test/recordings/tableservice-batch-tests5/x3.dat
  51. +625 −0 test/recordings/tableservice-batch-tests5/x4.dat
  52. +25 −0 test/recordings/tableservice-batch-tests5/x5.dat
  53. +22 −0 test/recordings/tableservice-batch-tests5/x6.dat
  54. +1 −0 test/recordings/tableservice-batch-tests6/index.json
  55. +1 −0 test/recordings/tableservice-batch-tests6/x1.dat
  56. +16 −0 test/recordings/tableservice-batch-tests6/x2.dat
  57. +205 −0 test/recordings/tableservice-batch-tests6/x3.dat
  58. +625 −0 test/recordings/tableservice-batch-tests6/x4.dat
  59. +79 −0 test/recordings/tableservice-batch-tests6/x5.dat
  60. +22 −0 test/recordings/tableservice-batch-tests6/x6.dat
  61. +1 −0 test/recordings/tableservice-tablequery-tests1/index.json
  62. +1 −0 test/recordings/tableservice-tablequery-tests1/x1.dat
  63. +16 −0 test/recordings/tableservice-tablequery-tests1/x2.dat
  64. +1 −0 test/recordings/tableservice-tablequery-tests1/x3.dat
  65. +20 −0 test/recordings/tableservice-tablequery-tests1/x4.dat
  66. +22 −0 test/recordings/tableservice-tablequery-tests1/x5.dat
  67. +26 −0 test/recordings/tableservice-tablequery-tests1/x6.dat
  68. +22 −0 test/recordings/tableservice-tablequery-tests1/x7.dat
  69. +1 −0 test/recordings/tableservice-tests1/index.json
  70. +1 −0 test/recordings/tableservice-tests1/x1.dat
  71. +10 −0 test/recordings/tableservice-tests1/x2.dat
  72. +1 −0 test/recordings/tableservice-tests10/index.json
  73. +1 −0 test/recordings/tableservice-tests10/x1.dat
  74. +16 −0 test/recordings/tableservice-tests10/x2.dat
  75. +1 −0 test/recordings/tableservice-tests10/x3.dat
  76. +21 −0 test/recordings/tableservice-tests10/x4.dat
  77. +7 −0 test/recordings/tableservice-tests10/x5.dat
  78. +22 −0 test/recordings/tableservice-tests10/x6.dat
  79. +1 −0 test/recordings/tableservice-tests11/index.json
  80. +1 −0 test/recordings/tableservice-tests11/x1.dat
  81. +16 −0 test/recordings/tableservice-tests11/x2.dat
  82. +1 −0 test/recordings/tableservice-tests11/x3.dat
  83. +21 −0 test/recordings/tableservice-tests11/x4.dat
  84. +1 −0 test/recordings/tableservice-tests11/x5.dat
  85. +22 −0 test/recordings/tableservice-tests11/x6.dat
  86. +1 −0 test/recordings/tableservice-tests12/index.json
  87. +1 −0 test/recordings/tableservice-tests12/x1.dat
  88. +16 −0 test/recordings/tableservice-tests12/x2.dat
  89. +1 −0 test/recordings/tableservice-tests12/x3.dat
  90. +21 −0 test/recordings/tableservice-tests12/x4.dat
  91. +1 −0 test/recordings/tableservice-tests12/x5.dat
  92. +7 −0 test/recordings/tableservice-tests12/x6.dat
  93. +22 −0 test/recordings/tableservice-tests12/x7.dat
  94. +1 −0 test/recordings/tableservice-tests13/index.json
  95. +1 −0 test/recordings/tableservice-tests13/x1.dat
  96. +16 −0 test/recordings/tableservice-tests13/x2.dat
  97. +1 −0 test/recordings/tableservice-tests13/x3.dat
  98. +21 −0 test/recordings/tableservice-tests13/x4.dat
  99. +1 −0 test/recordings/tableservice-tests13/x5.dat
  100. +22 −0 test/recordings/tableservice-tests13/x6.dat
  101. +1 −0 test/recordings/tableservice-tests14/index.json
  102. +1 −0 test/recordings/tableservice-tests14/x1.dat
  103. +16 −0 test/recordings/tableservice-tests14/x2.dat
  104. +1 −0 test/recordings/tableservice-tests14/x3.dat
  105. +21 −0 test/recordings/tableservice-tests14/x4.dat
  106. +1 −0 test/recordings/tableservice-tests14/x5.dat
  107. +7 −0 test/recordings/tableservice-tests14/x6.dat
  108. +22 −0 test/recordings/tableservice-tests14/x7.dat
  109. +1 −0 test/recordings/tableservice-tests15/index.json
  110. +1 −0 test/recordings/tableservice-tests15/x1.dat
  111. +16 −0 test/recordings/tableservice-tests15/x2.dat
  112. +1 −0 test/recordings/tableservice-tests15/x3.dat
  113. +1 −0 test/recordings/tableservice-tests15/x4.dat
  114. +20 −0 test/recordings/tableservice-tests15/x5.dat
  115. +22 −0 test/recordings/tableservice-tests15/x6.dat
  116. +1 −0 test/recordings/tableservice-tests16/index.json
  117. +1 −0 test/recordings/tableservice-tests16/x1.dat
  118. +16 −0 test/recordings/tableservice-tests16/x2.dat
  119. +1 −0 test/recordings/tableservice-tests16/x3.dat
  120. +1 −0 test/recordings/tableservice-tests16/x4.dat
  121. +21 −0 test/recordings/tableservice-tests16/x5.dat
  122. +22 −0 test/recordings/tableservice-tests16/x6.dat
  123. +1 −0 test/recordings/tableservice-tests17/index.json
  124. +1 −0 test/recordings/tableservice-tests17/x1.dat
  125. +16 −0 test/recordings/tableservice-tests17/x2.dat
  126. +1 −0 test/recordings/tableservice-tests17/x3.dat
  127. +20 −0 test/recordings/tableservice-tests17/x4.dat
  128. +22 −0 test/recordings/tableservice-tests17/x5.dat
  129. +1 −0 test/recordings/tableservice-tests18/index.json
  130. +1 −0 test/recordings/tableservice-tests18/x1.dat
  131. +16 −0 test/recordings/tableservice-tests18/x2.dat
  132. +7 −0 test/recordings/tableservice-tests18/x3.dat
  133. +25 −0 test/recordings/tableservice-tests18/x4.dat
  134. +22 −0 test/recordings/tableservice-tests18/x5.dat
  135. +1 −0 test/recordings/tableservice-tests19/index.json
  136. +1 −0 test/recordings/tableservice-tests19/x1.dat
  137. +22 −0 test/recordings/tableservice-tests19/x10.dat
  138. +16 −0 test/recordings/tableservice-tests19/x2.dat
  139. +1 −0 test/recordings/tableservice-tests19/x3.dat
  140. +19 −0 test/recordings/tableservice-tests19/x4.dat
  141. +1 −0 test/recordings/tableservice-tests19/x5.dat
  142. +19 −0 test/recordings/tableservice-tests19/x6.dat
  143. +1 −0 test/recordings/tableservice-tests19/x7.dat
  144. +19 −0 test/recordings/tableservice-tests19/x8.dat
  145. +43 −0 test/recordings/tableservice-tests19/x9.dat
  146. +1 −0 test/recordings/tableservice-tests2/index.json
  147. +1 −0 test/recordings/tableservice-tests2/x1.dat
  148. +1 −0 test/recordings/tableservice-tests2/x2.dat
  149. +1 −0 test/recordings/tableservice-tests2/x3.dat
  150. +10 −0 test/recordings/tableservice-tests2/x4.dat
  151. +1 −0 test/recordings/tableservice-tests20/index.json
  152. +10 −0 test/recordings/tableservice-tests20/x1.dat
  153. +1 −0 test/recordings/tableservice-tests21/index.json
  154. +10 −0 test/recordings/tableservice-tests21/x1.dat
  155. +1 −0 test/recordings/tableservice-tests22/index.json
  156. +1 −0 test/recordings/tableservice-tests22/x1.dat
  157. +16 −0 test/recordings/tableservice-tests22/x2.dat
  158. +22 −0 test/recordings/tableservice-tests22/x3.dat
  159. +1 −0 test/recordings/tableservice-tests23/index.json
  160. +1 −0 test/recordings/tableservice-tests23/x1.dat
  161. +16 −0 test/recordings/tableservice-tests23/x2.dat
  162. +22 −0 test/recordings/tableservice-tests23/x3.dat
  163. +1 −0 test/recordings/tableservice-tests24/index.json
  164. +1 −0 test/recordings/tableservice-tests24/x1.dat
  165. +16 −0 test/recordings/tableservice-tests24/x2.dat
  166. +22 −0 test/recordings/tableservice-tests24/x3.dat
  167. +1 −0 test/recordings/tableservice-tests25/index.json
  168. +10 −0 test/recordings/tableservice-tests25/x1.dat
  169. +1 −0 test/recordings/tableservice-tests3/index.json
  170. +1 −0 test/recordings/tableservice-tests3/x1.dat
  171. +16 −0 test/recordings/tableservice-tests3/x2.dat
  172. +16 −0 test/recordings/tableservice-tests3/x3.dat
  173. +22 −0 test/recordings/tableservice-tests3/x4.dat
  174. +1 −0 test/recordings/tableservice-tests4/index.json
  175. +1 −0 test/recordings/tableservice-tests4/x1.dat
  176. +16 −0 test/recordings/tableservice-tests4/x2.dat
  177. +1 −0 test/recordings/tableservice-tests4/x3.dat
  178. +7 −0 test/recordings/tableservice-tests4/x4.dat
  179. +22 −0 test/recordings/tableservice-tests4/x5.dat
  180. +1 −0 test/recordings/tableservice-tests5/index.json
  181. +10 −0 test/recordings/tableservice-tests5/x1.dat
  182. +1 −0 test/recordings/tableservice-tests5/x2.dat
  183. +16 −0 test/recordings/tableservice-tests5/x3.dat
  184. +1 −0 test/recordings/tableservice-tests5/x4.dat
  185. +16 −0 test/recordings/tableservice-tests5/x5.dat
  186. +37 −0 test/recordings/tableservice-tests5/x6.dat
  187. +37 −0 test/recordings/tableservice-tests5/x7.dat
  188. +1 −0 test/recordings/tableservice-tests6/index.json
  189. +1 −0 test/recordings/tableservice-tests6/x1.dat
  190. +16 −0 test/recordings/tableservice-tests6/x2.dat
  191. +10 −0 test/recordings/tableservice-tests6/x3.dat
  192. +1 −0 test/recordings/tableservice-tests7/index.json
  193. +1 −0 test/recordings/tableservice-tests7/x1.dat
  194. +16 −0 test/recordings/tableservice-tests7/x2.dat
  195. +1 −0 test/recordings/tableservice-tests7/x3.dat
  196. +21 −0 test/recordings/tableservice-tests7/x4.dat
  197. +1 −0 test/recordings/tableservice-tests7/x5.dat
  198. +22 −0 test/recordings/tableservice-tests7/x6.dat
  199. +48 −0 test/recordings/tableservice-tests7/x7.dat
  200. +21 −0 test/recordings/tableservice-tests7/x8.dat
  201. +22 −0 test/recordings/tableservice-tests7/x9.dat
  202. +1 −0 test/recordings/tableservice-tests8/index.json
  203. +1 −0 test/recordings/tableservice-tests8/x1.dat
  204. +16 −0 test/recordings/tableservice-tests8/x2.dat
  205. +1 −0 test/recordings/tableservice-tests8/x3.dat
  206. +21 −0 test/recordings/tableservice-tests8/x4.dat
  207. +21 −0 test/recordings/tableservice-tests8/x5.dat
  208. +22 −0 test/recordings/tableservice-tests8/x6.dat
  209. +1 −0 test/recordings/tableservice-tests9/index.json
  210. +1 −0 test/recordings/tableservice-tests9/x1.dat
  211. +16 −0 test/recordings/tableservice-tests9/x2.dat
  212. +1 −0 test/recordings/tableservice-tests9/x3.dat
  213. +21 −0 test/recordings/tableservice-tests9/x4.dat
  214. +22 −0 test/recordings/tableservice-tests9/x5.dat
  215. +8 −6 test/runtests.js
  216. +76 −68 test/services/blob/blobservice-tests.js
  217. +15 −8 test/services/blob/filters-tests.js
  218. +16 −20 test/services/blob/sharedkeylite-tests.js
  219. +20 −12 test/services/core/exponentialretrypolicyfilter-tests.js
  220. +20 −11 test/services/core/linearretrypolicyfilter-tests.js
  221. +26 −17 test/services/queue/queueservice-tests.js
  222. +17 −10 test/services/table/batchserviceclient-tests.js
  223. +1 −2 test/services/table/queryentitiesresultcontinuation-tests.js
  224. +16 −9 test/services/table/sharedkeytable-tests.js
  225. +22 −14 test/services/table/tableservice-batch-tests.js
  226. +16 −9 test/services/table/tableservice-tablequery-tests.js
  227. +56 −41 test/services/table/tableservice-tests.js
  228. +3 −3 test/testlist.txt
  229. +26 −75 test/util/blob-test-utils.js
  230. +24 −64 test/util/queue-test-utils.js
  231. +1 −1 test/util/servicebus-test-utils.js
  232. +84 −0 test/util/storage-test-utils.js
  233. +22 −70 test/util/table-test-utils.js
  234. +1 −1 test/util/wrapservice-test-utils.js
View
@@ -6,6 +6,7 @@ targets/*
*.user
# Node #
+test/recordings/
node_modules/
npm-debug.log
azure_error
@@ -952,6 +952,7 @@ BlobService.prototype.createBlockBlobFromText = function (container, blob, text,
var processResponseCallback = function (responseObject, next) {
responseObject.blobResult = null;
+
if (!responseObject.error) {
responseObject.blobResult = new BlobResult(container, blob);
responseObject.blobResult.getPropertiesFromHeaders(responseObject.response.headers);
@@ -106,20 +106,7 @@ function ServiceClient(host, authenticationProvider) {
this._initDefaultFilter();
if (host) {
- var parsedHost = ServiceClient._parseHost(host);
- this.host = parsedHost.hostname;
-
- if (parsedHost.port) {
- this.port = parsedHost.port;
- } else if (parsedHost.protocol === 'https:') {
- this.port = 443;
- } else {
- this.port = 80;
- }
-
- if (!this.protocol) {
- this.protocol = parsedHost.protocol + '//';
- }
+ this.setHost(host);
} else if (!this.protocol) {
this.protocol = ServiceClient.DEFAULT_PROTOCOL;
}
@@ -134,6 +121,28 @@ function ServiceClient(host, authenticationProvider) {
util.inherits(ServiceClient, events.EventEmitter);
+/**
+* Sets a host for the service.
+*
+* @param {string} host The host for the service.
+*/
+ServiceClient.prototype.setHost = function (host) {
+ var parsedHost = ServiceClient._parseHost(host);
+ this.host = parsedHost.hostname;
+
+ if (parsedHost.port) {
+ this.port = parsedHost.port;
+ } else if (parsedHost.protocol === 'https:') {
+ this.port = 443;
+ } else {
+ this.port = 80;
+ }
+
+ if (!this.protocol) {
+ this.protocol = parsedHost.protocol + '//';
+ }
+}
+
/**
* Performs a REST service request through HTTP expecting an input stream.
*
View
@@ -28,7 +28,8 @@
"mocha": "*",
"jshint": "*",
"sinon": "*",
- "should": "*"
+ "should": "*",
+ "http-mock": "*"
},
"homepage": "http://github.com/WindowsAzure/azure-sdk-for-node",
"repository": {
View
@@ -0,0 +1 @@
+Hello World!
View
@@ -1,47 +0,0 @@
-<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01//EN">
-<html>
- <head>
- <title>
- Mock proxy server
- </title>
- </head>
- <body>
- <h3>
- Get current session state
- </h3>
- <p>
- <code>GET <a href="session">/session</a></code>
- </p>
- <h3>
- Start recording session
- </h3>
- <p>
- <code>PUT <a href="session">/session</a> {"mode":"recording","name":"name-for-session-folder"}</code>
- </p>
- <h3>
- Start playback session
- </h3>
- <p>
- <code>PUT <a href="session">/session</a> {"mode":"playback","name":"name-for-session-folder"}</code>
- </p>
- <h3>
- End current playback or recording
- </h3>
- <p>
- <code>DELETE <a href="session">/session</a></code>
- </p>
- <h3>
- Browse recorded sessions
- </h3>
- <p>
- <code>GET <a href="sessions">/sessions</a></code>
- </p>
- <h3>
- Get and Set next-proxy settings
- </h3>
- <p>
- <code>GET <a href="proxy">/proxy</a></code><br>
- <code>PUT <a href="proxy">/proxy</a> {"host":"dns-name-or-ip","port":"80"}</code>
- </p>
- </body>
-</html>
Oops, something went wrong.

0 comments on commit e876a91

Please sign in to comment.