Skip to content

Commit

Permalink
added the source header while sending notification (#78)
Browse files Browse the repository at this point in the history
  • Loading branch information
shashi165 authored Dec 5, 2018
1 parent 32701ff commit aff5cac
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 12 deletions.
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

0 comments on commit aff5cac

Please sign in to comment.