update default req values based on vendor (#578)

This commit is contained in:
mfrances17 2021-05-14 14:12:27 -04:00 committed by GitHub
parent 40d004cdf1
commit bd6f8a9c78
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
2 changed files with 59 additions and 2 deletions

View file

@ -31,6 +31,58 @@ export const LdapSettingsGeneral = ({
const [isVendorDropdownOpen, setIsVendorDropdownOpen] = useState(false);
const setVendorDefaultValues = () => {
switch (form.getValues("config.vendor[0]")) {
case "ad":
form.setValue("config.usernameLDAPAttribute[0]", "cn");
form.setValue("config.rdnLDAPAttribute[0]", "cn");
form.setValue("config.uuidLDAPAttribute[0]", "objectGUID");
form.setValue(
"config.userObjectClasses[0]",
"person, organizationalPerson, user"
);
break;
case "rhds":
form.setValue("config.usernameLDAPAttribute[0]", "uid");
form.setValue("config.rdnLDAPAttribute[0]", "uid");
form.setValue("config.uuidLDAPAttribute[0]", "nsuniqueid");
form.setValue(
"config.userObjectClasses[0]",
"inetOrgPerson, organizationalPerson"
);
break;
case "tivoli":
form.setValue("config.usernameLDAPAttribute[0]", "uid");
form.setValue("config.rdnLDAPAttribute[0]", "uid");
form.setValue("config.uuidLDAPAttribute[0]", "uniqueidentifier");
form.setValue(
"config.userObjectClasses[0]",
"inetOrgPerson, organizationalPerson"
);
break;
case "edirectory":
form.setValue("config.usernameLDAPAttribute[0]", "uid");
form.setValue("config.rdnLDAPAttribute[0]", "uid");
form.setValue("config.uuidLDAPAttribute[0]", "guid");
form.setValue(
"config.userObjectClasses[0]",
"inetOrgPerson, organizationalPerson"
);
break;
case "other":
form.setValue("config.usernameLDAPAttribute[0]", "uid");
form.setValue("config.rdnLDAPAttribute[0]", "uid");
form.setValue("config.uuidLDAPAttribute[0]", "entryUUID");
form.setValue(
"config.userObjectClasses[0]",
"inetOrgPerson, organizationalPerson"
);
break;
default:
return "";
}
};
return (
<>
{showSectionHeading && (
@ -110,7 +162,7 @@ export const LdapSettingsGeneral = ({
>
<Controller
name="config.vendor[0]"
defaultValue=""
defaultValue="ad"
control={form.control}
render={({ onChange, value }) => (
<Select
@ -121,10 +173,10 @@ export const LdapSettingsGeneral = ({
onSelect={(_, value) => {
onChange(value as string);
setIsVendorDropdownOpen(false);
setVendorDefaultValues();
}}
selections={value}
variant={SelectVariant.single}
// data-testid="ldap-vendor"
>
<SelectOption key={0} value="ad" isPlaceholder>
Active Directory

View file

@ -96,6 +96,7 @@ export const LdapSettingsSearching = ({
<TextInput
isRequired
type="text"
defaultValue=""
id="kc-console-users-dn"
data-testid="ldap-users-dn"
name="config.usersDn[0]"
@ -129,6 +130,7 @@ export const LdapSettingsSearching = ({
<TextInput
isRequired
type="text"
defaultValue="cn"
id="kc-username-ldap-attribute"
data-testid="ldap-username-attribute"
name="config.usernameLDAPAttribute[0]"
@ -162,6 +164,7 @@ export const LdapSettingsSearching = ({
<TextInput
isRequired
type="text"
defaultValue="cn"
id="kc-rdn-ldap-attribute"
data-testid="ldap-rdn-attribute"
name="config.rdnLDAPAttribute[0]"
@ -195,6 +198,7 @@ export const LdapSettingsSearching = ({
<TextInput
isRequired
type="text"
defaultValue="objectGUID"
id="kc-uuid-ldap-attribute"
data-testid="ldap-uuid-attribute"
name="config.uuidLDAPAttribute[0]"
@ -228,6 +232,7 @@ export const LdapSettingsSearching = ({
<TextInput
isRequired
type="text"
defaultValue="person, organizationalPerson, user"
id="kc-user-object-classes"
data-testid="ldap-user-object-classes"
name="config.userObjectClasses[0]"