Skip to content
Snippets Groups Projects
Commit 2e62f81e authored by ManosAngelidis's avatar ManosAngelidis
Browse files

[NRRPLT-8250] Added GDPR status set and get functions

- Implements the communication with the proxy

- GET function that receives whether the user has accepted the GPDR terms.
  On the proxy side checks the GDPR table in the storage

- SET function that sets the accepted status (only positive) when the user
  has accepted the GDPR terms. On the proxy side adds the status in the
  GDPR table
parent c55aba47
No related branches found
No related tags found
No related merge requests found
...@@ -9,6 +9,7 @@ import MockServerConfig from './mock_server-config.json'; ...@@ -9,6 +9,7 @@ import MockServerConfig from './mock_server-config.json';
import MockUsers from './mock_users.json'; import MockUsers from './mock_users.json';
import MockSimulations from './mock_simulations.json'; import MockSimulations from './mock_simulations.json';
import MockUserGroups from './mock_user-groups.json'; import MockUserGroups from './mock_user-groups.json';
import MockGDPR from './mock_gdpr.json';
import ImageAI from '../assets/images/Artificial_Intelligence_2.jpg'; import ImageAI from '../assets/images/Artificial_Intelligence_2.jpg';
...@@ -48,7 +49,15 @@ export const handlers = [ ...@@ -48,7 +49,15 @@ export const handlers = [
rest.get(`${config.api.proxy.url}${endpoints.proxy.identity.me.groups.url}`, (req, res, ctx) => { rest.get(`${config.api.proxy.url}${endpoints.proxy.identity.me.groups.url}`, (req, res, ctx) => {
return res(ctx.json(MockUserGroups)); return res(ctx.json(MockUserGroups));
}), }),
rest.get(`${config.api.proxy.url}${endpoints.proxy.identity.url}${endpoints.proxy.identity.gdpr}`,
(req, res, ctx) => {
return res(ctx.json(MockGDPR));
}),
rest.get(`${config.api.proxy.url}${endpoints.proxy.identity.url}/:userID`, (req, res, ctx) => { rest.get(`${config.api.proxy.url}${endpoints.proxy.identity.url}/:userID`, (req, res, ctx) => {
return res(ctx.json(MockUsers[1])); return res(ctx.json(MockUsers[1]));
}) }),
rest.post(`${config.api.proxy.url}${endpoints.proxy.identity.url}${endpoints.proxy.identity.gdpr}`,
(req, res, ctx) => {
return res(ctx.json({"status":"success"}));
})
]; ];
\ No newline at end of file
{
"gdpr": false
}
\ No newline at end of file
...@@ -71,4 +71,12 @@ test('can determine group membership for administrators', async () => { ...@@ -71,4 +71,12 @@ test('can determine group membership for administrators', async () => {
test('can retrieve cluster reservations', async () => { test('can retrieve cluster reservations', async () => {
expect(await NrpUserService.instance.getReservation()).toBe(undefined); expect(await NrpUserService.instance.getReservation()).toBe(undefined);
});
test('can retrieve false gdpr status', async () => {
expect(await NrpUserService.instance.getGdpr()).toEqual({"gdpr": false});
});
test('can set gdpr status', async () => {
expect(await NrpUserService.instance.setGdpr()).toEqual({"status":"success"});
}); });
\ No newline at end of file
...@@ -16,7 +16,8 @@ ...@@ -16,7 +16,8 @@
"groups": { "groups": {
"url": "/identity/me/groups" "url": "/identity/me/groups"
} }
} },
"gdpr": "/gdpr"
}, },
"server": { "server": {
"url": "/server" "url": "/server"
......
...@@ -14,7 +14,7 @@ const PROXY_URL = config.api.proxy.url; ...@@ -14,7 +14,7 @@ const PROXY_URL = config.api.proxy.url;
const IDENTITY_BASE_URL = `${PROXY_URL}${endpoints.proxy.identity.url}`; const IDENTITY_BASE_URL = `${PROXY_URL}${endpoints.proxy.identity.url}`;
const IDENTITY_ME_URL = `${PROXY_URL}${endpoints.proxy.identity.me.url}`; const IDENTITY_ME_URL = `${PROXY_URL}${endpoints.proxy.identity.me.url}`;
const IDENTITY_ME_GROUPS_URL = `${PROXY_URL}${endpoints.proxy.identity.me.groups.url}`; const IDENTITY_ME_GROUPS_URL = `${PROXY_URL}${endpoints.proxy.identity.me.groups.url}`;
const GDPR_URL = `${IDENTITY_BASE_URL}${endpoints.proxy.identity.gdpr}`;
/** /**
* Service managing all data related to NRP users. * Service managing all data related to NRP users.
*/ */
...@@ -112,6 +112,22 @@ class NrpUserService extends HttpService { ...@@ -112,6 +112,22 @@ class NrpUserService extends HttpService {
getReservation() { getReservation() {
return window.sessionStorage.getItem('clusterReservation'); return window.sessionStorage.getItem('clusterReservation');
} }
/**
* Get the GDPR status for current user.
* @returns {promise} Contains the GDPR status for the current user
*/
async getGdpr() {
return await (await this.httpRequestGET(GDPR_URL)).json();
}
/**
* Set the accepted GDPR status for current user.
* @returns {promise} Response for the current user
*/
async setGdpr() {
return await (await this.httpRequestPOST(GDPR_URL)).json();
}
} }
export default NrpUserService; export default NrpUserService;
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment