Skip to content
This repository was archived by the owner on May 13, 2024. It is now read-only.

Commit 60d43fb

Browse files
authored
Merge pull request #168 from hubert-deriv/add_production_endpoint
Hubert / HOTFIX fixing endpoint
2 parents 7127412 + 05cd34e commit 60d43fb

File tree

7 files changed

+23
-15
lines changed

7 files changed

+23
-15
lines changed

src/features/Apiexplorer/RequestResponseRenderer/index.tsx

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
import React, { useState, useCallback, useEffect } from 'react';
1+
import React, { useState, useCallback } from 'react';
22
import { TSocketEndpointNames, TSocketRequestProps } from '@site/src/configs/websocket/types';
33
import { Button } from '@deriv/ui';
44
import useWS from '@site/src/hooks/useWs';
@@ -20,6 +20,7 @@ function RequestResponseRenderer<T extends TSocketEndpointNames>({
2020
reqData,
2121
auth,
2222
}: IResponseRendererProps<T>) {
23+
const AUTH_ENABLED = 1;
2324
const { is_logged_in } = useAuthContext();
2425
const { disableSendRequest } = useDisableSendRequest();
2526
const { full_response, is_loading, send, clear, error } = useWS<T>(name);
@@ -43,7 +44,7 @@ function RequestResponseRenderer<T extends TSocketEndpointNames>({
4344
};
4445

4546
const handleClick = useCallback(() => {
46-
if (auth === 1) setToggleModal(true);
47+
if (auth === AUTH_ENABLED) setToggleModal(true);
4748
clear();
4849
send(parseRequestJSON());
4950
setResponseState(true);

src/features/Endpoint/Endpoint.tsx

Lines changed: 7 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,18 +1,20 @@
11
import React from 'react';
22
import { useForm } from 'react-hook-form';
33
import { Button, Text } from '@deriv/ui';
4+
import { getAppId } from '@site/src/utils';
5+
import { OAUTH_URL } from '@site/src/utils/constants';
46
import styles from './Endpoint.module.scss';
57

6-
const default_endpoint = {
7-
app_id: '35014',
8-
server_url: 'green.binaryws.com',
9-
};
10-
118
interface IEndpointFormValues {
129
app_id: string;
1310
server_url: string;
1411
}
1512
const EndPoint = () => {
13+
const default_endpoint = {
14+
app_id: getAppId(false),
15+
server_url: OAUTH_URL,
16+
};
17+
1618
const {
1719
register,
1820
handleSubmit,

src/features/Endpoint/__tests__/Endpoint.test.tsx

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -23,9 +23,9 @@ describe('Endpoint', () => {
2323
it('should have default values in input fields', () => {
2424
const server = screen.getByPlaceholderText('e.g. frontend.binaryws.com');
2525
const app_id = screen.getByPlaceholderText('e.g. 9999');
26-
expect(server).toHaveValue('green.binaryws.com');
26+
expect(server).toHaveValue('oauth.deriv.com');
2727

28-
expect(app_id).toHaveValue('35014');
28+
expect(app_id).toHaveValue('35073');
2929
});
3030

3131
it('validate user inputs, and provides error messages for app id field', async () => {

src/hooks/useLoginUrl/__tests__/useLoginUrl.test.tsx

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@ import * as utils from '@site/src/utils';
55

66
jest
77
.spyOn(utils, 'getServerConfig')
8-
.mockReturnValue({ appId: '1234', serverUrl: 'test.binary.sx' });
8+
.mockReturnValue({ appId: '1234', serverUrl: 'test.binary.sx', oauth: 'test.deriv.com' });
99

1010
describe('Use Login URL', () => {
1111
afterEach(() => {
@@ -23,7 +23,7 @@ describe('Use Login URL', () => {
2323

2424
expect(loginUrl).toContain('l=en');
2525
expect(utils.getServerConfig).toHaveBeenCalled();
26-
expect(loginUrl).toMatch(/https:\/\/test.binary.sx/);
26+
expect(loginUrl).toMatch('https://test.deriv.com/oauth2/authorize?app_id=1234&l=en');
2727
expect(loginUrl).toMatch(/app_id=1234/);
2828
});
2929

@@ -37,7 +37,7 @@ describe('Use Login URL', () => {
3737

3838
expect(loginUrl).toContain('l=es');
3939
expect(utils.getServerConfig).toHaveBeenCalled();
40-
expect(loginUrl).toMatch(/https:\/\/test.binary.sx/);
40+
expect(loginUrl).toMatch('https://test.deriv.com/oauth2/authorize?app_id=1234&l=es');
4141
expect(loginUrl).toMatch(/app_id=1234/);
4242
});
4343
});

src/hooks/useLoginUrl/index.tsx

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3,8 +3,8 @@ import { useCallback } from 'react';
33

44
const useLoginUrl = () => {
55
const getUrl = useCallback((language = 'en') => {
6-
const { appId, serverUrl } = getServerConfig();
7-
return generateLoginUrl(language, serverUrl, appId);
6+
const { appId, oauth } = getServerConfig();
7+
return generateLoginUrl(language, oauth, appId);
88
}, []);
99

1010
return { getUrl };

src/utils/constants.ts

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,8 @@ export const PRODUCTION_APP_ID = '36544';
22
export const STAGING_APP_ID = '36545';
33
export const VERCEL_DEPLOYMENT_APP_ID = '35073';
44
export const LOCALHOST_APP_ID = '35074';
5-
export const DEFAULT_WS_SERVER = 'green.binaryws.com';
5+
export const DEFAULT_WS_SERVER = 'ws.binaryws.com';
6+
export const OAUTH_URL = 'oauth.deriv.com';
67

78
export const LOGIN_ACCOUNTS_SESSION_STORAGE_KEY = 'login-accounts';
89
export const CURRENT_LOGIN_ACCOUNT_SESSION_STORAGE_KEY = 'current-login-account';

src/utils/index.ts

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,7 @@ import {
77
PRODUCTION_APP_ID,
88
STAGING_APP_ID,
99
VERCEL_DEPLOYMENT_APP_ID,
10+
OAUTH_URL,
1011
} from './constants';
1112

1213
const CURRENCY_MAP = new Map([
@@ -130,18 +131,21 @@ export const getServerConfig = () => {
130131
return {
131132
serverUrl: config_server_url,
132133
appId: config_app_id,
134+
oauth: OAUTH_URL,
133135
};
134136
} else {
135137
const isLocalHost = isHost('localhost');
136138
return {
137139
serverUrl: DEFAULT_WS_SERVER,
138140
appId: getAppId(isLocalHost),
141+
oauth: OAUTH_URL,
139142
};
140143
}
141144
} else {
142145
return {
143146
serverUrl: DEFAULT_WS_SERVER,
144147
appId: getAppId(false),
148+
oauth: OAUTH_URL,
145149
};
146150
}
147151
};

0 commit comments

Comments
 (0)