use of io.gravitee.am.service.model.openid.PatchClientRegistrationSettings in project gravitee-access-management by gravitee-io.
the class PatchDomainTest method testGetRequiredPermissions.
@Test
public void testGetRequiredPermissions() {
PatchDomain patchDomain = new PatchDomain();
assertEquals(Collections.emptySet(), patchDomain.getRequiredPermissions());
patchDomain.setName(Optional.of("patchName"));
assertEquals(new HashSet<>(Arrays.asList(Permission.DOMAIN_SETTINGS)), patchDomain.getRequiredPermissions());
patchDomain = new PatchDomain();
patchDomain.setDescription(Optional.of("patchDescription"));
assertEquals(new HashSet<>(Arrays.asList(Permission.DOMAIN_SETTINGS)), patchDomain.getRequiredPermissions());
patchDomain = new PatchDomain();
patchDomain.setEnabled(Optional.of(true));
assertEquals(new HashSet<>(Arrays.asList(Permission.DOMAIN_SETTINGS)), patchDomain.getRequiredPermissions());
patchDomain = new PatchDomain();
patchDomain.setPath(Optional.of("patchPath"));
assertEquals(new HashSet<>(Arrays.asList(Permission.DOMAIN_SETTINGS)), patchDomain.getRequiredPermissions());
patchDomain = new PatchDomain();
patchDomain.setLoginSettings(Optional.of(new LoginSettings()));
assertEquals(new HashSet<>(Arrays.asList(Permission.DOMAIN_SETTINGS)), patchDomain.getRequiredPermissions());
patchDomain = new PatchDomain();
patchDomain.setAccountSettings(Optional.of(new AccountSettings()));
assertEquals(new HashSet<>(Arrays.asList(Permission.DOMAIN_SETTINGS)), patchDomain.getRequiredPermissions());
patchDomain = new PatchDomain();
patchDomain.setTags(Optional.of(Collections.singleton("patchTag")));
assertEquals(new HashSet<>(Arrays.asList(Permission.DOMAIN_SETTINGS)), patchDomain.getRequiredPermissions());
patchDomain = new PatchDomain();
PatchOIDCSettings oidcSettings = new PatchOIDCSettings();
patchDomain.setOidc(Optional.of(oidcSettings));
assertEquals(Collections.emptySet(), patchDomain.getRequiredPermissions());
oidcSettings.setClientRegistrationSettings(Optional.of(new PatchClientRegistrationSettings()));
oidcSettings.setRedirectUriStrictMatching(Optional.of(true));
assertEquals(new HashSet<>(Arrays.asList(Permission.DOMAIN_OPENID)), patchDomain.getRequiredPermissions());
patchDomain = new PatchDomain();
patchDomain.setScim(Optional.of(new SCIMSettings()));
assertEquals(new HashSet<>(Arrays.asList(Permission.DOMAIN_SCIM)), patchDomain.getRequiredPermissions());
patchDomain = new PatchDomain();
patchDomain.setUma(Optional.of(new UMASettings()));
assertEquals(new HashSet<>(Arrays.asList(Permission.DOMAIN_UMA)), patchDomain.getRequiredPermissions());
// Check multiple permissions.
patchDomain = new PatchDomain();
patchDomain.setPath(Optional.of("patchPath"));
patchDomain.setOidc(Optional.of(oidcSettings));
patchDomain.setScim(Optional.of(new SCIMSettings()));
assertEquals(new HashSet<>(Arrays.asList(Permission.DOMAIN_SETTINGS, Permission.DOMAIN_OPENID, Permission.DOMAIN_SCIM)), patchDomain.getRequiredPermissions());
}
use of io.gravitee.am.service.model.openid.PatchClientRegistrationSettings in project gravitee-access-management by gravitee-io.
the class PatchDomainTest method testPatchWithEnabledOidc.
@Test
public void testPatchWithEnabledOidc() {
// Build patcher
PatchClientRegistrationSettings dcrPatcher = new PatchClientRegistrationSettings();
dcrPatcher.setDynamicClientRegistrationEnabled(Optional.of(true));
PatchOIDCSettings oidcPatcher = new PatchOIDCSettings();
oidcPatcher.setClientRegistrationSettings(Optional.of(dcrPatcher));
PatchDomain patch = new PatchDomain();
patch.setOidc(Optional.of(oidcPatcher));
// Build object to patch with DCR enabled
Domain toPatch = new Domain();
toPatch.setOidc(OIDCSettings.defaultSettings());
// apply patch
Domain result = patch.patch(toPatch);
// check.
assertNotNull("was expecting a domain", result);
assertNotNull(result.getOidc());
assertNotNull(result.getOidc().getClientRegistrationSettings());
assertTrue("should have been enabled", result.getOidc().getClientRegistrationSettings().isDynamicClientRegistrationEnabled());
}
use of io.gravitee.am.service.model.openid.PatchClientRegistrationSettings in project gravitee-access-management by gravitee-io.
the class DomainUpgrader method upgradeDomain.
private Single<Domain> upgradeDomain(Domain domain) {
if (domain.getOidc() != null) {
return Single.just(domain);
}
PatchClientRegistrationSettings clientRegistrationPatch = new PatchClientRegistrationSettings();
clientRegistrationPatch.setDynamicClientRegistrationEnabled(Optional.of(false));
clientRegistrationPatch.setOpenDynamicClientRegistrationEnabled(Optional.of(false));
clientRegistrationPatch.setAllowHttpSchemeRedirectUri(Optional.of(true));
clientRegistrationPatch.setAllowLocalhostRedirectUri(Optional.of(true));
clientRegistrationPatch.setAllowWildCardRedirectUri(Optional.of(true));
PatchOIDCSettings oidcPatch = new PatchOIDCSettings();
oidcPatch.setClientRegistrationSettings(Optional.of(clientRegistrationPatch));
PatchDomain patchDomain = new PatchDomain();
patchDomain.setOidc(Optional.of(oidcPatch));
return domainService.patch(domain.getId(), patchDomain);
}
Aggregations