diff --git a/src/test/java/rs/iggy/http/UsersHttpClientTest.java b/src/test/java/rs/iggy/http/UsersHttpClientTest.java new file mode 100644 index 0000000..41059fa --- /dev/null +++ b/src/test/java/rs/iggy/http/UsersHttpClientTest.java @@ -0,0 +1,28 @@ +package rs.iggy.http; + +import org.junit.jupiter.api.Test; +import rs.iggy.IggyClient; +import rs.iggy.user.UsersClientBaseTest; +import static org.assertj.core.api.Assertions.assertThat; + +class UsersHttpClientTest extends UsersClientBaseTest { + + @Override + protected IggyClient getClient() { + return HttpClientFactory.create(iggyServer); + } + + + @Test + void shouldGetTokens() { + // when + var identityInfo = usersClient.login("iggy", "iggy"); + + // then + assertThat(identityInfo).isNotNull(); + assertThat(identityInfo.tokens()).isPresent(); + assertThat(identityInfo.tokens().get().accessToken().token()).isNotBlank(); + assertThat(identityInfo.tokens().get().refreshToken().token()).isNotBlank(); + } + +} diff --git a/src/test/java/rs/iggy/user/UsersClientBaseTest.java b/src/test/java/rs/iggy/user/UsersClientBaseTest.java new file mode 100644 index 0000000..707c033 --- /dev/null +++ b/src/test/java/rs/iggy/user/UsersClientBaseTest.java @@ -0,0 +1,27 @@ +package rs.iggy.user; + +import org.junit.jupiter.api.BeforeEach; +import org.junit.jupiter.api.Test; +import rs.iggy.IntegrationTest; +import static org.assertj.core.api.Assertions.assertThat; + +public abstract class UsersClientBaseTest extends IntegrationTest { + + protected UsersClient usersClient; + + @BeforeEach + void beforeEachBase() { + usersClient = client.users(); + } + + @Test + void shouldLogin() { + // when + var identityInfo = usersClient.login("iggy", "iggy"); + + // then + assertThat(identityInfo).isNotNull(); + assertThat(identityInfo.userId()).isEqualTo(1L); + } + +}