Skip to content

Commit

Permalink
feat: new checkApp origin requirement
Browse files Browse the repository at this point in the history
  • Loading branch information
zacharis278 committed Dec 15, 2023
1 parent 3a04fbf commit c6342ec
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 4 deletions.
4 changes: 3 additions & 1 deletion src/data/messages/proctorio.js
Original file line number Diff line number Diff line change
Expand Up @@ -5,10 +5,12 @@
* vendor-specific integrations long term. As of now these events
* will trigger on ANY lti integration, not just Proctorio.
*/
import { getConfig } from '@edx/frontend-platform';

export async function checkAppStatus() {
return new Promise((resolve, reject) => {
const handleResponse = event => {
if (event.origin === window.location.origin) {
if (event.origin === getConfig().EXAMS_BASE_URL) {
window.removeEventListener('message', handleResponse);
if (event?.data?.active) {
resolve();
Expand Down
6 changes: 3 additions & 3 deletions src/data/redux.test.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -1091,7 +1091,7 @@ describe('Data layer integration tests', () => {
postMessage: mockPostMessage,
},
location: {
origin: 'https://edx.example.com',
origin: 'http://localhost:18740',
},
addEventListener: mockAddEventListener,
removeEventListener: jest.fn(),
Expand Down Expand Up @@ -1152,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://edx.example.com', data: { active: false } });
handleResponseCb({ origin: 'http://localhost:18740', data: { active: false } });

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

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

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

0 comments on commit c6342ec

Please sign in to comment.