yeg
2026-08-29 a2a8908f2d9d4e19201423ff58ee23c65a8df670
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
package com.ruoyi.web.controller.system;
 
import static org.junit.jupiter.api.Assertions.assertEquals;
import java.lang.reflect.Method;
import org.junit.jupiter.api.Test;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.security.access.prepost.PreAuthorize;
 
class TTestControllerContractTest
{
    @Test
    void configurationEndpointsKeepServerSidePermissions() throws Exception
    {
        assertPermission("options", "@ss.hasAnyPermi('system:test:add,system:test:edit')");
        assertPermission("getInfo", "@ss.hasPermi('system:test:query')", Long.class);
        assertPermission("add", "@ss.hasPermi('system:test:add')", com.ruoyi.system.domain.TTest.class);
        assertPermission("edit", "@ss.hasPermi('system:test:edit')", com.ruoyi.system.domain.TTest.class);
        assertPermission("startReception", "@ss.hasPermi('system:test:start')", Long.class);
        Method startReception = TTestController.class.getMethod("startReception", Long.class);
        assertEquals("/{testId}/reception/start", startReception.getAnnotation(PostMapping.class).value()[0]);
    }
 
    private void assertPermission(String methodName, String permission, Class<?>... parameterTypes) throws Exception
    {
        Method method = TTestController.class.getMethod(methodName, parameterTypes);
        assertEquals(permission, method.getAnnotation(PreAuthorize.class).value());
    }
}