Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Bug Fix: added the source header while sending notification #78

Merged
merged 1 commit into from
Dec 5, 2018
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
12 changes: 6 additions & 6 deletions src/handlers/notification/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -146,26 +146,26 @@ const processMessage = async (msg) => {
} else if (action.toLowerCase() === 'commit' && status.toLowerCase() === 'success') {
let callbackURLFrom = await Participant.getEndpoint(from, FSPIOP_CALLBACK_URL_TRANSFER_PUT, id)
let callbackURLTo = await Participant.getEndpoint(to, FSPIOP_CALLBACK_URL_TRANSFER_PUT, id)
headers = Object.assign({}, content.headers, { 'FSPIOP-Destination': from })
headers = Object.assign({}, content.headers, { 'FSPIOP-Destination': from }, { 'FSPIOP-Source': to })
await Callback.sendCallback(callbackURLFrom, 'put', headers, content.payload, id, from)
headers = Object.assign({}, content.headers, { 'FSPIOP-Destination': to })
headers = Object.assign({}, content.headers, { 'FSPIOP-Destination': to }, { 'FSPIOP-Source': from })
return Callback.sendCallback(callbackURLTo, 'put', headers, content.payload, id, to)
} else if (action.toLowerCase() === 'commit' && status.toLowerCase() !== 'success') {
let callbackURL = await Participant.getEndpoint(from, FSPIOP_CALLBACK_URL_TRANSFER_ERROR, id)
return Callback.sendCallback(callbackURL, 'put', content.headers, content.payload, id, from)
} else if (action.toLowerCase() === 'reject') {
let callbackURLFrom = await Participant.getEndpoint(from, FSPIOP_CALLBACK_URL_TRANSFER_PUT, id)
let callbackURLTo = await Participant.getEndpoint(to, FSPIOP_CALLBACK_URL_TRANSFER_PUT, id)
headers = Object.assign({}, content.headers, { 'FSPIOP-Destination': from })
headers = Object.assign({}, content.headers, { 'FSPIOP-Destination': from }, { 'FSPIOP-Source': to })
await Callback.sendCallback(callbackURLFrom, 'put', headers, content.payload, id, from)
headers = Object.assign({}, content.headers, { 'FSPIOP-Destination': to })
headers = Object.assign({}, content.headers, { 'FSPIOP-Destination': to }, { 'FSPIOP-Source': from })
return Callback.sendCallback(callbackURLTo, 'put', headers, content.payload, id, to)
} else if (action.toLowerCase() === 'abort') {
let callbackURLFrom = await Participant.getEndpoint(from, FSPIOP_CALLBACK_URL_TRANSFER_ERROR, id)
let callbackURLTo = await Participant.getEndpoint(to, FSPIOP_CALLBACK_URL_TRANSFER_ERROR, id)
headers = Object.assign({}, content.headers, { 'FSPIOP-Destination': from })
headers = Object.assign({}, content.headers, { 'FSPIOP-Destination': from }, { 'FSPIOP-Source': to })
await Callback.sendCallback(callbackURLFrom, 'put', headers, content.payload, id, from)
headers = Object.assign({}, content.headers, { 'FSPIOP-Destination': to })
headers = Object.assign({}, content.headers, { 'FSPIOP-Destination': to }, { 'FSPIOP-Source': from })
return Callback.sendCallback(callbackURLTo, 'put', headers, content.payload, id, to)
} else if (action.toLowerCase() === 'timeout-received') {
let callbackURL = await Participant.getEndpoint(from, FSPIOP_CALLBACK_URL_TRANSFER_ERROR, id)
Expand Down
12 changes: 6 additions & 6 deletions test/unit/handlers/notification/index.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -238,8 +238,8 @@ Test('Notification Service tests', notificationTest => {
const urlPayer = await Participant.getEndpoint(msg.value.from, FSPIOP_CALLBACK_URL_TRANSFER_PUT, msg.value.id)
const urlPayee = await Participant.getEndpoint(msg.value.to, FSPIOP_CALLBACK_URL_TRANSFER_PUT, msg.value.id)
const method = 'put'
const headersFrom = { 'FSPIOP-Destination': msg.value.from }
const headersTo = { 'FSPIOP-Destination': msg.value.to }
const headersFrom = { 'FSPIOP-Destination': msg.value.from, 'FSPIOP-Source': msg.value.to }
const headersTo = { 'FSPIOP-Destination': msg.value.to, 'FSPIOP-Source': msg.value.from }
const message = {}

const expected = 200
Expand Down Expand Up @@ -364,8 +364,8 @@ Test('Notification Service tests', notificationTest => {
const fromUrl = await Participant.getEndpoint(msg.value.from, FSPIOP_CALLBACK_URL_TRANSFER_PUT, msg.value.id)
const toUrl = await Participant.getEndpoint(msg.value.to, FSPIOP_CALLBACK_URL_TRANSFER_PUT, msg.value.id)
const method = 'put'
const headersFrom = { 'FSPIOP-Destination': msg.value.from }
const headersTo = { 'FSPIOP-Destination': msg.value.to }
const headersFrom = { 'FSPIOP-Destination': msg.value.from, 'FSPIOP-Source': msg.value.to }
const headersTo = { 'FSPIOP-Destination': msg.value.to, 'FSPIOP-Source': msg.value.from }
const message = {}

const expected = 200
Expand Down Expand Up @@ -405,8 +405,8 @@ Test('Notification Service tests', notificationTest => {
const fromUrl = await Participant.getEndpoint(msg.value.from, FSPIOP_CALLBACK_URL_TRANSFER_ERROR, msg.value.id)
const toUrl = await Participant.getEndpoint(msg.value.to, FSPIOP_CALLBACK_URL_TRANSFER_ERROR, msg.value.id)
const method = 'put'
const headersFrom = { 'FSPIOP-Destination': msg.value.from }
const headersTo = { 'FSPIOP-Destination': msg.value.to }
const headersFrom = { 'FSPIOP-Destination': msg.value.from, 'FSPIOP-Source': msg.value.to }
const headersTo = { 'FSPIOP-Destination': msg.value.to, 'FSPIOP-Source': msg.value.from }
const message = {}

const expected = 200
Expand Down