35 lines
1.3 KiB
Java
35 lines
1.3 KiB
Java
package com.baiyue.integration.config;
|
|
|
|
import org.junit.jupiter.api.Test;
|
|
|
|
import java.net.URI;
|
|
import java.nio.file.Path;
|
|
import java.time.Duration;
|
|
|
|
import static org.assertj.core.api.Assertions.assertThat;
|
|
|
|
class IntegrationPropertiesTest {
|
|
@Test
|
|
void providerIsConfiguredOnlyWhenEnabledAndAllSecretsExist() {
|
|
var baidu = baidu(true, "key", "secret");
|
|
var amazon = new IntegrationProperties.AmazonSpApi(
|
|
true, "client", "secret", "refresh", "access", "aws-secret", "us-east-1");
|
|
|
|
assertThat(baidu.configured()).isTrue();
|
|
assertThat(amazon.configured()).isTrue();
|
|
assertThat(baidu(false, "key", "secret").configured()).isFalse();
|
|
assertThat(new IntegrationProperties.AmazonSpApi(
|
|
true, "client", "secret", "", "access", "aws-secret", "us-east-1").configured()).isFalse();
|
|
}
|
|
|
|
private IntegrationProperties.BaiduOcr baidu(boolean enabled, String apiKey, String secretKey) {
|
|
return new IntegrationProperties.BaiduOcr(
|
|
enabled, apiKey, secretKey,
|
|
URI.create("https://example.com/token"), URI.create("https://example.com/meter"),
|
|
Duration.ofSeconds(10), Duration.ofSeconds(60),
|
|
Path.of("input"), Path.of("output"), null,
|
|
40_000_000L, 50, Duration.ofMillis(600), 3
|
|
);
|
|
}
|
|
}
|