This commit is contained in:
@@ -87,6 +87,8 @@
|
|||||||
const track = css.getPropertyValue('--surface-2').trim() || '#2c2c2c';
|
const track = css.getPropertyValue('--surface-2').trim() || '#2c2c2c';
|
||||||
const tick = css.getPropertyValue('--text').trim() || '#f1f1f1';
|
const tick = css.getPropertyValue('--text').trim() || '#f1f1f1';
|
||||||
const grid = css.getPropertyValue('--border').trim() || '#333';
|
const grid = css.getPropertyValue('--border').trim() || '#333';
|
||||||
|
const xpPercentage = /*[[${xpPercentage}]]*/ 0;
|
||||||
|
const weeklyMinutes = /*[[${weekly.minutes}]]*/ [0, 0, 0, 0, 0, 0, 0];
|
||||||
|
|
||||||
// Kreisdiagramm
|
// Kreisdiagramm
|
||||||
const ctx = document.getElementById('progressCircle').getContext('2d');
|
const ctx = document.getElementById('progressCircle').getContext('2d');
|
||||||
@@ -94,7 +96,7 @@
|
|||||||
type: 'doughnut',
|
type: 'doughnut',
|
||||||
data: {
|
data: {
|
||||||
datasets: [{
|
datasets: [{
|
||||||
data: [/*[[${xpPercentage}]]*/ 0, 100 - /*[[${xpPercentage}]]*/ 0],
|
data: [xpPercentage, 100 - xpPercentage],
|
||||||
backgroundColor: [accent, track],
|
backgroundColor: [accent, track],
|
||||||
borderWidth: 0
|
borderWidth: 0
|
||||||
}]
|
}]
|
||||||
@@ -115,7 +117,7 @@
|
|||||||
labels: ['Mo', 'Di', 'Mi', 'Do', 'Fr', 'Sa', 'So'],
|
labels: ['Mo', 'Di', 'Mi', 'Do', 'Fr', 'Sa', 'So'],
|
||||||
datasets: [{
|
datasets: [{
|
||||||
label: 'Spielzeit (Minuten)',
|
label: 'Spielzeit (Minuten)',
|
||||||
data: /*[[${weekly.minutes}]]*/ [0, 0, 0, 0, 0, 0, 0],
|
data: weeklyMinutes,
|
||||||
backgroundColor: accent,
|
backgroundColor: accent,
|
||||||
borderRadius: 6
|
borderRadius: 6
|
||||||
}]
|
}]
|
||||||
|
|||||||
@@ -3,7 +3,9 @@ package com.example.mindflux;
|
|||||||
import com.example.mindflux.config.SecurityConfig;
|
import com.example.mindflux.config.SecurityConfig;
|
||||||
import com.example.mindflux.controller.AdminUserController;
|
import com.example.mindflux.controller.AdminUserController;
|
||||||
import com.example.mindflux.controller.DashboardController;
|
import com.example.mindflux.controller.DashboardController;
|
||||||
|
import com.example.mindflux.controller.ProgressController;
|
||||||
import com.example.mindflux.dto.ProgressData;
|
import com.example.mindflux.dto.ProgressData;
|
||||||
|
import com.example.mindflux.dto.WeeklyActivity;
|
||||||
import com.example.mindflux.repository.UserRepository;
|
import com.example.mindflux.repository.UserRepository;
|
||||||
import com.example.mindflux.service.LoginAttemptService;
|
import com.example.mindflux.service.LoginAttemptService;
|
||||||
import com.example.mindflux.service.ProgressService;
|
import com.example.mindflux.service.ProgressService;
|
||||||
@@ -18,13 +20,14 @@ import org.springframework.test.web.servlet.MockMvc;
|
|||||||
|
|
||||||
import static org.mockito.ArgumentMatchers.anyString;
|
import static org.mockito.ArgumentMatchers.anyString;
|
||||||
import static org.mockito.Mockito.when;
|
import static org.mockito.Mockito.when;
|
||||||
|
import java.util.List;
|
||||||
import static org.springframework.security.test.web.servlet.request.SecurityMockMvcRequestPostProcessors.csrf;
|
import static org.springframework.security.test.web.servlet.request.SecurityMockMvcRequestPostProcessors.csrf;
|
||||||
import static org.springframework.test.web.servlet.request.MockMvcRequestBuilders.get;
|
import static org.springframework.test.web.servlet.request.MockMvcRequestBuilders.get;
|
||||||
import static org.springframework.test.web.servlet.request.MockMvcRequestBuilders.post;
|
import static org.springframework.test.web.servlet.request.MockMvcRequestBuilders.post;
|
||||||
import static org.springframework.test.web.servlet.result.MockMvcResultMatchers.status;
|
import static org.springframework.test.web.servlet.result.MockMvcResultMatchers.status;
|
||||||
|
|
||||||
/** Absichert die zentralen Security-Regeln: Login-Zwang, Admin-Schutz, gelöschter Legacy-Endpunkt. */
|
/** Absichert die zentralen Security-Regeln: Login-Zwang, Admin-Schutz, gelöschter Legacy-Endpunkt. */
|
||||||
@WebMvcTest(controllers = {DashboardController.class, AdminUserController.class})
|
@WebMvcTest(controllers = {DashboardController.class, ProgressController.class, AdminUserController.class})
|
||||||
@Import(SecurityConfig.class)
|
@Import(SecurityConfig.class)
|
||||||
class SecurityRulesTest {
|
class SecurityRulesTest {
|
||||||
|
|
||||||
@@ -57,6 +60,18 @@ class SecurityRulesTest {
|
|||||||
.andExpect(status().isOk());
|
.andExpect(status().isOk());
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Test
|
||||||
|
@WithMockUser(username = "alice")
|
||||||
|
void eingeloggteNutzerSehenDieFortschrittsseite() throws Exception {
|
||||||
|
when(progressService.getOverallProgress(anyString())).thenReturn(new ProgressData());
|
||||||
|
when(progressService.getGameProgress(anyString())).thenReturn(List.of());
|
||||||
|
when(progressService.getCurrentWeekActivity(anyString())).thenReturn(
|
||||||
|
new WeeklyActivity(List.of(0, 0, 0, 0, 0, 0, 0), List.of(0, 0, 0, 0, 0, 0, 0), 0, 0));
|
||||||
|
|
||||||
|
mockMvc.perform(get("/progress"))
|
||||||
|
.andExpect(status().isOk());
|
||||||
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
@WithMockUser(username = "alice", roles = "USER")
|
@WithMockUser(username = "alice", roles = "USER")
|
||||||
void adminBereichIstFuerNormaleNutzerGesperrt() throws Exception {
|
void adminBereichIstFuerNormaleNutzerGesperrt() throws Exception {
|
||||||
|
|||||||
Reference in New Issue
Block a user