1
0
mirror of https://github.com/sismics/docs.git synced 2025-12-16 11:15:07 +00:00

#79: POST /theme/color to change the main color

This commit is contained in:
jendib
2016-04-18 00:00:46 +02:00
parent 55cdca0c7d
commit 4e768e9103
11 changed files with 138 additions and 36 deletions

View File

@@ -1,7 +1,13 @@
package com.sismics.docs.rest;
import com.sismics.util.filter.TokenBasedSecurityFilter;
import org.junit.Assert;
import org.junit.Test;
import javax.json.JsonObject;
import javax.ws.rs.client.Entity;
import javax.ws.rs.core.Form;
/**
* Test the theme resource.
*
@@ -13,9 +19,23 @@ public class TestThemeResource extends BaseJerseyTest {
*/
@Test
public void testThemeResource() {
// Login admin
String adminToken = clientUtil.login("admin", "admin", false);
// Get the stylesheet anonymously
String stylesheet = target().path("/theme/stylesheet").request()
.get(String.class);
System.out.println(stylesheet);
Assert.assertTrue(stylesheet.contains("background-color: inherit;"));
// Update the main color as admin
target().path("/theme/color").request()
.cookie(TokenBasedSecurityFilter.COOKIE_NAME, adminToken)
.post(Entity.form(new Form()
.param("color", "#ff0000")), JsonObject.class);
// Get the stylesheet anonymously
stylesheet = target().path("/theme/stylesheet").request()
.get(String.class);
Assert.assertTrue(stylesheet.contains("background-color: #ff0000;"));
}
}