Skip to content

Commit

Permalink
Merge branch 'master' of github.com:jordanwalsh23/xero-node
Browse files Browse the repository at this point in the history
  • Loading branch information
Jordan Walsh committed Mar 7, 2017
2 parents 7956c1f + 3dbbc32 commit 5918bb8
Show file tree
Hide file tree
Showing 4 changed files with 29 additions and 38 deletions.
2 changes: 0 additions & 2 deletions README.md
Expand Up @@ -76,7 +76,6 @@ The config file should be set up as follows:
"ConsumerSecret": "BBBBBBBBBBBBBBBBBBBB",
"AuthorizeCallbackUrl": 'https://www.mywebsite.com/xerocallback',
"PrivateKeyPath" : "/some/path/to/partner_privatekey.pem",
"SSLCertPath" : "/some/path/to/partner_publickey.cer",
"RunscopeBucketId" : "xxxyyyzzzz"
}
```
Expand All @@ -90,7 +89,6 @@ The config file should be set up as follows:
| ConsumerSecret | The secret key from the developer portal that is required to authenticate your API calls | True |
| AuthorizeCallbackUrl | The callback that Xero should invoke when the authorization is successful. | False |
| PrivateKeyPath | The filesystem path to your privatekey.pem file to sign the API calls | False |
| SSLCertPath | The filesystem path to your publickey.pem file to sign the API calls | False |
| RunscopeBucketId | Your personal runscope bucket for debugging API calls | False |
---

Expand Down
5 changes: 1 addition & 4 deletions lib/application.js
Expand Up @@ -455,7 +455,6 @@ populateOptions = function(configFilePath) {
options["consumerSecret"] = config.ConsumerSecret;
options["privateKeyPath"] = config.PrivateKeyPath;
options["authorizeCallbackUrl"] = config.AuthorizeCallbackUrl;
options["sslCertPath"] = config.SSLCertPath;
options["userAgent"] = config.UserAgent || "Xero - Node.js SDK";
options["runscopeBucketId"] = config.RunscopeBucketId;
} catch (e) {
Expand Down Expand Up @@ -582,16 +581,14 @@ var PartnerApplication = RequireAuthorizationApplication.extend({
);
//use SSL certificate
var keyCert = fs.readFileSync(this.options.privateKeyPath);
var cert = fs.readFileSync(this.options.sslCertPath);
this.oa._createClient = function(port, hostname, method, path, headers, sslEnabled) {
var options = {
host: hostname,
port: port,
path: path,
method: method,
headers: headers,
key: keyCert,
cert: cert
key: keyCert
};
var httpModel;
if (sslEnabled) {
Expand Down
2 changes: 1 addition & 1 deletion sample_app/sample_app.js
Expand Up @@ -4,7 +4,7 @@ var express = require('express'),
LRU = require('lru-cache'),
fs = require('fs'),
nodemailer = require('nodemailer'),
publicConfigFile = "/Users/jordan.walsh/.xero/public_app_config.json";
publicConfigFile = "../public_app_config.json";

function getXeroApp(session) {
var config = {
Expand Down
58 changes: 27 additions & 31 deletions test/accountingtests.js
Expand Up @@ -13,40 +13,37 @@ process.on('uncaughtException', function(err) {
var currentApp;
var organisationCountry = "";

var APPTYPE = "PRIVATE";
var privateConfigFile = "/Users/jordan.walsh/.xero/private_app_config.json";
var publicConfigFile = "/Users/jordan.walsh/.xero/public_app_config.json";
var partnerConfigFile = "/Users/jordan.walsh/.xero/partner_app_config.json";
var APPTYPE = "PARTNER";
var privateConfigFile = "../private_app_config.json";
var publicConfigFile = "../public_app_config.json";
var partnerConfigFile = "../partner_app_config.json";
var configFile = "";

describe('create application', function() {
describe('create instance', function() {
it('init instance and set options', function(done) {
//This constructor looks in ~/.xero/config.json for settings

switch (APPTYPE) {
case "PRIVATE":
configFile = privateConfigFile;
currentApp = new xero.PrivateApplication(configFile);
break;
case "PUBLIC":
configFile = publicConfigFile;
currentApp = new xero.PublicApplication(publicConfigFile, { runscopeBucketId: "ei635hnc0fem" });
break;
case "PARTNER":
configFile = partnerConfigFile;
currentApp = new xero.PartnerApplication(partnerConfigFile, { authorizedCallbackUrl: "" });
break;
default:
throw "No App Type Set!!"
}

done();
})
});
});
before('init instance and set options', function(done) {
//This constructor looks in ~/.xero/config.json for settings

switch (APPTYPE) {
case "PRIVATE":
configFile = privateConfigFile;
currentApp = new xero.PrivateApplication(configFile);
break;
case "PUBLIC":
configFile = publicConfigFile;
currentApp = new xero.PublicApplication(publicConfigFile, { runscopeBucketId: "ei635hnc0fem" });
break;
case "PARTNER":
configFile = partnerConfigFile;
currentApp = new xero.PartnerApplication(partnerConfigFile, { authorizedCallbackUrl: "" });
break;
default:
throw "No App Type Set!!"
}

done();
})

describe('get access for public or partner application', function() {
this.timeout(30000);
beforeEach(function() {
if (APPTYPE === "PRIVATE") {
this.skip();
Expand Down Expand Up @@ -155,7 +152,6 @@ describe('get access for public or partner application', function() {
it('should see application auth page', function(done) {
//console.log(browser.document.documentElement.innerHTML);
browser.assert.text('title', 'Xero | Authorise Application');
browser.select('select', 'MWE5NzdkMDItZTAyNC00NGJkLTlmMGQtNjFiOGI4OWY2YTI4-ecmd9rxRfsM=');

if (APPTYPE === "PUBLIC") {
browser.pressButton("Allow access for 30 mins");
Expand Down

0 comments on commit 5918bb8

Please sign in to comment.