@@ -7,94 +7,86 @@ import { waitForLoadingToFinish } from './navbar/__TESTS__/utils';
77import './navbar/index' ;
88
99export const configurationHandlers = [
10- rest . get (
11- 'http://localhost:3000/.well-known/micro-app-configuration' ,
12- ( req , res , ctx ) => {
13- return res (
14- ctx . json ( {
15- kind : 'MicroAppConfiguration' ,
16- apiVersion : 'ui.scality.com/v1alpha1' ,
17- metadata : {
18- kind : 'metalk8s-ui' ,
19- } ,
20- spec : {
21- remoteEntryPath : '/static/js/remoteEntry.js' ,
22- views : {
23- platform : {
24- path : '/' ,
25- label : {
26- en : 'Platform' ,
27- fr : 'Plateforme' ,
28- } ,
29- module : './FederableApp' ,
30- scope : 'metalk8s' ,
31- } ,
32- alerts : {
33- path : '/alerts' ,
34- label : {
35- en : 'Alerts' ,
36- fr : 'Alertes' ,
37- } ,
38- module : './FederableApp' ,
39- scope : 'metalk8s' ,
40- } ,
41- } ,
42- hooks : {
43- TODO_useAlert_and_platform_lib_hooks : {
44- module : '' ,
45- scope : '' ,
10+ rest . get ( 'http://localhost:3000/.well-known/micro-app-configuration' , ( req , res , ctx ) => {
11+ return res (
12+ ctx . json ( {
13+ kind : 'MicroAppConfiguration' ,
14+ apiVersion : 'ui.scality.com/v1alpha1' ,
15+ metadata : {
16+ kind : 'metalk8s-ui' ,
17+ } ,
18+ spec : {
19+ remoteEntryPath : '/static/js/remoteEntry.js' ,
20+ views : {
21+ platform : {
22+ path : '/' ,
23+ label : {
24+ en : 'Platform' ,
25+ fr : 'Plateforme' ,
4626 } ,
27+ module : './FederableApp' ,
28+ scope : 'metalk8s' ,
4729 } ,
48- components : {
49- TODO_AlertProvider : {
50- module : '' ,
51- scope : '' ,
30+ alerts : {
31+ path : '/alerts' ,
32+ label : {
33+ en : 'Alerts' ,
34+ fr : 'Alertes' ,
5235 } ,
36+ module : './FederableApp' ,
37+ scope : 'metalk8s' ,
5338 } ,
5439 } ,
55- } ) ,
56- ) ;
57- } ,
58- ) ,
59- rest . get (
60- 'http://localhost:3000/.well-known/runtime-app-configuration' ,
61- ( req , res , ctx ) => {
62- return res (
63- ctx . json ( {
64- kind : 'MicroAppRuntimeConfiguration' ,
65- apiVersion : 'ui.scality.com/v1alpha1' ,
66- metadata : {
67- kind : 'metalk8s-ui' ,
68- name : 'metalk8s.eu-west-1' ,
69- } ,
70- spec : {
71- title : 'MetalK8s Platform' ,
72- selfConfiguration : {
73- url : '/api/kubernetes' ,
74- url_salt : '/api/salt' ,
75- url_prometheus : '/api/prometheus' ,
76- url_grafana : '/grafana' ,
77- url_doc : '/docs' ,
78- url_alertmanager : '/api/alertmanager' ,
79- flags : [ ] ,
80- ui_base_path : '/' ,
81- url_support :
82- 'https://github.com/scality/metalk8s/discussions/new' ,
40+ hooks : {
41+ TODO_useAlert_and_platform_lib_hooks : {
42+ module : '' ,
43+ scope : '' ,
8344 } ,
84- auth : {
85- kind : 'OIDC' ,
86- providerUrl : '/oidc' ,
87- redirectUrl : 'http://localhost:3000/' ,
88- clientId : 'metalk8s-ui' ,
89- responseType : 'code' ,
90- scopes :
91- 'openid profile email groups offline_access audience:server:client_id:oidc-auth-client' ,
45+ } ,
46+ components : {
47+ TODO_AlertProvider : {
48+ module : '' ,
49+ scope : '' ,
9250 } ,
9351 } ,
94- } ) ,
95- ) ;
96- } ,
97- ) ,
52+ } ,
53+ } ) ,
54+ ) ;
55+ } ) ,
56+ rest . get ( 'http://localhost:3000/.well-known/runtime-app-configuration' , ( req , res , ctx ) => {
57+ return res (
58+ ctx . json ( {
59+ kind : 'MicroAppRuntimeConfiguration' ,
60+ apiVersion : 'ui.scality.com/v1alpha1' ,
61+ metadata : {
62+ kind : 'metalk8s-ui' ,
63+ name : 'metalk8s.eu-west-1' ,
64+ } ,
65+ spec : {
66+ title : 'MetalK8s Platform' ,
67+ selfConfiguration : {
68+ url : '/api/kubernetes' ,
69+ url_salt : '/api/salt' ,
70+ url_prometheus : '/api/prometheus' ,
71+ url_grafana : '/grafana' ,
72+ url_doc : '/docs' ,
73+ url_alertmanager : '/api/alertmanager' ,
74+ flags : [ ] ,
75+ ui_base_path : '/' ,
76+ url_support : 'https://github.com/scality/metalk8s/discussions/new' ,
77+ } ,
78+ auth : {
79+ kind : 'OIDC' ,
80+ providerUrl : '/oidc' ,
81+ redirectUrl : 'http://localhost:3000/' ,
82+ clientId : 'metalk8s-ui' ,
83+ responseType : 'code' ,
84+ scopes : 'openid profile email groups offline_access audience:server:client_id:oidc-auth-client' ,
85+ } ,
86+ } ,
87+ } ) ,
88+ ) ;
89+ } ) ,
9890 rest . get ( 'http://localhost/shell/deployed-ui-apps.json' , ( req , res , ctx ) => {
9991 return res (
10092 ctx . json ( [
@@ -138,55 +130,32 @@ export const configurationHandlers = [
138130 ) ;
139131 } ) ,
140132 rest . get ( 'http://localhost/static/js/remoteEntry.js' , ( req , res , ctx ) => {
141- return res (
142- ctx . set ( 'Content-Type' , 'application/javascript' ) ,
143- ctx . text ( 'window.metalk8s = {init: () => {}};' ) ,
144- ) ;
133+ return res ( ctx . set ( 'Content-Type' , 'application/javascript' ) , ctx . text ( 'window.metalk8s = {init: () => {}};' ) ) ;
134+ } ) ,
135+ rest . get ( 'http://localhost/oidc/.well-known/openid-configuration' , ( req , res , ctx ) => {
136+ const result = {
137+ issuer : 'https://mocked.ingress/oidc' ,
138+ authorization_endpoint : 'https://mocked.ingress/oidc/auth' ,
139+ token_endpoint : 'https://mocked.ingress/oidc/token' ,
140+ jwks_uri : 'https://mocked.ingress/oidc/keys' ,
141+ userinfo_endpoint : 'https://mocked.ingress/oidc/userinfo' ,
142+ response_types_supported : [ 'code' , 'id_token' , 'token' ] ,
143+ subject_types_supported : [ 'public' ] ,
144+ id_token_signing_alg_values_supported : [ 'RS256' ] ,
145+ scopes_supported : [ 'openid' , 'email' , 'groups' , 'profile' , 'offline_access' ] ,
146+ token_endpoint_auth_methods_supported : [ 'client_secret_basic' ] ,
147+ claims_supported : [ 'aud' , 'email' , 'email_verified' , 'exp' , 'iat' , 'iss' , 'locale' , 'name' , 'sub' ] ,
148+ } ;
149+ return res ( ctx . json ( result ) ) ;
145150 } ) ,
146- rest . get (
147- 'http://localhost/oidc/.well-known/openid-configuration' ,
148- ( req , res , ctx ) => {
149- const result = {
150- issuer : 'https://mocked.ingress/oidc' ,
151- authorization_endpoint : 'https://mocked.ingress/oidc/auth' ,
152- token_endpoint : 'https://mocked.ingress/oidc/token' ,
153- jwks_uri : 'https://mocked.ingress/oidc/keys' ,
154- userinfo_endpoint : 'https://mocked.ingress/oidc/userinfo' ,
155- response_types_supported : [ 'code' , 'id_token' , 'token' ] ,
156- subject_types_supported : [ 'public' ] ,
157- id_token_signing_alg_values_supported : [ 'RS256' ] ,
158- scopes_supported : [
159- 'openid' ,
160- 'email' ,
161- 'groups' ,
162- 'profile' ,
163- 'offline_access' ,
164- ] ,
165- token_endpoint_auth_methods_supported : [ 'client_secret_basic' ] ,
166- claims_supported : [
167- 'aud' ,
168- 'email' ,
169- 'email_verified' ,
170- 'exp' ,
171- 'iat' ,
172- 'iss' ,
173- 'locale' ,
174- 'name' ,
175- 'sub' ,
176- ] ,
177- } ;
178- return res ( ctx . json ( result ) ) ;
179- } ,
180- ) ,
181151] ;
182152const server = setupServer ( ...configurationHandlers ) ;
183153
184154const mockOIDCProvider = ( ) => {
185155 // This is a hack to workarround the following issue : MSW return lower cased content-type header,
186156 // oidc-client is internally using XMLHttpRequest to perform queries and retrieve response header Content-Type using 'XMLHttpRequest.prototype.getResponseHeader'.
187157 // XMLHttpRequest.prototype.getResponseHeader is case sensitive and hence when receiving a response with header content-type it is not mapping it to Content-Type
188- const caseSensitiveGetResponseHeader =
189- XMLHttpRequest . prototype . getResponseHeader ;
158+ const caseSensitiveGetResponseHeader = XMLHttpRequest . prototype . getResponseHeader ;
190159
191160 XMLHttpRequest . prototype . getResponseHeader = function ( header ) {
192161 if ( header === 'Content-Type' ) {
@@ -242,9 +211,7 @@ describe('FederatedApp', () => {
242211 //S
243212 render ( < App /> ) ;
244213 //E
245- await waitFor ( ( ) =>
246- expect ( screen . getByRole ( 'navigation' ) ) . toBeInTheDocument ( ) ,
247- ) ;
214+ await waitFor ( ( ) => expect ( screen . getByRole ( 'navigation' ) ) . toBeInTheDocument ( ) ) ;
248215 //V
249216 let navbar = screen . getByRole ( 'navigation' ) ;
250217 expect ( navbar ) . toBeInTheDocument ( ) ;
@@ -253,9 +220,7 @@ describe('FederatedApp', () => {
253220 ( ) => {
254221 navbar = screen . getByRole ( 'navigation' ) ;
255222
256- return expect (
257- within ( navbar ) . getByText ( / P l a t f o r m / i) ,
258- ) . toBeInTheDocument ( ) ;
223+ return expect ( within ( navbar ) . getByText ( / P l a t f o r m / i) ) . toBeInTheDocument ( ) ;
259224 } ,
260225 { timeout : 5000 } ,
261226 ) ;
0 commit comments