Skip to content

Commit

Permalink
fix: check app domain (#119)
Browse files Browse the repository at this point in the history
  • Loading branch information
zacharis278 authored Sep 27, 2023
1 parent 60cdeb6 commit 0bb36d4
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 3 deletions.
2 changes: 1 addition & 1 deletion src/data/messages/proctorio.js
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@
export async function checkAppStatus() {
return new Promise((resolve, reject) => {
const handleResponse = event => {
if (event.origin === 'https://getproctorio.com') {
if (event.origin === window.location.origin) {
window.removeEventListener('message', handleResponse);
if (event?.data?.active) {
resolve();
Expand Down
7 changes: 5 additions & 2 deletions src/data/redux.test.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -1090,6 +1090,9 @@ describe('Data layer integration tests', () => {
top: {
postMessage: mockPostMessage,
},
location: {
origin: 'https://edx.example.com',
},
addEventListener: mockAddEventListener,
removeEventListener: jest.fn(),
}));
Expand Down Expand Up @@ -1149,7 +1152,7 @@ describe('Data layer integration tests', () => {
await new Promise(process.nextTick);
const handleResponseCb = mockAddEventListener.mock.calls[0][1];
axiosMock.onPut(`${createUpdateAttemptURL}/${proctoredAttempt.attempt_id}`).reply(200, { exam_attempt_id: proctoredAttempt.attempt_id });
handleResponseCb({ origin: 'https://getproctorio.com', data: { active: false } });
handleResponseCb({ origin: 'https://edx.example.com', data: { active: false } });

await new Promise(process.nextTick);
const request = axiosMock.history.put[0];
Expand All @@ -1168,7 +1171,7 @@ describe('Data layer integration tests', () => {

await new Promise(process.nextTick);
const handleResponseCb = mockAddEventListener.mock.calls[0][1];
handleResponseCb({ origin: 'https://getproctorio.com', data: { active: true } });
handleResponseCb({ origin: 'https://edx.example.com', data: { active: true } });

await new Promise(process.nextTick);
expect(axiosMock.history.put.length).toBe(0);
Expand Down

0 comments on commit 0bb36d4

Please sign in to comment.