Skip to content

Commit

Permalink
fixes rapidpro unit tests
Browse files Browse the repository at this point in the history
Signed-off-by: Diana Barsan <barsan@medic.org>
  • Loading branch information
dianabarsan committed Jan 18, 2025
1 parent 0b8dea9 commit 53ed67d
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 13 deletions.
1 change: 0 additions & 1 deletion api/src/services/rapidpro.js
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,6 @@ const getCredentials = () => {

const getRequestOptions = ({ apiToken, host }={}) => ({
baseUrl: host,
json: true,
headers: {
Authorization: `Token ${apiToken}`,
},
Expand Down
19 changes: 7 additions & 12 deletions api/tests/mocha/services/rapidpro.spec.js
Original file line number Diff line number Diff line change
Expand Up @@ -62,17 +62,15 @@ describe('RapidPro SMS Gateway', () => {
expect(request.post.args[0]).to.deep.equal([{
baseUrl: 'https://self-hosted-rapid-pro.net',
uri: '/api/v2/broadcasts.json',
json: true,
body: { urns: ['tel:phone1'], text: 'message1', },
headers: { Accept: 'application/json', Authorization: 'Token customRapidPro' },
headers: { Authorization: 'Token customRapidPro' },

Check failure

Code scanning / CodeQL

Hard-coded credentials Critical test

The hard-coded value "Token customRapidPro" is used as
authorization header
.
}]);

expect(request.post.args[1]).to.deep.equal([{
baseUrl: 'https://self-hosted-rapid-pro.net',
uri: '/api/v2/broadcasts.json',
json: true,
body: { urns: ['tel:phone2'], text: 'message2', },
headers: { Accept: 'application/json', Authorization: 'Token customRapidPro' },
headers: { Authorization: 'Token customRapidPro' },

Check failure

Code scanning / CodeQL

Hard-coded credentials Critical test

The hard-coded value "Token customRapidPro" is used as
authorization header
.
}]);

expect(result).to.deep.equal([
Expand Down Expand Up @@ -252,9 +250,8 @@ describe('RapidPro SMS Gateway', () => {
request.get.args.forEach((args, i) => expect(args).to.deep.equal([{
baseUrl: 'http://self-hosted.com',
uri: '/api/v2/messages.json',
json: true,
qs: { broadcast: `broadcast${i}` },
headers: { Accept: 'application/json', Authorization: 'Token key' },
headers: { Authorization: 'Token key' },

Check failure

Code scanning / CodeQL

Hard-coded credentials Critical test

The hard-coded value "Token key" is used as
authorization header
.
}]));
expect(messaging.updateMessageTaskStates.callCount).to.equal(1);
expect(messaging.updateMessageTaskStates.args[0]).to.deep.equal([[]]);
Expand Down Expand Up @@ -283,17 +280,15 @@ describe('RapidPro SMS Gateway', () => {
expect(request.get.args[0]).to.deep.equal([{
baseUrl: 'http://self-hosted.com',
uri: '/api/v2/messages.json',
json: true,
qs: { broadcast: `ref2` },
headers: { Accept: 'application/json', Authorization: 'Token key' },
headers: { Authorization: 'Token key' },

Check failure

Code scanning / CodeQL

Hard-coded credentials Critical test

The hard-coded value "Token key" is used as
authorization header
.
}]);

expect(request.get.args[1]).to.deep.equal([{
baseUrl: 'http://self-hosted.com',
uri: '/api/v2/messages.json',
json: true,
qs: { broadcast: `ref4` },
headers: { Accept: 'application/json', Authorization: 'Token key' },
headers: { Authorization: 'Token key' },

Check failure

Code scanning / CodeQL

Hard-coded credentials Critical test

The hard-coded value "Token key" is used as
authorization header
.
}]);
});
});
Expand Down Expand Up @@ -325,13 +320,13 @@ describe('RapidPro SMS Gateway', () => {
baseUrl: 'https://textit.in',
uri: '/api/v2/messages.json',
qs: { broadcast: `ref1` },
headers: { Accept: 'application/json', Authorization: 'Token key' },
headers: { Authorization: 'Token key' },

Check failure

Code scanning / CodeQL

Hard-coded credentials Critical test

The hard-coded value "Token key" is used as
authorization header
.
});
expect(request.get.args[1][0]).to.deep.include({
baseUrl: 'https://textit.in',
uri: '/api/v2/messages.json',
qs: { broadcast: `ref2` },
headers: { Accept: 'application/json', Authorization: 'Token key' },
headers: { Authorization: 'Token key' },

Check failure

Code scanning / CodeQL

Hard-coded credentials Critical test

The hard-coded value "Token key" is used as
authorization header
.
});
expect(request.get.args[2][0]).to.deep.include({
baseUrl: 'https://textit.in',
Expand Down

0 comments on commit 53ed67d

Please sign in to comment.