|
| 1 | +package io.camunda.zeebe.spring.client.config.authentication; |
| 2 | + |
| 3 | +import io.camunda.common.auth.Authentication; |
| 4 | +import io.camunda.common.auth.Product; |
| 5 | +import io.camunda.common.auth.SimpleAuthentication; |
| 6 | +import io.camunda.common.auth.SimpleCredential; |
| 7 | +import io.camunda.identity.autoconfigure.IdentityAutoConfiguration; |
| 8 | +import io.camunda.operate.CamundaOperateClient; |
| 9 | +import io.camunda.zeebe.spring.client.configuration.CommonClientConfiguration; |
| 10 | +import io.camunda.zeebe.spring.client.configuration.OperateClientConfiguration; |
| 11 | +import io.camunda.zeebe.spring.client.properties.ZeebeClientConfigurationProperties; |
| 12 | +import org.junit.jupiter.api.Test; |
| 13 | +import org.junit.jupiter.api.extension.ExtendWith; |
| 14 | +import org.springframework.beans.factory.annotation.Autowired; |
| 15 | +import org.springframework.boot.autoconfigure.ImportAutoConfiguration; |
| 16 | +import org.springframework.boot.context.properties.EnableConfigurationProperties; |
| 17 | +import org.springframework.test.context.ContextConfiguration; |
| 18 | +import org.springframework.test.context.TestPropertySource; |
| 19 | +import org.springframework.test.context.junit.jupiter.SpringExtension; |
| 20 | + |
| 21 | +import static org.assertj.core.api.Assertions.assertThat; |
| 22 | + |
| 23 | +@ExtendWith(SpringExtension.class) |
| 24 | +@TestPropertySource( |
| 25 | + properties = { |
| 26 | + "zeebe.client.broker.gatewayAddress=localhost12345", |
| 27 | + "zeebe.authorization.server.url=http://zeebe-authorization-server", |
| 28 | + "zeebe.client.id=client-id", |
| 29 | + "zeebe.client.secret=client-secret", |
| 30 | + "zeebe.token.audience=sample-audience", |
| 31 | + "camunda.operate.client.url=http://localhost:8081", |
| 32 | + "camunda.operate.client.username=username", |
| 33 | + "camunda.operate.client.password=password" |
| 34 | + } |
| 35 | +) |
| 36 | +@ContextConfiguration(classes = OperateSelfManagedBasicWithZeebeCredentialsTest.TestConfig.class) |
| 37 | +public class OperateSelfManagedBasicWithZeebeCredentialsTest { |
| 38 | + |
| 39 | + @ImportAutoConfiguration({CommonClientConfiguration.class, OperateClientConfiguration.class, IdentityAutoConfiguration.class}) |
| 40 | + @EnableConfigurationProperties(ZeebeClientConfigurationProperties.class) |
| 41 | + public static class TestConfig { |
| 42 | + |
| 43 | + } |
| 44 | + |
| 45 | + @Autowired |
| 46 | + private Authentication authentication; |
| 47 | + |
| 48 | + @Autowired |
| 49 | + private CamundaOperateClient operateClient; |
| 50 | + |
| 51 | + @Test |
| 52 | + public void testAuthentication() { |
| 53 | + assertThat(authentication).isInstanceOf(SimpleAuthentication.class); |
| 54 | + assertThat(operateClient).isNotNull(); |
| 55 | + } |
| 56 | + |
| 57 | + @Test |
| 58 | + public void testCredential() { |
| 59 | + SimpleAuthentication simpleAuthentication = (SimpleAuthentication) authentication; |
| 60 | + SimpleCredential simpleCredential = simpleAuthentication.getSimpleConfig().getProduct(Product.OPERATE); |
| 61 | + |
| 62 | + assertThat(simpleCredential.getUser()).isEqualTo("username"); |
| 63 | + assertThat(simpleCredential.getPassword()).isEqualTo("password"); |
| 64 | + } |
| 65 | +} |
0 commit comments