@Test public void buildShouldThrowWhenKeystoreIsEmpty() { assertThatThrownBy(() -> JMAPConfiguration.builder() .enable() .keystore("") .build()) .isInstanceOf(IllegalStateException.class) .hasMessage("'keystore' is mandatory"); }
@Test public void buildShouldThrowWhenKeystoreIsNull() { assertThatThrownBy(() -> JMAPConfiguration.builder() .enable() .keystore(null) .build()) .isInstanceOf(IllegalStateException.class) .hasMessage("'keystore' is mandatory"); }
@Test public void buildShouldThrowWhenSecretIsNull() { assertThatThrownBy(() -> JMAPConfiguration.builder() .enable() .keystore("keystore") .secret(null) .build()) .isInstanceOf(IllegalStateException.class) .hasMessage("'secret' is mandatory"); }
@Test public void buildShouldWorkWhenRandomPort() { JMAPConfiguration expectedJMAPConfiguration = new JMAPConfiguration(ENABLED, "keystore", "secret", Optional.of("file://conf/jwt_publickey"), Optional.empty()); JMAPConfiguration jmapConfiguration = JMAPConfiguration.builder() .enable() .keystore("keystore") .secret("secret") .jwtPublicKeyPem(Optional.of("file://conf/jwt_publickey")) .randomPort() .build(); assertThat(jmapConfiguration).isEqualToComparingFieldByField(expectedJMAPConfiguration); }
@Test public void buildShouldThrowWhenJwtPublicKeyPemIsEmpty() { assertThatThrownBy(() -> JMAPConfiguration.builder() .enable() .keystore("keystore") .secret("secret") .jwtPublicKeyPem(Optional.empty()) .build()) .isInstanceOf(IllegalStateException.class); }
@Test public void buildShouldThrowWhenSecretIsEmpty() { assertThatThrownBy(() -> JMAPConfiguration.builder() .enable() .keystore("keystore") .secret("") .build()) .isInstanceOf(IllegalStateException.class) .hasMessage("'secret' is mandatory"); }
@Test public void buildShouldWorkWhenFixedPort() { JMAPConfiguration expectedJMAPConfiguration = new JMAPConfiguration(ENABLED, "keystore", "secret", Optional.of("file://conf/jwt_publickey"), Optional.of(80)); JMAPConfiguration jmapConfiguration = JMAPConfiguration.builder() .enable() .keystore("keystore") .secret("secret") .jwtPublicKeyPem(Optional.of("file://conf/jwt_publickey")) .port(80) .build(); assertThat(jmapConfiguration).isEqualToComparingFieldByField(expectedJMAPConfiguration); }
public static Builder newConfigurationBuilder() { return JMAPConfiguration.builder() .enable() .keystore("keystore") .secret("james72laBalle") .jwtPublicKeyPem(Optional.of(JWT_PUBLIC_KEY)); }
@Test public void buildShouldThrowWhenJwtPublicKeyPemIsNull() { assertThatThrownBy(() -> JMAPConfiguration.builder() .enable() .keystore("keystore") .secret("secret") .jwtPublicKeyPem(null) .build()) .isInstanceOf(NullPointerException.class); }
@Provides @Singleton JMAPConfiguration provideConfiguration() throws FileNotFoundException, ConfigurationException { return JMAPConfiguration.builder() .enable() .keystore("keystore") .secret("james72laBalle") .jwtPublicKeyPem(Optional.of(PUBLIC_PEM_KEY)) .randomPort() .build(); } }