Skip to content
This repository has been archived by the owner on Jul 15, 2019. It is now read-only.

Proxy - Header manipulation doesn't occur if newHost is not same as the actual host #262

Open
pranavparikh opened this issue Jun 6, 2014 · 0 comments
Labels

Comments

@pranavparikh
Copy link

[
{
"settings": [ "master" ],

    "name" : "descriptor",

    "startProxyServer" : true,

    "routerProxyConfig" : "./router.json",

    "config" :{
        "baseUrl" : "http://sports.yahoo.com"
    },

    "dataprovider" : {

        "Test Proxy" : {

            "controller":"./proxy-controller-record.js",
            "params" : {
                "test" : "test.js",
                "page" : "$$config.baseUrl$$"
            },
            "group" : "int"
        }
    }
}

]

Router.json looks like
{
"sports.yahoo.com" : {
"headers" : [
{
"param" : "User-Agent",
"value" : "Mozilla/5.0 (iPhone; U; CPU iPhone OS 4_2_1 like Mac OS X; en-us) AppleWebKit/533.17.9 (KHTML, like Gecko) Version/5.0.2 Mobile/8C148 Safari/6533.18.5"
}
],
"newHost" : "sports.yahoo.com",

    "record":true
}

}

-- Proxy controller

var util = require("util");
var log4js = require("yahoo-arrow").log4js;
var Controller = require("yahoo-arrow").controller;

function ProxyCustomController(testConfig,args,driver) {
Controller.call(this, testConfig,args,driver);
this.logger = log4js.getLogger("ProxyCustomController");
}

util.inherits(ProxyCustomController, Controller);

ProxyCustomController.prototype.execute = function(callback) {
var self = this;
self.resetProxyRecord(); // Reset the proxy record

if(self.driver.webdriver){

    var page = self.testParams.page;
    var webdriver = self.driver.webdriver;

    webdriver.get(page);
    webdriver.waitForElementPresent(webdriver.By.css("#yucs-search-submit")).then(function() {
        var record = self.getProxyRecord(); // Get the proxy record
        self.testParams.proxyManagerRecord=record;
        self.driver.executeTest(self.testConfig, self.testParams, function(error, report) {
            callback(error);
        });

    });
}else{
    this.logger.fatal("Custom Controllers are currently only supported on Selenium Browsers");
    callback("Custom Controllers are currently only supported on Selenium Browsers");
}

}

module.exports = ProxyCustomController;

Running this./node_modules/.bin/arrow proxy-descriptor.json --driver=selenium --browser=firefox --logLevel=debug will change the headers to Iphone

  1. Change the newHost to ".yahoo.com". Run above command again.
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
Projects
None yet
Development

No branches or pull requests

1 participant