@Test
    void verifyAcceptedCredentialsWithServiceDisabled() {
        val credentials = new UsernamePasswordCredentials("casuser", "casuser");
        val request = new MockHttpServletRequest();

        val disabledService = new OAuthRegisteredService();
        disabledService.setName("OAuth");
        disabledService.setId(RandomUtils.nextLong());
        disabledService.setServiceId("https://www.example.org");
        disabledService.setClientSecret(UUID.randomUUID().toString());
        disabledService.setClientId(UUID.randomUUID().toString());
        disabledService.setAccessStrategy(new DefaultRegisteredServiceAccessStrategy(false, false));
        servicesManager.save(disabledService);
        request.addParameter(OAuth20Constants.CLIENT_ID, disabledService.getClientId());
        val ctx = new JEEContext(request, new MockHttpServletResponse());
        assertThrows(CredentialsException.class,
            () -> authenticator.validate(new CallContext(ctx, new JEESessionStore()), credentials));
    }
This is {@link OAuth20UsernamePasswordAuthenticatorTests}.

@author Misagh Moayyed
@since 6.0.0
support/cas-server-support-oauth/src/test/java/org/apereo/cas/support/oauth/authenticator/OAuth20UsernamePasswordAuthenticatorTests.java