@@ -0,0 +1,2339 @@
+package net.explorviz.security.server;%0A%0Aimport static io.restassured.RestAssured.*;%0Aimport static org.hamcrest.CoreMatchers.is;%0A%0Aimport io.restassured.http.Header;%0Aimport net.explorviz.security.server.helper.AuthorizationHelper;%0Aimport net.explorviz.security.server.helper.JsonAPIListMapper;%0Aimport net.explorviz.shared.security.model.roles.Role;%0Aimport org.junit.Assert;%0Aimport org.junit.jupiter.api.BeforeAll;%0Aimport org.junit.jupiter.api.BeforeEach;%0Aimport org.junit.jupiter.api.DisplayName;%0Aimport org.junit.jupiter.api.Test;%0A%0Aimport java.io.IOException;%0Aimport java.util.ArrayList;%0Aimport java.util.Arrays;%0Aimport java.util.List;%0A%0Apublic class RoleTests %7B%0A%0A  private static final String ROLE_URL = %22http://localhost:8082/v1/roles%22;%0A%0A  // Currently only two roles exist, nameley 'user' and 'admin'%0A  // It's not possible to add more roles%0A%0A  private static String adminToken;%0A  private static String normieToken;%0A%0A  private Header authHeaderAdmin;%0A  private Header authHeaderNormie;%0A%0A%0A%0A  /**%0A   * Retrieves token for both an admin and an unprivileged user (%22normie%22).%0A   * The default admin is used for the former, a normie is created.%0A   *%0A   * @throws IOException if serialization fails%0A   */%0A  @BeforeAll static void setUpAll() throws IOException %7B%0A    adminToken = AuthorizationHelper.getAdminToken();%0A    normieToken = AuthorizationHelper.getNormieToken();%0A  %7D%0A%0A  @BeforeEach void setUp() %7B%0A    this.authHeaderAdmin = new Header(%22authorization%22, %22Bearer %22 + adminToken);%0A    this.authHeaderNormie = new Header(%22authorization%22, %22Bearer %22 + normieToken);%0A  %7D%0A%0A%0A  @Test%0A  @DisplayName(%22Get all roles%22)%0A  @SuppressWarnings(%22unchecked%22)%0A  public void getAll() %7B%0A    List%3CRole%3E actualRoles = new ArrayList%3C%3E(Arrays.asList(new Role(%22admin%22),%0A        new Role(%22user%22)));%0A%0A    List%3CRole%3E retrieved = given()%0A        .header(authHeaderAdmin)%0A        .when()%0A        .get(ROLE_URL)%0A        .then()%0A        .statusCode(200)%0A        .body(%22data.size()%22, is(2))%0A        .extract()%0A        .body()%0A        .as(List.class, new JsonAPIListMapper%3CRole%3E(Role.class));%0A%0A    Assert.assertEquals(actualRoles, retrieved);%0A  %7D%0A%0A  @Test%0A  @DisplayName(%22Get all roles without privileges%22)%0A  public void getAllAsNormie() %7B%0A    given()%0A        .header(authHeaderNormie)%0A        .when()%0A        .get(ROLE_URL)%0A        .then()%0A        .statusCode(403);%0A  %7D%0A%0A%7D%0A

Add integration test for roles