Skip to content

Commit

Permalink
add user-agent while calling api
Browse files Browse the repository at this point in the history
  • Loading branch information
nagpalkaran95 committed May 12, 2020
1 parent 8d9d4d3 commit 67dd517
Show file tree
Hide file tree
Showing 5 changed files with 27 additions and 11 deletions.
11 changes: 7 additions & 4 deletions bin/commands/info.js
Original file line number Diff line number Diff line change
Expand Up @@ -20,12 +20,15 @@ function buildInfo(args) {

let options = {
url: config.buildUrl + buildId,
method: 'GET',
method: "GET",
auth: {
user: bsConfig.auth.username,
password: bsConfig.auth.access_key
}
}
password: bsConfig.auth.access_key,
},
headers: {
"User-Agent": util.getUserAgent,
},
};

request(options, function (err, resp, body) {
let message = null;
Expand Down
11 changes: 7 additions & 4 deletions bin/commands/stop.js
Original file line number Diff line number Diff line change
Expand Up @@ -20,12 +20,15 @@ function buildStop(args) {

let options = {
url: config.buildStopUrl + buildId,
method: 'POST',
method: "POST",
auth: {
user: bsConfig.auth.username,
password: bsConfig.auth.access_key
}
}
password: bsConfig.auth.access_key,
},
headers: {
"User-Agent": util.getUserAgent(),
},
};

request(options, function (err, resp, body) {
let message = null;
Expand Down
6 changes: 4 additions & 2 deletions bin/helpers/build.js
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,8 @@ const request = require('request');

const config = require('./config'),
capabilityHelper = require("../helpers/capabilityHelper"),
Constants = require('../helpers/constants');
Constants = require('../helpers/constants'),
util =require('../helpers/util');

const createBuild = (bsConfig, zip) => {
return new Promise(function (resolve, reject) {
Expand All @@ -15,7 +16,8 @@ const createBuild = (bsConfig, zip) => {
password: bsConfig.auth.access_key
},
headers: {
'Content-Type': 'application/json'
'Content-Type': 'application/json',
"User-Agent": util.getUserAgent(),
},
body: data
}
Expand Down
4 changes: 4 additions & 0 deletions bin/helpers/util.js
Original file line number Diff line number Diff line change
Expand Up @@ -67,3 +67,7 @@ exports.setUsageReportingFlag = (bsConfig, disableUsageReporting) => {
process.env.DISABLE_USAGE_REPORTING = disableUsageReporting;
}
}

exports.getUserAgent = () => {
return `BStack-Cypress-CLI`;
}
6 changes: 5 additions & 1 deletion bin/helpers/zipUpload.js
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,8 @@ const config = require("./config"),
request = require("request"),
fs = require("fs"),
logger = require("./logger").winstonLogger,
Constants = require("./constants");
Constants = require("./constants"),
util = require("./util");

const uploadCypressZip = (bsConfig, filePath) => {
return new Promise(function (resolve, reject) {
Expand All @@ -17,6 +18,9 @@ const uploadCypressZip = (bsConfig, filePath) => {
file: fs.createReadStream(filePath),
filetype: 'zip',
filename: 'tests'
},
headers: {
"User-Agent": util.getUserAgent,
}
}

Expand Down

0 comments on commit 67dd517

Please sign in to comment.