Skip to content

Commit 04db929

Browse files
committed
Add doc for overrideDNS() and starting test it
1 parent 6f46ee5 commit 04db929

File tree

5 files changed

+177
-31
lines changed

5 files changed

+177
-31
lines changed

index.js

Lines changed: 9 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -360,7 +360,7 @@ class browserMobProxyClientApi {
360360
};
361361
/**
362362
* Set and override HTTP Request headers
363-
* @param {object} headers - Represents set of headers, Where key is a header name and value is a value of HTTP header
363+
* @param {object} headers - Represents set of headers, where key is a header name and value is a value of HTTP header
364364
* @returns {Promise}
365365
*/
366366
setHeaders(headers) {
@@ -373,16 +373,18 @@ class browserMobProxyClientApi {
373373
});
374374
};
375375

376+
/**
377+
* Overrides normal DNS lookups and remaps the given hosts with the associated IP address
378+
* @param {object} dns - Represents set of of hosts, where key is a host name and value is a IP address which associated with host name
379+
* @returns {Promise}
380+
*/
376381
overrideDNS (dns) {
377382

378-
dns = dns || {};
379-
380-
let apiUrl = `${this.url}/proxy/${this._lpPort}/headers`;
381-
let options = { method : 'POST', json : dns};
383+
const apiUrl = `${this.apiUrl}/hosts`;
384+
const options = { method : 'POST', json : true, body : dns};
382385

383386
return co(function* (){
384-
let result = yield lpClass[bmpRequest](apiUrl, options);
385-
return result;
387+
return yield browserMobProxyClient[bmpRequest](apiUrl, options);
386388
});
387389
};
388390

out/browserMobProxyClientApi.html

Lines changed: 151 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -240,6 +240,155 @@ <h5>Returns:</h5>
240240

241241

242242

243+
<h4 class="name" id="overrideDNS"><span class="type-signature"></span>overrideDNS<span class="signature">(dns)</span><span class="type-signature"> &rarr; {Promise}</span></h4>
244+
245+
246+
247+
248+
249+
<div class="description">
250+
Overrides normal DNS lookups and remaps the given hosts with the associated IP address
251+
</div>
252+
253+
254+
255+
256+
257+
258+
259+
260+
261+
<h5>Parameters:</h5>
262+
263+
264+
<table class="params">
265+
<thead>
266+
<tr>
267+
268+
<th>Name</th>
269+
270+
271+
<th>Type</th>
272+
273+
274+
275+
276+
277+
<th class="last">Description</th>
278+
</tr>
279+
</thead>
280+
281+
<tbody>
282+
283+
284+
<tr>
285+
286+
<td class="name"><code>dns</code></td>
287+
288+
289+
<td class="type">
290+
291+
292+
<span class="param-type">object</span>
293+
294+
295+
296+
</td>
297+
298+
299+
300+
301+
302+
<td class="description last">Represents set of of hosts, where key is a host name and value is a IP address which associated with host name</td>
303+
</tr>
304+
305+
306+
</tbody>
307+
</table>
308+
309+
310+
311+
312+
313+
314+
<dl class="details">
315+
316+
317+
318+
319+
320+
321+
322+
323+
324+
325+
326+
327+
328+
329+
330+
331+
332+
333+
334+
335+
336+
337+
338+
339+
340+
341+
<dt class="tag-source">Source:</dt>
342+
<dd class="tag-source"><ul class="dummy"><li>
343+
<a href="index.js.html">index.js</a>, <a href="index.js.html#line381">line 381</a>
344+
</li></ul></dd>
345+
346+
347+
348+
349+
350+
351+
352+
</dl>
353+
354+
355+
356+
357+
358+
359+
360+
361+
362+
363+
364+
365+
366+
<h5>Returns:</h5>
367+
368+
369+
370+
371+
<dl>
372+
<dt>
373+
Type
374+
</dt>
375+
<dd>
376+
377+
<span class="param-type">Promise</span>
378+
379+
380+
</dd>
381+
</dl>
382+
383+
384+
385+
386+
387+
388+
389+
390+
391+
243392
<h4 class="name" id="setBlackList"><span class="type-signature"></span>setBlackList<span class="signature">(httpCodeStatus, regexp, methodsRegexp<span class="signature-attributes">opt</span>)</span><span class="type-signature"> &rarr; {Promise.&lt;Array.&lt;<a href="global.html#BlackListedUrl">BlackListedUrl</a>>>}</span></h4>
244393

245394

@@ -522,7 +671,7 @@ <h5>Parameters:</h5>
522671

523672

524673

525-
<td class="description last">Represents set of headers, Where key is a header name and value is a value of HTTP header</td>
674+
<td class="description last">Represents set of headers, where key is a header name and value is a value of HTTP header</td>
526675
</tr>
527676

528677

@@ -790,7 +939,7 @@ <h2><a href="index.html">Home</a></h2><h3>Classes</h3><ul><li><a href="browserMo
790939
<br class="clear">
791940

792941
<footer>
793-
Documentation generated by <a href="https://github.com/jsdoc3/jsdoc">JSDoc 3.4.0</a> on Thu Jul 28 2016 00:16:54 GMT+0300 (MSK)
942+
Documentation generated by <a href="https://github.com/jsdoc3/jsdoc">JSDoc 3.4.0</a> on Thu Jul 28 2016 16:07:38 GMT+0300 (MSK)
794943
</footer>
795944

796945
<script> prettyPrint(); </script>

out/global.html

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1009,7 +1009,7 @@ <h2><a href="index.html">Home</a></h2><h3>Classes</h3><ul><li><a href="browserMo
10091009
<br class="clear">
10101010

10111011
<footer>
1012-
Documentation generated by <a href="https://github.com/jsdoc3/jsdoc">JSDoc 3.4.0</a> on Thu Jul 28 2016 00:16:54 GMT+0300 (MSK)
1012+
Documentation generated by <a href="https://github.com/jsdoc3/jsdoc">JSDoc 3.4.0</a> on Thu Jul 28 2016 16:07:38 GMT+0300 (MSK)
10131013
</footer>
10141014

10151015
<script> prettyPrint(); </script>

out/index.html

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -56,7 +56,7 @@ <h2><a href="index.html">Home</a></h2><h3>Classes</h3><ul><li><a href="browserMo
5656
<br class="clear">
5757

5858
<footer>
59-
Documentation generated by <a href="https://github.com/jsdoc3/jsdoc">JSDoc 3.4.0</a> on Thu Jul 28 2016 00:16:54 GMT+0300 (MSK)
59+
Documentation generated by <a href="https://github.com/jsdoc3/jsdoc">JSDoc 3.4.0</a> on Thu Jul 28 2016 16:07:38 GMT+0300 (MSK)
6060
</footer>
6161

6262
<script> prettyPrint(); </script>

out/index.js.html

Lines changed: 15 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -388,36 +388,31 @@ <h1 class="page-title">Source: index.js</h1>
388388
};
389389
/**
390390
* Set and override HTTP Request headers
391-
* @param {object} headers - Represents set of headers, Where key is a header name and value is a value of HTTP header
391+
* @param {object} headers - Represents set of headers, where key is a header name and value is a value of HTTP header
392392
* @returns {Promise}
393393
*/
394394
setHeaders(headers) {
395395

396-
headers = headers || {};
396+
const apiUrl = `${this.apiUrl}/headers`;
397+
const options = { method : 'POST', json : true, body : headers};
397398

398-
let apiUrl = `${this.url}/proxy/${this._lpPort}/headers`;
399-
try {
400-
let options = { method : 'POST', json : true, body : headers};
401-
402-
return co(function* (){
403-
let result = yield lpClass[bmpRequest](apiUrl, options);
404-
return result;
405-
});
406-
} catch (err){
407-
throw err;
408-
}
399+
return co(function* (){
400+
return yield browserMobProxyClient[bmpRequest](apiUrl, options);
401+
});
409402
};
410403

404+
/**
405+
* Overrides normal DNS lookups and remaps the given hosts with the associated IP address
406+
* @param {object} dns - Represents set of of hosts, where key is a host name and value is a IP address which associated with host name
407+
* @returns {Promise}
408+
*/
411409
overrideDNS (dns) {
412410

413-
dns = dns || {};
414-
415-
let apiUrl = `${this.url}/proxy/${this._lpPort}/headers`;
416-
let options = { method : 'POST', json : dns};
411+
const apiUrl = `${this.apiUrl}/hosts`;
412+
const options = { method : 'POST', json : true, body : dns};
417413

418414
return co(function* (){
419-
let result = yield lpClass[bmpRequest](apiUrl, options);
420-
return result;
415+
return yield browserMobProxyClient[bmpRequest](apiUrl, options);
421416
});
422417
};
423418

@@ -532,7 +527,7 @@ <h2><a href="index.html">Home</a></h2><h3>Classes</h3><ul><li><a href="browserMo
532527
<br class="clear">
533528

534529
<footer>
535-
Documentation generated by <a href="https://github.com/jsdoc3/jsdoc">JSDoc 3.4.0</a> on Thu Jul 28 2016 00:16:54 GMT+0300 (MSK)
530+
Documentation generated by <a href="https://github.com/jsdoc3/jsdoc">JSDoc 3.4.0</a> on Thu Jul 28 2016 16:07:38 GMT+0300 (MSK)
536531
</footer>
537532

538533
<script> prettyPrint(); </script>

0 commit comments

Comments
 (0)