Developer 역할 Spring 골격 smoke (role-developer-live-v3-001)
This commit is contained in:
parent
061ee7ab69
commit
e563e57c84
1 changed files with 88 additions and 0 deletions
|
|
@ -0,0 +1,88 @@
|
||||||
|
package com.example.demo.service;
|
||||||
|
|
||||||
|
import org.junit.jupiter.api.BeforeEach;
|
||||||
|
import org.junit.jupiter.api.Test;
|
||||||
|
import org.junit.jupiter.api.DisplayName;
|
||||||
|
|
||||||
|
import java.util.List;
|
||||||
|
|
||||||
|
import static org.junit.jupiter.api.Assertions.*;
|
||||||
|
|
||||||
|
class DeveloperServiceTest {
|
||||||
|
|
||||||
|
private DeveloperService developerService;
|
||||||
|
|
||||||
|
@BeforeEach
|
||||||
|
void setUp() {
|
||||||
|
developerService = new DeveloperService();
|
||||||
|
}
|
||||||
|
|
||||||
|
@Test
|
||||||
|
@DisplayName("Developer role should have read-write permission")
|
||||||
|
void getRolePermission_developer_returnsReadWrite() {
|
||||||
|
String permission = developerService.getRolePermission("developer");
|
||||||
|
assertEquals("read-write", permission);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Test
|
||||||
|
@DisplayName("Viewer role should have read-only permission")
|
||||||
|
void getRolePermission_viewer_returnsReadOnly() {
|
||||||
|
String permission = developerService.getRolePermission("viewer");
|
||||||
|
assertEquals("read-only", permission);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Test
|
||||||
|
@DisplayName("Admin role should have full-access permission")
|
||||||
|
void getRolePermission_admin_returnsFullAccess() {
|
||||||
|
String permission = developerService.getRolePermission("admin");
|
||||||
|
assertEquals("full-access", permission);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Test
|
||||||
|
@DisplayName("Unknown role should return no-access")
|
||||||
|
void getRolePermission_unknown_returnsNoAccess() {
|
||||||
|
String permission = developerService.getRolePermission("unknown");
|
||||||
|
assertEquals("no-access", permission);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Test
|
||||||
|
@DisplayName("Role lookup should be case-insensitive")
|
||||||
|
void getRolePermission_caseInsensitive() {
|
||||||
|
assertEquals("read-write", developerService.getRolePermission("DEVELOPER"));
|
||||||
|
assertEquals("read-write", developerService.getRolePermission("Developer"));
|
||||||
|
}
|
||||||
|
|
||||||
|
@Test
|
||||||
|
@DisplayName("getAllRoles should return all defined roles")
|
||||||
|
void getAllRoles_returnsAllRoles() {
|
||||||
|
List<String> roles = developerService.getAllRoles();
|
||||||
|
assertEquals(3, roles.size());
|
||||||
|
assertTrue(roles.contains("developer"));
|
||||||
|
assertTrue(roles.contains("viewer"));
|
||||||
|
assertTrue(roles.contains("admin"));
|
||||||
|
}
|
||||||
|
|
||||||
|
@Test
|
||||||
|
@DisplayName("Admin should have all permissions")
|
||||||
|
void hasPermission_admin_hasAllPermissions() {
|
||||||
|
assertTrue(developerService.hasPermission("admin", "read"));
|
||||||
|
assertTrue(developerService.hasPermission("admin", "write"));
|
||||||
|
assertTrue(developerService.hasPermission("admin", "delete"));
|
||||||
|
}
|
||||||
|
|
||||||
|
@Test
|
||||||
|
@DisplayName("Developer should have read and write but not delete")
|
||||||
|
void hasPermission_developer_readWriteNotDelete() {
|
||||||
|
assertTrue(developerService.hasPermission("developer", "read"));
|
||||||
|
assertTrue(developerService.hasPermission("developer", "write"));
|
||||||
|
assertFalse(developerService.hasPermission("developer", "delete"));
|
||||||
|
}
|
||||||
|
|
||||||
|
@Test
|
||||||
|
@DisplayName("Viewer should only have read permission")
|
||||||
|
void hasPermission_viewer_onlyRead() {
|
||||||
|
assertTrue(developerService.hasPermission("viewer", "read"));
|
||||||
|
assertFalse(developerService.hasPermission("viewer", "write"));
|
||||||
|
assertFalse(developerService.hasPermission("viewer", "delete"));
|
||||||
|
}
|
||||||
|
}
|
||||||
Loading…
Add table
Add a link
Reference in a new issue