Search in sources :

Example 1 with PatchClientRegistrationSettings

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());
}
Also used : AccountSettings(io.gravitee.am.model.account.AccountSettings) SCIMSettings(io.gravitee.am.model.scim.SCIMSettings) PatchOIDCSettings(io.gravitee.am.service.model.openid.PatchOIDCSettings) LoginSettings(io.gravitee.am.model.login.LoginSettings) PatchClientRegistrationSettings(io.gravitee.am.service.model.openid.PatchClientRegistrationSettings) UMASettings(io.gravitee.am.model.uma.UMASettings) Test(org.junit.Test)

Example 2 with PatchClientRegistrationSettings

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());
}
Also used : PatchOIDCSettings(io.gravitee.am.service.model.openid.PatchOIDCSettings) Domain(io.gravitee.am.model.Domain) PatchClientRegistrationSettings(io.gravitee.am.service.model.openid.PatchClientRegistrationSettings) Test(org.junit.Test)

Example 3 with PatchClientRegistrationSettings

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);
}
Also used : PatchOIDCSettings(io.gravitee.am.service.model.openid.PatchOIDCSettings) PatchClientRegistrationSettings(io.gravitee.am.service.model.openid.PatchClientRegistrationSettings) PatchDomain(io.gravitee.am.service.model.PatchDomain)

Aggregations

PatchClientRegistrationSettings (io.gravitee.am.service.model.openid.PatchClientRegistrationSettings)3 PatchOIDCSettings (io.gravitee.am.service.model.openid.PatchOIDCSettings)3 Test (org.junit.Test)2 Domain (io.gravitee.am.model.Domain)1 AccountSettings (io.gravitee.am.model.account.AccountSettings)1 LoginSettings (io.gravitee.am.model.login.LoginSettings)1 SCIMSettings (io.gravitee.am.model.scim.SCIMSettings)1 UMASettings (io.gravitee.am.model.uma.UMASettings)1 PatchDomain (io.gravitee.am.service.model.PatchDomain)1