-
Notifications
You must be signed in to change notification settings - Fork 4
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Added missing graph endpoints in mock
- Loading branch information
Showing
7 changed files
with
144 additions
and
34 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
29 changes: 29 additions & 0 deletions
29
provisioning-mock/src/test/java/provisioning/api/AbstractTest.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,29 @@ | ||
package provisioning.api; | ||
|
||
import io.restassured.RestAssured; | ||
import org.junit.jupiter.api.BeforeEach; | ||
import org.junit.jupiter.api.extension.ExtendWith; | ||
import org.springframework.beans.factory.annotation.Autowired; | ||
import org.springframework.boot.test.context.SpringBootTest; | ||
import org.springframework.boot.test.web.server.LocalServerPort; | ||
import org.springframework.test.context.junit.jupiter.SpringExtension; | ||
import provisioning.repository.ProvisioningRepository; | ||
|
||
@ExtendWith(SpringExtension.class) | ||
@SpringBootTest(webEnvironment = SpringBootTest.WebEnvironment.RANDOM_PORT) | ||
public abstract class AbstractTest { | ||
|
||
@LocalServerPort | ||
protected int port; | ||
|
||
@Autowired | ||
protected ProvisioningRepository provisioningRepository; | ||
|
||
@BeforeEach | ||
protected void beforeEach() { | ||
RestAssured.port = port; | ||
provisioningRepository.deleteAllInBatch(); | ||
} | ||
|
||
|
||
} |
86 changes: 86 additions & 0 deletions
86
provisioning-mock/src/test/java/provisioning/api/GraphControllerTest.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,86 @@ | ||
package provisioning.api; | ||
|
||
import io.restassured.common.mapper.TypeRef; | ||
import io.restassured.http.ContentType; | ||
import org.junit.jupiter.api.Test; | ||
|
||
import java.util.Map; | ||
import java.util.UUID; | ||
|
||
import static io.restassured.RestAssured.given; | ||
import static org.junit.jupiter.api.Assertions.assertEquals; | ||
import static org.junit.jupiter.api.Assertions.assertNotNull; | ||
|
||
class GraphControllerTest extends AbstractTest { | ||
|
||
@Test | ||
void createUser() { | ||
Map<String, Object> result = given() | ||
.when() | ||
.accept(ContentType.JSON) | ||
.contentType(ContentType.JSON) | ||
.body(Map.of("inviteRedirectUrl", "http://localhost/api/v1/invitations/ms-accept-return/1/2")) | ||
.post("/graph/users") | ||
.as(new TypeRef<>() { | ||
}); | ||
assertNotNull(result.get("id")); | ||
assertNotNull(((Map) result.get("invitedUser")).get("id")); | ||
assertEquals("http://localhost:8081/graph/accept/1/2", result.get("inviteRedeemUrl")); | ||
|
||
assertEquals(1, provisioningRepository.count()); | ||
} | ||
|
||
@Test | ||
void getUser() { | ||
Map<String, Object> result = given() | ||
.when() | ||
.accept(ContentType.JSON) | ||
.contentType(ContentType.JSON) | ||
.get("/graph/users") | ||
.as(new TypeRef<>() { | ||
}); | ||
assertNotNull(result.get("id")); | ||
assertEquals(1, provisioningRepository.count()); | ||
} | ||
|
||
@Test | ||
void updateUser() { | ||
Map<String, Object> result = given() | ||
.when() | ||
.accept(ContentType.JSON) | ||
.contentType(ContentType.JSON) | ||
.body(Map.of("id", UUID.randomUUID().toString())) | ||
.patch("/graph/users") | ||
.as(new TypeRef<>() { | ||
}); | ||
assertNotNull(result.get("id")); | ||
|
||
assertEquals(1, provisioningRepository.count()); | ||
} | ||
|
||
@Test | ||
void deleteUser() { | ||
given() | ||
.when() | ||
.accept(ContentType.JSON) | ||
.contentType(ContentType.JSON) | ||
.delete("/graph/users") | ||
.then() | ||
.statusCode(201); | ||
|
||
assertEquals(1, provisioningRepository.count()); | ||
} | ||
|
||
@Test | ||
void accept() { | ||
given() | ||
.redirects() | ||
.follow(false) | ||
.when() | ||
.accept(ContentType.JSON) | ||
.contentType(ContentType.JSON) | ||
.get("/graph/accept/1/2") | ||
.then() | ||
.header("Location", "http://localhost:8080/api/v1/users/ms-accept-return/1/2"); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters