Skip to content

Commit

Permalink
Update testProcessWithInvalidOrgDiscoveryParam unit test.
Browse files Browse the repository at this point in the history
  • Loading branch information
dhaura committed Aug 21, 2024
1 parent 8016383 commit 3d6b4d9
Showing 1 changed file with 7 additions and 8 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -62,7 +62,6 @@
import java.nio.file.Paths;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.Collections;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
Expand Down Expand Up @@ -469,20 +468,17 @@ public Object[][] getInvalidOrgDiscoveryParams() {

return new Object[][]{
// When the given discovery type is not valid.
{userEmailWithValidDomain, invalidDiscoveryType, new ArrayList<>(Collections.singletonList(
new ConfigProperty(emailDomainDiscoveryType + ENABLE_CONFIG, "true")))},
{userEmailWithValidDomain, invalidDiscoveryType, true},
// When the given discovery type is valid but not enabled.
{userEmailWithValidDomain, emailDomainDiscoveryType, new ArrayList<>(Collections.singletonList(
new ConfigProperty(emailDomainDiscoveryType + ENABLE_CONFIG, "false")))},
{userEmailWithValidDomain, emailDomainDiscoveryType, false},
// When the given email domain of the user email is invalid.
{userEmailWithInvalidDomain, emailDomainDiscoveryType, new ArrayList<>(Collections.singletonList(
new ConfigProperty(emailDomainDiscoveryType + ENABLE_CONFIG, "true")))}
{userEmailWithInvalidDomain, emailDomainDiscoveryType, true}
};
}

@Test(dataProvider = "invalidOrgDiscoveryParams")
public void testProcessWithInvalidOrgDiscoveryParam(String userEmail, String discoveryType,
List<ConfigProperty> configProperties) throws Exception {
boolean isEmailDomainDiscoveryEnabled) throws Exception {

Map<String, String[]> mockParamMap = new HashMap<>();
mockParamMap.put(LOGIN_HINT_PARAMETER, new String[]{userEmail});
Expand All @@ -493,6 +489,9 @@ public void testProcessWithInvalidOrgDiscoveryParam(String userEmail, String dis

when(authenticatorDataHolder.getOrganizationConfigManager().getDiscoveryConfiguration())
.thenReturn(mockDiscoveryConfig);
List<ConfigProperty> configProperties = new ArrayList<>();
configProperties.add(new ConfigProperty(emailDomainDiscoveryType + ENABLE_CONFIG,
String.valueOf(isEmailDomainDiscoveryEnabled)));
when(mockDiscoveryConfig.getConfigProperties()).thenReturn(configProperties);

Map<String, AttributeBasedOrganizationDiscoveryHandler> discoveryHandlers = new HashMap<>();
Expand Down

0 comments on commit 3d6b4d9

Please sign in to comment.