ExternalPrincipalConfiguration extends ConfigurationBase implements PrincipalConfiguration { @NotNull @Override public List<? extends ValidatorProvider> getValidators(@NotNull String workspaceName, @NotNull Set<Principal> principals, @NotNull MoveTracker moveTracker) { return Collections.singletonList(new ExternalIdentityValidatorProvider(principals, protectedExternalIds())); } @SuppressWarnings("UnusedDeclaration")  ExternalPrincipalConfiguration();  ExternalPrincipalConfiguration(SecurityProvider securityProvider); @NotNull @Override PrincipalManager getPrincipalManager(Root root, NamePathMapper namePathMapper); @NotNull @Override PrincipalProvider getPrincipalProvider(Root root, NamePathMapper namePathMapper); @NotNull @Override String getName(); @NotNull @Override RepositoryInitializer getRepositoryInitializer(); @NotNull @Override List<? extends ValidatorProvider> getValidators(@NotNull String workspaceName, @NotNull Set<Principal> principals, @NotNull MoveTracker moveTracker); @NotNull @Override List<ProtectedItemImporter> getProtectedItemImporters(); @NotNull @Override List<ThreeWayConflictHandler> getConflictHandlers();  }
@Test public void testGetValidators() { ContentSession cs = root.getContentSession(); List<? extends ValidatorProvider> validatorProviders = externalPrincipalConfiguration.getValidators(cs.getWorkspaceName(), cs.getAuthInfo().getPrincipals(), new MoveTracker()); assertFalse(validatorProviders.isEmpty()); assertEquals(1, validatorProviders.size()); assertTrue(validatorProviders.get(0) instanceof ExternalIdentityValidatorProvider); validatorProviders = externalPrincipalConfiguration.getValidators(cs.getWorkspaceName(), cs.getAuthInfo().getPrincipals(), new MoveTracker()); assertFalse(validatorProviders.isEmpty()); assertEquals(1, validatorProviders.size()); assertTrue(validatorProviders.get(0) instanceof ExternalIdentityValidatorProvider); enable(); validatorProviders = externalPrincipalConfiguration.getValidators(cs.getWorkspaceName(), cs.getAuthInfo().getPrincipals(), new MoveTracker()); assertFalse(validatorProviders.isEmpty()); assertEquals(1, validatorProviders.size()); assertTrue(validatorProviders.get(0) instanceof ExternalIdentityValidatorProvider); }
@Test public void testGetValidatorsOmitIdProtection() { externalPrincipalConfiguration.setParameters(ConfigurationParameters.of(ExternalIdentityConstants.PARAM_PROTECT_EXTERNAL_IDS, false)); ContentSession cs = root.getContentSession(); List<? extends ValidatorProvider> validatorProviders = externalPrincipalConfiguration.getValidators(cs.getWorkspaceName(), cs.getAuthInfo().getPrincipals(), new MoveTracker()); assertFalse(validatorProviders.isEmpty()); assertEquals(1, validatorProviders.size()); assertTrue(validatorProviders.get(0) instanceof ExternalIdentityValidatorProvider); enable(); validatorProviders = externalPrincipalConfiguration.getValidators(cs.getWorkspaceName(), cs.getAuthInfo().getPrincipals(), new MoveTracker()); assertFalse(validatorProviders.isEmpty()); assertEquals(1, validatorProviders.size()); assertTrue(validatorProviders.get(0) instanceof ExternalIdentityValidatorProvider); }