Skip to content

Commit 5809eac

Browse files
committed
passed the user-ticket to the request for #8
1 parent 8483ea7 commit 5809eac

File tree

4 files changed

+37
-8
lines changed

4 files changed

+37
-8
lines changed

test/integration/features/step_definitions/auth.js

+7-1
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,13 @@ function getUserTicket(callback) {
2828
simulateUserGettingRsvpByGrantingScopes.call(this, (err, rsvp) => {
2929
hoek.assert(!err, err);
3030

31-
exchangeRsvpForUserTicket.call(this, appTicket, rsvp, callback);
31+
exchangeRsvpForUserTicket.call(this, appTicket, rsvp, (err, userTicket) => {
32+
hoek.assert(!err, err);
33+
34+
this.ozUserTicket = userTicket;
35+
36+
callback()
37+
});
3238
});
3339
});
3440
}
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
'use strict';
2+
3+
module.exports = function () {
4+
this.World = require('../support/world.js').World;
5+
6+
this.After(function () {
7+
this.serverResponse = null;
8+
this.ozUserTicket = null;
9+
});
10+
};

test/integration/features/step_definitions/resources.js

+6-3
Original file line numberDiff line numberDiff line change
@@ -153,10 +153,11 @@ module.exports = function () {
153153
});
154154

155155
this.Then(/^a list of "([^"]*)" is returned$/, function (resourceType, callback) {
156+
assert.equals(this.getResponseStatus(), 200, this.getResponseBody());
157+
156158
var actualList = JSON.parse(this.getResponseBody())._embedded[resourceType],
157159
expectedList = getListForType(resourceType);
158160

159-
assert.equals(this.getResponseStatus(), 200);
160161
assert.equals(actualList.length, expectedList.length);
161162
_.forEach(actualList, function (actualItem, index) {
162163
var expectedItem = expectedList[index];
@@ -167,7 +168,8 @@ module.exports = function () {
167168
});
168169

169170
this.Then(/^an empty list is returned$/, function (callback) {
170-
assert.equals(this.getResponseStatus(), 200);
171+
assert.equals(this.getResponseStatus(), 200, this.getResponseBody());
172+
171173
refute.defined(JSON.parse(this.getResponseBody())._embedded);
172174

173175
callback();
@@ -196,7 +198,8 @@ module.exports = function () {
196198
});
197199

198200
this.Then(/^user "([^"]*)" is returned$/, function (user, callback) {
199-
assert.equals(this.getResponseStatus(), 200);
201+
assert.equals(this.getResponseStatus(), 200, this.getResponseBody());
202+
200203
assert.equals(JSON.parse(this.getResponseBody())['first-name'], user);
201204

202205
callback();

test/integration/features/support/world.js

+14-4
Original file line numberDiff line numberDiff line change
@@ -31,6 +31,7 @@ module.exports.World = function World() {
3131

3232
this.requestTo = (options, callback) => {
3333
loadApi.then((server) => {
34+
this.serverResponse = null;
3435
this.server = server;
3536

3637
var headers = Object.assign({
@@ -51,10 +52,19 @@ module.exports.World = function World() {
5152
};
5253

5354
this.getRequestTo = (url, callback) => {
54-
this.requestTo({
55-
url,
56-
method: 'GET'
57-
}, callback);
55+
const
56+
headers = {},
57+
method = 'GET';
58+
url = `http://example.com${url}`;
59+
60+
if (this.ozUserTicket) {
61+
headers.authorization = oz.client.header(url, method, this.ozUserTicket).field;
62+
}
63+
64+
this.requestTo(
65+
{url, method, headers},
66+
callback
67+
);
5868
};
5969

6070
this.postRequestTo = (url, callback) => {

0 commit comments

Comments
 (0)