Skip to content

Commit

Permalink
test: 🚧 🧪 add some more tests
Browse files Browse the repository at this point in the history
Signed-off-by: Manuel Ruck <[email protected]>
  • Loading branch information
Manuel Ruck committed Jul 13, 2024
1 parent c3e2ea1 commit 9055cdc
Show file tree
Hide file tree
Showing 6 changed files with 591 additions and 161 deletions.
4 changes: 2 additions & 2 deletions src/express/auth/permissions.ts
Original file line number Diff line number Diff line change
Expand Up @@ -8,15 +8,15 @@ const isLoggedin = rule({ cache: 'no_cache' })(async (parent, args, { user, devi
logger.graphql('isLoggedin', { user, device });
if (!user || !device) {
logger.warn('Permission denied: You need to login with your Device');
return false;
return Error('Not Authorised!');
}
return true;
});

const isVerified = rule({ cache: 'no_cache' })(async (parent, args, { user, phone }) => {
if (!user || (CONFIG.SMS_VERIFICATION && (!user.isVerified() || !phone))) {
logger.warn('Permission denied: isVerified = false');
return false;
return Error('Not Verified!');
}
return true;
});
Expand Down
32 changes: 32 additions & 0 deletions src/graphql/resolvers/Activity.integ.ts
Original file line number Diff line number Diff line change
Expand Up @@ -226,6 +226,38 @@ describe('Activity Resolvers', () => {
expect(data.increaseActivity.activityIndex).toBeDefined();
expect(data.increaseActivity.active).toBeTruthy();
});

it('not verified', async () => {
const response = await axios.post(
GRAPHQL_API_URL,
{
query: `
mutation IncreaseActivity($procedureId: String!) {
increaseActivity(procedureId: $procedureId) {
activityIndex
active
}
}
`,
variables: {
procedureId: '0000000',
},
},
{
headers: {
'Content-Type': 'application/json',
'x-device-hash': device.deviceHash,
},
},
);

const { data, errors } = response.data;

expect(data).toBeDefined();
expect(data.increaseActivity).toBeNull();
expect(errors).toBeDefined();
expect(errors[0].message).toBe('Not Verified!');
});
});
});
});
Loading

0 comments on commit 9055cdc

Please sign in to comment.