public void afterPropertiesSet() { validate(); }
public void afterPropertiesSet() { validate(); }
@Test public void validateWhenUserInfoUriConfiguredShouldNotFail() throws Exception { this.properties.setUserInfoUri("http://my-auth-server/userinfo"); setListableBeanFactory(); this.properties.validate(); verifyZeroInteractions(this.errors); }
@Test public void validateWhenClientIdNullShouldNotFail() throws Exception { this.properties = new ResourceServerProperties(null, "secret"); setListableBeanFactory(); this.properties.validate(); verifyZeroInteractions(this.errors); }
@Test public void validateWhenTokenUriConfiguredShouldNotFail() throws Exception { this.properties.setTokenInfoUri("http://my-auth-server/userinfo"); setListableBeanFactory(); this.properties.validate(); verifyZeroInteractions(this.errors); }
@Test public void validateWhenTokenUriAbsentAndClientSecretAbsentShouldNotFail() throws Exception { this.properties = new ResourceServerProperties("client", ""); this.properties.setUserInfoUri("http://my-auth-server/userinfo"); setListableBeanFactory(); this.properties.validate(); verifyZeroInteractions(this.errors); }
@Test public void validateWhenJwkKeySetUriProvidedShouldSucceed() throws Exception { this.properties.getJwk().setKeySetUri("http://my-auth-server/token_keys"); setListableBeanFactory(); this.properties.validate(); verifyZeroInteractions(this.errors); }
@Test public void validateWhenKeyValuePresentShouldSucceed() throws Exception { this.properties.getJwt().setKeyValue("my-key"); setListableBeanFactory(); this.properties.validate(); verifyZeroInteractions(this.errors); }
@Test public void validateWhenKeysUriOrValuePresentAndUserInfoAbsentShouldNotFail() throws Exception { this.properties = new ResourceServerProperties("client", ""); this.properties.getJwk().setKeySetUri("http://my-auth-server/token_keys"); setListableBeanFactory(); this.properties.validate(); verifyZeroInteractions(this.errors); }
@Test public void validateWhenTokenUriNotPreferredAndClientSecretAbsentShouldNotFail() throws Exception { this.properties = new ResourceServerProperties("client", ""); this.properties.setPreferTokenInfo(false); this.properties.setTokenInfoUri("http://my-auth-server/check_token"); this.properties.setUserInfoUri("http://my-auth-server/userinfo"); setListableBeanFactory(); this.properties.validate(); verifyZeroInteractions(this.errors); }
@Test public void validateWhenKeyConfigAbsentAndInfoUrisNotConfiguredShouldFail() throws Exception { setListableBeanFactory(); this.thrown.expect(IllegalStateException.class); this.thrown.expect(getMatcher("Missing tokenInfoUri and userInfoUri and there" + " is no JWT verifier key", "tokenInfoUri")); this.properties.validate(); }
@Test public void validateWhenTokenUriPreferredAndClientSecretAbsentShouldFail() throws Exception { this.properties = new ResourceServerProperties("client", ""); this.properties.setTokenInfoUri("http://my-auth-server/check_token"); this.properties.setUserInfoUri("http://my-auth-server/userinfo"); setListableBeanFactory(); this.thrown.expect(IllegalStateException.class); this.thrown.expect(getMatcher("Missing client secret", "clientSecret")); this.properties.validate(); }
@Test public void validateWhenBothJwtKeyValueAndJwkKeyUriPresentShouldFail() throws Exception { this.properties.getJwk().setKeySetUri("http://my-auth-server/token_keys"); this.properties.getJwt().setKeyValue("my-key"); setListableBeanFactory(); this.thrown.expect(IllegalStateException.class); this.thrown.expect(getMatcher("Only one of jwt.keyUri (or jwt.keyValue) " + "and jwk.keySetUri should be configured.", null)); this.properties.validate(); }
@Test public void validateWhenBothJwtAndJwkKeyUrisPresentShouldFail() throws Exception { this.properties.getJwk().setKeySetUri("http://my-auth-server/token_keys"); this.properties.getJwt().setKeyUri("http://my-auth-server/token_key"); setListableBeanFactory(); this.thrown.expect(IllegalStateException.class); this.thrown.expect(getMatcher("Only one of jwt.keyUri (or jwt.keyValue) " + "and jwk.keySetUri should be configured.", null)); this.properties.validate(); }