-
Notifications
You must be signed in to change notification settings - Fork 4.2k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
* Fix Social Push notifications * Fix code formatting issues * Fix commented issues * Fix Syntax errors * update push notify dependency * specify push-notify version * change how apn key is loaded * feat(push-notifications): improve logging * feat(push-notifications): disable v2 push notifications * test(push-notifications): add unit tests and improve integration ones * fix(push-notifications): throw when required params are missing * fix(tests): correct descriptions and remove wrong comment * fix(push-notifications): trim APN key * fix(apn): log feedback only if it has data * fix(apn): load cert and key differently * fix(tests): correctly load apn during tests * download creds from S3 and create AWS lib * convert s3 buffer to a string * fix(apn): remove console.log and do not use cert twice * invert key and cert, disable failing test * invert key and cert
- Loading branch information
Showing
26 changed files
with
624 additions
and
291 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
32 changes: 32 additions & 0 deletions
32
test/api/v3/integration/user/DELETE-user_push_device.test.js
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,32 @@ | ||
import { | ||
generateUser, | ||
translate as t, | ||
} from '../../../../helpers/api-integration/v3'; | ||
|
||
describe('DELETE /user/push-devices', () => { | ||
let user; | ||
let regId = '10'; | ||
let type = 'ios'; | ||
|
||
beforeEach(async () => { | ||
user = await generateUser(); | ||
}); | ||
|
||
it('returns an error if user does not have the push device', async () => { | ||
await expect(user.del(`/user/push-devices/${regId}`)) | ||
.to.eventually.be.rejected.and.eql({ | ||
code: 404, | ||
error: 'NotFound', | ||
message: t('pushDeviceNotFound'), | ||
}); | ||
}); | ||
|
||
it('removes a push device from the user', async () => { | ||
await user.post('/user/push-devices', {type, regId}); | ||
let response = await user.del(`/user/push-devices/${regId}`); | ||
await user.sync(); | ||
|
||
expect(response.message).to.equal(t('pushDeviceRemoved')); | ||
expect(user.pushDevices.length).to.equal(0); | ||
}); | ||
}); |
35 changes: 0 additions & 35 deletions
35
test/api/v3/integration/user/POST-user_addPushDevice.test.js
This file was deleted.
Oops, something went wrong.
60 changes: 60 additions & 0 deletions
60
test/api/v3/integration/user/POST-user_push_device.test.js
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,60 @@ | ||
import { | ||
generateUser, | ||
translate as t, | ||
} from '../../../../helpers/api-integration/v3'; | ||
|
||
describe('POST /user/push-devices', () => { | ||
let user; | ||
let regId = '10'; | ||
let type = 'ios'; | ||
|
||
beforeEach(async () => { | ||
user = await generateUser(); | ||
}); | ||
|
||
it('returns an error when regId is not provided', async () => { | ||
await expect(user.post('/user/push-devices'), {type}) | ||
.to.eventually.be.rejected.and.to.eql({ | ||
code: 400, | ||
error: 'BadRequest', | ||
message: 'Invalid request parameters.', | ||
}); | ||
}); | ||
|
||
it('returns an error when type is not provided', async () => { | ||
await expect(user.post('/user/push-devices', {regId})) | ||
.to.eventually.be.rejected.and.to.eql({ | ||
code: 400, | ||
error: 'BadRequest', | ||
message: 'Invalid request parameters.', | ||
}); | ||
}); | ||
|
||
it('returns an error when type is not valid', async () => { | ||
await expect(user.post('/user/push-devices', {regId, type: 'invalid'})) | ||
.to.eventually.be.rejected.and.to.eql({ | ||
code: 400, | ||
error: 'BadRequest', | ||
message: 'Invalid request parameters.', | ||
}); | ||
}); | ||
|
||
it('returns an error if user already has the push device', async () => { | ||
await user.post('/user/push-devices', {type, regId}); | ||
await expect(user.post('/user/push-devices', {type, regId})) | ||
.to.eventually.be.rejected.and.eql({ | ||
code: 401, | ||
error: 'NotAuthorized', | ||
message: t('pushDeviceAlreadyAdded'), | ||
}); | ||
}); | ||
|
||
it('adds a push device to the user', async () => { | ||
let response = await user.post('/user/push-devices', {type, regId}); | ||
await user.sync(); | ||
|
||
expect(response.message).to.equal(t('pushDeviceAdded')); | ||
expect(user.pushDevices[0].type).to.equal(type); | ||
expect(user.pushDevices[0].regId).to.equal(regId); | ||
}); | ||
}); |
Oops, something went wrong.