Skip to content

Commit

Permalink
feat: new checkApp origin requirement (#126)
Browse files Browse the repository at this point in the history
  • Loading branch information
Zacharis278 authored Dec 15, 2023
1 parent 3a04fbf commit 1d236a4
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 3 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
4 changes: 2 additions & 2 deletions src/data/redux.test.jsx
Original file line number Diff line number Diff line change
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 1d236a4

Please sign in to comment.