@eeacms/volto-eea-website-policy 2.2.2 → 2.2.3
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.md +16 -0
- package/package.json +1 -1
- package/src/index.js +0 -14
- package/src/components/AzureLogin/Login.jsx +0 -103
- package/src/components/AzureLogin/Login.test.jsx +0 -179
package/CHANGELOG.md
CHANGED
|
@@ -4,6 +4,22 @@ All notable changes to this project will be documented in this file. Dates are d
|
|
|
4
4
|
|
|
5
5
|
Generated by [`auto-changelog`](https://github.com/CookPete/auto-changelog).
|
|
6
6
|
|
|
7
|
+
### [2.2.3](https://github.com/eea/volto-eea-website-policy/compare/2.2.2...2.2.3) - 19 September 2024
|
|
8
|
+
|
|
9
|
+
#### :rocket: New Features
|
|
10
|
+
|
|
11
|
+
- feat: Switch to Microsoft Azure Login - refs #272383 [Alin Voinea - [`95ea03e`](https://github.com/eea/volto-eea-website-policy/commit/95ea03ee01102b4c2bd3f2b642dadd4fe6bf59ee)]
|
|
12
|
+
|
|
13
|
+
#### :hammer_and_wrench: Others
|
|
14
|
+
|
|
15
|
+
- Add Sonarqube tag using eea-website-frontend addons list [EEA Jenkins - [`74f7cb1`](https://github.com/eea/volto-eea-website-policy/commit/74f7cb1b4f7dd3232f9a6c0ad35e50bc86b64e60)]
|
|
16
|
+
- Add Sonarqube tag using eea-website-frontend addons list [EEA Jenkins - [`c8978f0`](https://github.com/eea/volto-eea-website-policy/commit/c8978f02c53c38d88b654544051aa28ba5ccd05c)]
|
|
17
|
+
- Add Sonarqube tag using eea-website-frontend addons list [EEA Jenkins - [`fb31e28`](https://github.com/eea/volto-eea-website-policy/commit/fb31e285959820147aa07e827cea25589d27be63)]
|
|
18
|
+
- Add Sonarqube tag using eea-website-frontend addons list [EEA Jenkins - [`3b0c059`](https://github.com/eea/volto-eea-website-policy/commit/3b0c059772a0ca32f398c17b6ddb74be8e2f0060)]
|
|
19
|
+
- Add Sonarqube tag using eea-website-frontend addons list [EEA Jenkins - [`25d16e4`](https://github.com/eea/volto-eea-website-policy/commit/25d16e401b4d2685a201a1b3a9830916ed4c5b80)]
|
|
20
|
+
- Add Sonarqube tag using eea-website-frontend addons list [EEA Jenkins - [`d4fdfaf`](https://github.com/eea/volto-eea-website-policy/commit/d4fdfaf94d8fa962906cf713c865202bbff1ff60)]
|
|
21
|
+
- Add Sonarqube tag using eea-website-frontend addons list [EEA Jenkins - [`742d72c`](https://github.com/eea/volto-eea-website-policy/commit/742d72c1f020fc7a2ed553dc739be54daeb2283d)]
|
|
22
|
+
- Add Sonarqube tag using eea-website-frontend addons list [EEA Jenkins - [`e3dc5ef`](https://github.com/eea/volto-eea-website-policy/commit/e3dc5ef5da18aa64091388d8779dcc2819e5ad80)]
|
|
7
23
|
### [2.2.2](https://github.com/eea/volto-eea-website-policy/compare/2.2.1...2.2.2) - 28 August 2024
|
|
8
24
|
|
|
9
25
|
#### :bug: Bug Fixes
|
package/package.json
CHANGED
package/src/index.js
CHANGED
|
@@ -2,9 +2,6 @@ import { runtimeConfig } from '@plone/volto/runtime_config';
|
|
|
2
2
|
import installContextNavigationBlock from '@eeacms/volto-eea-website-policy/components/Blocks/ContextNavigation';
|
|
3
3
|
import { appendGroup } from './helpers';
|
|
4
4
|
import { FrequencyOfDissemination } from '@eeacms/volto-eea-website-policy/components/Widgets/FrequencyOfDissemination';
|
|
5
|
-
import Login from '@eeacms/volto-eea-website-policy/components/AzureLogin/Login.jsx';
|
|
6
|
-
import Logout from '@plone-collective/volto-authomatic/components/Logout/Logout.jsx';
|
|
7
|
-
import { Login as VoltoLogin } from '@plone/volto/components';
|
|
8
5
|
|
|
9
6
|
const restrictedBlocks = [
|
|
10
7
|
'imagecards',
|
|
@@ -55,17 +52,6 @@ const applyConfig = (config) => {
|
|
|
55
52
|
},
|
|
56
53
|
];
|
|
57
54
|
|
|
58
|
-
// #258877 Make Azure AD login to be at route /azure_login and EIONET LDAP login to be at /login
|
|
59
|
-
config.addonRoutes = [
|
|
60
|
-
{ path: '/azure_login', component: Login },
|
|
61
|
-
{ path: '/**/azure_login', component: Login },
|
|
62
|
-
{ path: '/login', component: VoltoLogin },
|
|
63
|
-
{ path: '/**/login', component: VoltoLogin },
|
|
64
|
-
{ path: '/logout', component: Logout },
|
|
65
|
-
{ path: '/**/logout', component: Logout },
|
|
66
|
-
...(config.addonRoutes || []),
|
|
67
|
-
];
|
|
68
|
-
|
|
69
55
|
// #160689 Redirect contact-form to contact-us
|
|
70
56
|
config.settings.contactForm = '/en/about/contact-us';
|
|
71
57
|
|
|
@@ -1,103 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* Login container.
|
|
3
|
-
* @module components/Login/Login
|
|
4
|
-
*/
|
|
5
|
-
import React, { useEffect, useState } from 'react';
|
|
6
|
-
import {
|
|
7
|
-
authomaticRedirect,
|
|
8
|
-
listAuthOptions,
|
|
9
|
-
oidcRedirect,
|
|
10
|
-
} from '@plone-collective/volto-authomatic/actions';
|
|
11
|
-
import { injectIntl } from 'react-intl';
|
|
12
|
-
import { useSelector, useDispatch } from 'react-redux';
|
|
13
|
-
import { useLocation } from 'react-router-dom';
|
|
14
|
-
import LoginForm from '@plone-collective/volto-authomatic/components/Login/LoginForm';
|
|
15
|
-
import qs from 'query-string';
|
|
16
|
-
import { useCookies } from 'react-cookie';
|
|
17
|
-
|
|
18
|
-
/**
|
|
19
|
-
* Get retur url function.
|
|
20
|
-
* @function getReturnUrl
|
|
21
|
-
* @param {Object} location Location object.
|
|
22
|
-
* @returns {string} Return url.
|
|
23
|
-
*/
|
|
24
|
-
function getReturnUrl(location) {
|
|
25
|
-
return `${
|
|
26
|
-
qs.parse(location.search).return_url ||
|
|
27
|
-
(location.pathname === '/azure_login'
|
|
28
|
-
? '/'
|
|
29
|
-
: location.pathname.replace('/azure_login', ''))
|
|
30
|
-
}`;
|
|
31
|
-
}
|
|
32
|
-
|
|
33
|
-
/**
|
|
34
|
-
* Login function.
|
|
35
|
-
* @function Login
|
|
36
|
-
* @returns {JSX.Element} Markup of the Login page.
|
|
37
|
-
*/
|
|
38
|
-
function Login({ intl }) {
|
|
39
|
-
const dispatch = useDispatch();
|
|
40
|
-
const [startedOAuth, setStartedOAuth] = useState(false);
|
|
41
|
-
const [startedOIDC, setStartedOIDC] = useState(false);
|
|
42
|
-
const loading = useSelector((state) => state.authOptions.loading);
|
|
43
|
-
const options = useSelector((state) => state.authOptions.options);
|
|
44
|
-
const loginOAuthValues = useSelector((state) => state.authomaticRedirect);
|
|
45
|
-
const loginOIDCValues = useSelector((state) => state.oidcRedirect);
|
|
46
|
-
const location = useLocation();
|
|
47
|
-
const [, setCookie] = useCookies();
|
|
48
|
-
|
|
49
|
-
useEffect(() => {
|
|
50
|
-
dispatch(listAuthOptions());
|
|
51
|
-
}, [dispatch]);
|
|
52
|
-
|
|
53
|
-
useEffect(() => {
|
|
54
|
-
const next_url = loginOAuthValues.next_url;
|
|
55
|
-
const session = loginOAuthValues.session;
|
|
56
|
-
if (next_url && session && startedOAuth) {
|
|
57
|
-
setStartedOAuth(false);
|
|
58
|
-
// Give time to save state to localstorage
|
|
59
|
-
setTimeout(function () {
|
|
60
|
-
window.location.href = next_url;
|
|
61
|
-
}, 500);
|
|
62
|
-
}
|
|
63
|
-
}, [startedOAuth, loginOAuthValues]);
|
|
64
|
-
|
|
65
|
-
const onSelectProvider = (provider) => {
|
|
66
|
-
setStartedOAuth(true);
|
|
67
|
-
setCookie('return_url', getReturnUrl(location), { path: '/' });
|
|
68
|
-
dispatch(authomaticRedirect(provider.id));
|
|
69
|
-
};
|
|
70
|
-
|
|
71
|
-
useEffect(() => {
|
|
72
|
-
const next_url = loginOIDCValues.next_url;
|
|
73
|
-
if (next_url && startedOIDC) {
|
|
74
|
-
setStartedOIDC(false);
|
|
75
|
-
// Give time to save state to localstorage
|
|
76
|
-
setTimeout(function () {
|
|
77
|
-
window.location.href = next_url;
|
|
78
|
-
}, 500);
|
|
79
|
-
}
|
|
80
|
-
}, [startedOIDC, loginOIDCValues]);
|
|
81
|
-
|
|
82
|
-
useEffect(() => {
|
|
83
|
-
if (
|
|
84
|
-
options !== undefined &&
|
|
85
|
-
options.length === 1 &&
|
|
86
|
-
options[0].id === 'oidc'
|
|
87
|
-
) {
|
|
88
|
-
setStartedOIDC(true);
|
|
89
|
-
dispatch(oidcRedirect('oidc'));
|
|
90
|
-
}
|
|
91
|
-
}, [options, dispatch]);
|
|
92
|
-
|
|
93
|
-
return (
|
|
94
|
-
<LoginForm
|
|
95
|
-
loading={loading}
|
|
96
|
-
providers={options}
|
|
97
|
-
action={'login'}
|
|
98
|
-
onSelectProvider={onSelectProvider}
|
|
99
|
-
/>
|
|
100
|
-
);
|
|
101
|
-
}
|
|
102
|
-
|
|
103
|
-
export default injectIntl(Login);
|
|
@@ -1,179 +0,0 @@
|
|
|
1
|
-
import { render, screen, fireEvent } from '@testing-library/react';
|
|
2
|
-
import { Provider } from 'react-intl-redux';
|
|
3
|
-
import configureStore from 'redux-mock-store';
|
|
4
|
-
import { useLocation } from 'react-router-dom';
|
|
5
|
-
import { listAuthOptions } from '@plone-collective/volto-authomatic/actions';
|
|
6
|
-
import '@testing-library/jest-dom/extend-expect';
|
|
7
|
-
|
|
8
|
-
import Login from './Login';
|
|
9
|
-
|
|
10
|
-
const mockStore = configureStore();
|
|
11
|
-
|
|
12
|
-
jest.mock('react-router-dom', () => ({
|
|
13
|
-
...jest.requireActual('react-router-dom'),
|
|
14
|
-
useLocation: jest.fn(),
|
|
15
|
-
}));
|
|
16
|
-
|
|
17
|
-
jest.useFakeTimers();
|
|
18
|
-
|
|
19
|
-
describe('Login component', () => {
|
|
20
|
-
beforeEach(() => {
|
|
21
|
-
useLocation.mockReturnValue({ pathname: '/azure_login' });
|
|
22
|
-
});
|
|
23
|
-
|
|
24
|
-
it('renders correctly with loading state', () => {
|
|
25
|
-
const store = mockStore({
|
|
26
|
-
authOptions: { loading: true, options: [] },
|
|
27
|
-
authomaticRedirect: {
|
|
28
|
-
next_url: '/dashboard',
|
|
29
|
-
session: true,
|
|
30
|
-
},
|
|
31
|
-
oidcRedirect: {
|
|
32
|
-
next_url: '/dashboard',
|
|
33
|
-
session: true,
|
|
34
|
-
},
|
|
35
|
-
intl: {
|
|
36
|
-
locale: 'en',
|
|
37
|
-
messages: {},
|
|
38
|
-
formatMessage: jest.fn(),
|
|
39
|
-
},
|
|
40
|
-
});
|
|
41
|
-
|
|
42
|
-
render(
|
|
43
|
-
<Provider store={store}>
|
|
44
|
-
<Login />
|
|
45
|
-
</Provider>,
|
|
46
|
-
);
|
|
47
|
-
|
|
48
|
-
expect(screen.getByText('Loading')).toBeInTheDocument();
|
|
49
|
-
});
|
|
50
|
-
|
|
51
|
-
it('dispatches listAuthOptions on mount', () => {
|
|
52
|
-
const store = mockStore({
|
|
53
|
-
authOptions: { loading: true, options: [] },
|
|
54
|
-
authomaticRedirect: {
|
|
55
|
-
next_url: '/dashboard',
|
|
56
|
-
session: true,
|
|
57
|
-
},
|
|
58
|
-
oidcRedirect: {
|
|
59
|
-
next_url: '/dashboard',
|
|
60
|
-
session: true,
|
|
61
|
-
},
|
|
62
|
-
intl: {
|
|
63
|
-
locale: 'en',
|
|
64
|
-
messages: {},
|
|
65
|
-
formatMessage: jest.fn(),
|
|
66
|
-
},
|
|
67
|
-
});
|
|
68
|
-
const dispatch = jest.spyOn(store, 'dispatch');
|
|
69
|
-
|
|
70
|
-
render(
|
|
71
|
-
<Provider store={store}>
|
|
72
|
-
<Login />
|
|
73
|
-
</Provider>,
|
|
74
|
-
);
|
|
75
|
-
|
|
76
|
-
expect(dispatch).toHaveBeenCalledWith(listAuthOptions());
|
|
77
|
-
});
|
|
78
|
-
|
|
79
|
-
it('renders providers from the store', () => {
|
|
80
|
-
const store = mockStore({
|
|
81
|
-
authOptions: {
|
|
82
|
-
loading: false,
|
|
83
|
-
options: [
|
|
84
|
-
{ id: 'facebook', title: 'Facebook' },
|
|
85
|
-
{ id: 'twitter', title: 'Twitter' },
|
|
86
|
-
],
|
|
87
|
-
},
|
|
88
|
-
authomaticRedirect: {
|
|
89
|
-
next_url: '/dashboard',
|
|
90
|
-
session: true,
|
|
91
|
-
},
|
|
92
|
-
oidcRedirect: {
|
|
93
|
-
next_url: '/dashboard',
|
|
94
|
-
session: true,
|
|
95
|
-
},
|
|
96
|
-
intl: {
|
|
97
|
-
locale: 'en',
|
|
98
|
-
messages: {},
|
|
99
|
-
formatMessage: jest.fn(),
|
|
100
|
-
},
|
|
101
|
-
});
|
|
102
|
-
|
|
103
|
-
render(
|
|
104
|
-
<Provider store={store}>
|
|
105
|
-
<Login />
|
|
106
|
-
</Provider>,
|
|
107
|
-
);
|
|
108
|
-
|
|
109
|
-
// Assert that the provider buttons are present
|
|
110
|
-
expect(
|
|
111
|
-
screen.getByRole('button', { name: /Facebook/i }),
|
|
112
|
-
).toBeInTheDocument();
|
|
113
|
-
expect(
|
|
114
|
-
screen.getByRole('button', { name: /Twitter/i }),
|
|
115
|
-
).toBeInTheDocument();
|
|
116
|
-
|
|
117
|
-
fireEvent.click(screen.getByRole('button', { name: /Facebook/i }));
|
|
118
|
-
});
|
|
119
|
-
|
|
120
|
-
it('clicks on GitHub button for OAuth login', () => {
|
|
121
|
-
useLocation.mockReturnValue({ pathname: '/login' });
|
|
122
|
-
|
|
123
|
-
const store = mockStore({
|
|
124
|
-
authOptions: {
|
|
125
|
-
loading: false,
|
|
126
|
-
options: [{ id: 'github', title: 'GitHub' }],
|
|
127
|
-
},
|
|
128
|
-
authomaticRedirect: { next_url: '/dashboard', session: true },
|
|
129
|
-
oidcRedirect: {
|
|
130
|
-
next_url: '/dashboard',
|
|
131
|
-
session: true,
|
|
132
|
-
},
|
|
133
|
-
intl: {
|
|
134
|
-
locale: 'en',
|
|
135
|
-
messages: {},
|
|
136
|
-
formatMessage: jest.fn(),
|
|
137
|
-
},
|
|
138
|
-
});
|
|
139
|
-
|
|
140
|
-
render(
|
|
141
|
-
<Provider store={store}>
|
|
142
|
-
<Login />
|
|
143
|
-
</Provider>,
|
|
144
|
-
);
|
|
145
|
-
|
|
146
|
-
fireEvent.click(screen.getByRole('button', { name: /GitHub/i }));
|
|
147
|
-
});
|
|
148
|
-
|
|
149
|
-
it('renders correctly with loading state', () => {
|
|
150
|
-
const store = mockStore({
|
|
151
|
-
authOptions: {
|
|
152
|
-
loading: true,
|
|
153
|
-
options: [{ id: 'oidc', title: 'OIDC' }],
|
|
154
|
-
},
|
|
155
|
-
authomaticRedirect: {
|
|
156
|
-
next_url: '/dashboard',
|
|
157
|
-
session: true,
|
|
158
|
-
},
|
|
159
|
-
oidcRedirect: {
|
|
160
|
-
next_url: '/dashboard',
|
|
161
|
-
session: true,
|
|
162
|
-
},
|
|
163
|
-
intl: {
|
|
164
|
-
locale: 'en',
|
|
165
|
-
messages: {},
|
|
166
|
-
formatMessage: jest.fn(),
|
|
167
|
-
},
|
|
168
|
-
});
|
|
169
|
-
|
|
170
|
-
render(
|
|
171
|
-
<Provider store={store}>
|
|
172
|
-
<Login />
|
|
173
|
-
</Provider>,
|
|
174
|
-
);
|
|
175
|
-
|
|
176
|
-
expect(screen.getByText('Loading')).toBeInTheDocument();
|
|
177
|
-
jest.advanceTimersByTime(500);
|
|
178
|
-
});
|
|
179
|
-
});
|