diff --git a/.forge/BAIS-E2E-MIG-001-attempt-1.md b/.forge/BAIS-E2E-MIG-001-attempt-1.md new file mode 100644 index 0000000..0384ad0 --- /dev/null +++ b/.forge/BAIS-E2E-MIG-001-attempt-1.md @@ -0,0 +1,3 @@ +# BAIS-E2E-MIG-001-attempt-1 + +Forge 이슈 작업 브랜치 `forge/BAIS-E2E-MIG-001-attempt-1`. diff --git a/pom.xml b/pom.xml new file mode 100644 index 0000000..3e45ad2 --- /dev/null +++ b/pom.xml @@ -0,0 +1,41 @@ + + + 4.0.0 + + com.example + bais-authorization-service + 1.0-SNAPSHOT + jar + + + 17 + + + + + org.springframework.boot + spring-boot-starter + + + org.springframework.boot + spring-boot-starter-test + test + + + + + + + org.springframework.boot + spring-boot-maven-plugin + + + org.apache.maven.plugins + maven-surefire-plugin + 3.0.0-M5 + + + + \ No newline at end of file diff --git a/src/main/java/com/example/authorization/AuthorizationService.java b/src/main/java/com/example/authorization/AuthorizationService.java new file mode 100644 index 0000000..a88d2e5 --- /dev/null +++ b/src/main/java/com/example/authorization/AuthorizationService.java @@ -0,0 +1,11 @@ +package com.example.authorization; + +import org.springframework.stereotype.Service; + +@Service +public class AuthorizationService { + public boolean hasAccess(String userRole, String resource) { + // 간단한 권한 확인 로직 + return "ADMIN".equals(userRole) || "USER".equals(userRole) && "RESOURCE".equals(resource); + } +} \ No newline at end of file diff --git a/src/test/java/com/example/authorization/AuthorizationServiceTest.java b/src/test/java/com/example/authorization/AuthorizationServiceTest.java new file mode 100644 index 0000000..cad95c4 --- /dev/null +++ b/src/test/java/com/example/authorization/AuthorizationServiceTest.java @@ -0,0 +1,17 @@ +package com.example.authorization; + +import org.junit.jupiter.api.Test; +import static org.junit.jupiter.api.Assertions.*; + +class AuthorizationServiceTest { + + private final AuthorizationService authorizationService = new AuthorizationService(); + + @Test + void testHasAccess() { + assertTrue(authorizationService.hasAccess("ADMIN", "RESOURCE")); + assertTrue(authorizationService.hasAccess("USER", "RESOURCE")); + assertFalse(authorizationService.hasAccess("USER", "OTHER_RESOURCE")); + assertFalse(authorizationService.hasAccess("GUEST", "RESOURCE")); + } +} \ No newline at end of file