Skip to content
This repository was archived by the owner on Jul 15, 2019. It is now read-only.
This repository was 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

Description

@pranavparikh

[
{
"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.

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions