Skip to content

Commit

Permalink
Add tests for HTTP login flow
Browse files Browse the repository at this point in the history
  • Loading branch information
mmodzelewski committed Jan 4, 2024
1 parent a2117e5 commit 1f34ac5
Show file tree
Hide file tree
Showing 2 changed files with 55 additions and 0 deletions.
28 changes: 28 additions & 0 deletions src/test/java/rs/iggy/http/UsersHttpClientTest.java
Original file line number Diff line number Diff line change
@@ -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();
}

}
27 changes: 27 additions & 0 deletions src/test/java/rs/iggy/user/UsersClientBaseTest.java
Original file line number Diff line number Diff line change
@@ -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);
}

}

0 comments on commit 1f34ac5

Please sign in to comment.