Skip to content

Commit c1c65c2

Browse files
committed
test: add apns-id to success test cases for ManageChannelsClient
1 parent daed8f8 commit c1c65c2

1 file changed

Lines changed: 14 additions & 6 deletions

File tree

test/client.js

Lines changed: 14 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1619,6 +1619,8 @@ describe('ManageChannelsClient', () => {
16191619
let requestsServed = 0;
16201620
const method = HTTP2_METHOD_POST;
16211621
const path = PATH_CHANNELS;
1622+
const notificationId = '7dc35f9f-58d4-40dd-8c08-38ab811f57df';
1623+
const additionalHeaderInfo = { 'apns-id': notificationId };
16221624
server = createAndStartMockServer(TEST_PORT, (req, res, requestBody) => {
16231625
expect(req.headers).to.deep.equal({
16241626
':authority': '127.0.0.1',
@@ -1630,7 +1632,7 @@ describe('ManageChannelsClient', () => {
16301632
expect(requestBody).to.equal(MOCK_BODY);
16311633
// res.setHeader('X-Foo', 'bar');
16321634
// res.writeHead(200, { 'Content-Type': 'text/plain; charset=utf-8' });
1633-
res.writeHead(200);
1635+
res.writeHead(200, additionalHeaderInfo);
16341636
res.end('');
16351637
requestsServed += 1;
16361638
didRequest = true;
@@ -1648,7 +1650,7 @@ describe('ManageChannelsClient', () => {
16481650
};
16491651
const bundleId = BUNDLE_ID;
16501652
const result = await client.write(mockNotification, bundleId, 'channels', 'post');
1651-
expect(result).to.deep.equal({ bundleId });
1653+
expect(result).to.deep.equal({ ...additionalHeaderInfo, bundleId });
16521654
expect(didRequest).to.be.true;
16531655
};
16541656
expect(establishedConnections).to.equal(0); // should not establish a connection until it's needed
@@ -1677,10 +1679,12 @@ describe('ManageChannelsClient', () => {
16771679
const channel = 'dHN0LXNyY2gtY2hubA==';
16781680
const requestId = '0309F412-AA57-46A8-9AC6-B5AECA8C4594';
16791681
const uniqueId = '4C106C5F-2013-40B9-8193-EAA270B8F2C5';
1682+
const notificationId = '7dc35f9f-58d4-40dd-8c08-38ab811f57df';
16801683
const additionalHeaderInfo = {
16811684
'apns-channel-id': channel,
16821685
'apns-request-id': requestId,
16831686
'apns-unique-id': uniqueId,
1687+
'apns-id': notificationId,
16841688
};
16851689

16861690
server = createAndStartMockServer(TEST_PORT, (req, res, requestBody) => {
@@ -1739,7 +1743,8 @@ describe('ManageChannelsClient', () => {
17391743
const path = PATH_CHANNELS;
17401744
const channel = 'dHN0LXNyY2gtY2hubA==';
17411745
const requestId = '0309F412-AA57-46A8-9AC6-B5AECA8C4594';
1742-
const additionalHeaderInfo = { 'apns-request-id': requestId };
1746+
const notificationId = '7dc35f9f-58d4-40dd-8c08-38ab811f57df';
1747+
const additionalHeaderInfo = { 'apns-request-id': requestId, 'apns-id': notificationId };
17431748

17441749
server = createAndStartMockServer(TEST_PORT, (req, res, requestBody) => {
17451750
expect(req.headers).to.deep.equal({
@@ -1799,7 +1804,8 @@ describe('ManageChannelsClient', () => {
17991804
const channels = { channels: ['dHN0LXNyY2gtY2hubA=='] };
18001805
const requestId = '0309F412-AA57-46A8-9AC6-B5AECA8C4594';
18011806
const uniqueId = '4C106C5F-2013-40B9-8193-EAA270B8F2C5';
1802-
const additionalHeaderInfo = { 'apns-request-id': requestId, 'apns-unique-id': uniqueId };
1807+
const notificationId = '7dc35f9f-58d4-40dd-8c08-38ab811f57df';
1808+
const additionalHeaderInfo = { 'apns-request-id': requestId, 'apns-unique-id': uniqueId, 'apns-id': notificationId };
18031809

18041810
server = createAndStartMockServer(TEST_PORT, (req, res, requestBody) => {
18051811
expect(req.headers).to.deep.equal({
@@ -1858,6 +1864,8 @@ describe('ManageChannelsClient', () => {
18581864
let requestsServed = 0;
18591865
const method = HTTP2_METHOD_POST;
18601866
const path = PATH_CHANNELS;
1867+
const notificationId = '7dc35f9f-58d4-40dd-8c08-38ab811f57df';
1868+
const additionalHeaderInfo = { 'apns-id': notificationId };
18611869
server = createAndStartMockServer(TEST_PORT, (req, res, requestBody) => {
18621870
expect(req.headers).to.deep.equal({
18631871
':authority': '127.0.0.1',
@@ -1869,7 +1877,7 @@ describe('ManageChannelsClient', () => {
18691877
expect(requestBody).to.equal(MOCK_BODY);
18701878
// Set a timeout of 100 to simulate latency to a remote server.
18711879
setTimeout(() => {
1872-
res.writeHead(200);
1880+
res.writeHead(200, additionalHeaderInfo);
18731881
res.end('');
18741882
requestsServed += 1;
18751883
}, 100);
@@ -1887,7 +1895,7 @@ describe('ManageChannelsClient', () => {
18871895
};
18881896
const bundleId = BUNDLE_ID;
18891897
const result = await client.write(mockNotification, bundleId, 'channels', 'post');
1890-
expect(result).to.deep.equal({ bundleId });
1898+
expect(result).to.deep.equal({ ...additionalHeaderInfo, bundleId });
18911899
};
18921900
expect(establishedConnections).to.equal(0); // should not establish a connection until it's needed
18931901
// Validate that when multiple valid requests arrive concurrently,

0 commit comments

Comments
 (0)