(providerName)
| 234 | } |
| 235 | |
| 236 | const validateAndTest = async (providerName) => { |
| 237 | let validationErrors = [] |
| 238 | switch (providerName) { |
| 239 | case 'Azure': |
| 240 | validateAzureFields(validationErrors) |
| 241 | break |
| 242 | case 'Google': |
| 243 | validateGoogleFields(validationErrors) |
| 244 | break |
| 245 | case 'Auth0': |
| 246 | validateAuth0Fields(validationErrors) |
| 247 | break |
| 248 | case 'Gtihub': |
| 249 | validateGithubFields(validationErrors) |
| 250 | break |
| 251 | } |
| 252 | if (validationErrors.length > 0) { |
| 253 | setAuthErrors(validationErrors) |
| 254 | return |
| 255 | } |
| 256 | const body = constructRequestBody() |
| 257 | // depending on the tab value, we need to set the provider name and remove the other provider |
| 258 | body.providers = [body.providers[tabValue]] |
| 259 | body.providerName = providerName.toLowerCase() |
| 260 | setLoading(true) |
| 261 | try { |
| 262 | const updateResponse = await loginMethodApi.testLoginMethod(body) |
| 263 | setAuthErrors([]) |
| 264 | setLoading(false) |
| 265 | if (updateResponse.data?.message) { |
| 266 | enqueueSnackbar({ |
| 267 | message: `${getSelectedProviderName()} SSO Configuration is Valid!`, |
| 268 | options: { |
| 269 | key: new Date().getTime() + Math.random(), |
| 270 | variant: 'success', |
| 271 | action: (key) => ( |
| 272 | <Button style={{ color: 'white' }} onClick={() => closeSnackbar(key)}> |
| 273 | <IconX /> |
| 274 | </Button> |
| 275 | ) |
| 276 | } |
| 277 | }) |
| 278 | } |
| 279 | if (updateResponse.data.error) { |
| 280 | enqueueSnackbar({ |
| 281 | message: `${updateResponse.data.error}`, |
| 282 | options: { |
| 283 | key: new Date().getTime() + Math.random(), |
| 284 | variant: 'error', |
| 285 | persist: true, |
| 286 | action: (key) => ( |
| 287 | <Button style={{ color: 'white' }} onClick={() => closeSnackbar(key)}> |
| 288 | <IconX /> |
| 289 | </Button> |
| 290 | ) |
| 291 | } |
| 292 | }) |
| 293 | } |
no test coverage detected