Skip to content

Commit

Permalink
refactor: rename classes and improve application.properties
Browse files Browse the repository at this point in the history
Signed-off-by: Oleg Kopysov <[email protected]>
  • Loading branch information
o-kopysov committed Feb 23, 2024
1 parent baedd56 commit f7dddb7
Show file tree
Hide file tree
Showing 9 changed files with 56 additions and 57 deletions.
2 changes: 2 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -58,6 +58,8 @@ With these features, _LPVS_ assists developers to manage license compliance for

The frontend of the _LPVS_ project is implemented using React. The corresponding code can be found in the `frontend` folder. For detailed information about the frontend, please refer to the [Frontend README](frontend/README.md).

To ensure compatibility between the LPVS frontend and backend, it's important to build the backend with the _"web"_ profile.

---

## License
Expand Down
2 changes: 1 addition & 1 deletion pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -153,7 +153,7 @@
<archive>
<manifest>
<addClasspath>true</addClasspath>
<mainClass>com.lpvs.LicensePreValidationSystem</mainClass>
<mainClass>com.lpvs.LicensePreValidationService</mainClass>
</manifest>
</archive>
<appendAssemblyId>false</appendAssemblyId>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@
@SpringBootApplication(scanBasePackages = {"com.lpvs"})
@EnableAutoConfiguration
@EnableAsync
public class LicensePreValidationSystem {
public class LicensePreValidationService {

/**
* The core pool size for the asynchronous task executor.
Expand All @@ -38,11 +38,11 @@ public class LicensePreValidationSystem {
private static LPVSExitHandler exitHandler;

/**
* Constructs a new LicensePreValidationSystem with the specified core pool size.
* Constructs a new LicensePreValidationService with the specified core pool size.
*
* @param corePoolSize The core pool size for the asynchronous task executor.
*/
public LicensePreValidationSystem(@Value("${lpvs.cores:8}") int corePoolSize) {
public LicensePreValidationService(@Value("${lpvs.cores:8}") int corePoolSize) {
this.corePoolSize = corePoolSize;
}

Expand All @@ -54,7 +54,7 @@ public LicensePreValidationSystem(@Value("${lpvs.cores:8}") int corePoolSize) {
public static void main(String[] args) {
try {
ApplicationContext applicationContext =
SpringApplication.run(LicensePreValidationSystem.class, args);
SpringApplication.run(LicensePreValidationService.class, args);
exitHandler = applicationContext.getBean(LPVSExitHandler.class);
} catch (IllegalArgumentException e) {
System.err.println("An IllegalArgumentException occurred: " + e.getMessage());
Expand Down
4 changes: 3 additions & 1 deletion src/main/java/com/lpvs/controller/LPVSWebController.java
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,7 @@
import com.lpvs.util.LPVSWebhookUtil;
import lombok.extern.slf4j.Slf4j;
import org.springframework.boot.web.servlet.error.ErrorController;
import org.springframework.context.annotation.Profile;
import org.springframework.dao.DataIntegrityViolationException;
import org.springframework.data.domain.Page;
import org.springframework.data.domain.Pageable;
Expand Down Expand Up @@ -113,8 +114,9 @@ public LPVSWebController(
* Controller class for managing public web API endpoints in LPVS.
* This class provides endpoints for retrieving user information, login details, and performing user-related actions.
*/
@RequestMapping("/api/v1/web")
@RestController
@Profile("web")
@RequestMapping("/api/v1/web")
class WebApiEndpoints {

/**
Expand Down
2 changes: 1 addition & 1 deletion src/main/java/com/lpvs/package-info.java
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@
* Provides the main classes and components for the License Pre-Validation Service (LPVS) application.
* LPVS is an open-source tool designed to mitigate license-related risks in open-source projects.
* It analyzes the project, identifies components and licenses, and generates potential issue cases.
* The {@link com.lpvs.LicensePreValidationSystem} class is the main entry point for LPVS.
* The {@link com.lpvs.LicensePreValidationService} class is the main entry point for LPVS.
*
* <p>
* The LPVS project aims to assist developers in ensuring license compliance for their open-source code.
Expand Down
14 changes: 5 additions & 9 deletions src/main/resources/application-singlescan.properties
Original file line number Diff line number Diff line change
@@ -1,22 +1,18 @@
debug=false
logging.level.org.hibernate=error
spring.sql.init.mode=always
spring.datasource.initialization-mode=always

spring.h2.console.enabled=false
spring.sql.init.mode=always
spring.sql.init.platform=h2
# DB Configuration
# Whether to enable logging of SQL statements.
spring.jpa.show-sql=false

# DB Configuration
spring.sql.init.data-locations=classpath*:database_dump.sql

spring.datasource.initialization-mode=always
spring.datasource.url=jdbc:h2:mem:singlescan;DATABASE_TO_UPPER=false;MODE=MySQL;NON_KEYWORDS=USER
spring.datasource.username=
spring.datasource.password=

spring.jpa.properties.hibernate.format_sql=false
spring.jpa.properties.hibernate.use_sql_comments=false
spring.jpa.properties.hibernate.show_sql=false

spring.jpa.hibernate.ddl-auto=create-drop
spring.jpa.defer-datasource-initialization=true
spring.jpa.defer-datasource-initialization=true
36 changes: 36 additions & 0 deletions src/main/resources/application-web.properties
Original file line number Diff line number Diff line change
@@ -0,0 +1,36 @@
# Login Configuration
#Google
spring.security.oauth2.client.registration.google.client-id={YOUR_GOOGLE_CLIENT_ID}
spring.security.oauth2.client.registration.google.client-secret={YOUR_GOOGLE_CLIENT_SECRET}
spring.security.oauth2.client.registration.google.redirect-uri=http://localhost:7896/login/oauth2/code/google
spring.security.oauth2.client.registration.google.scope=profile, email

#Naver
spring.security.oauth2.client.registration.naver.client-id={YOUR_NAVER_CLIENT_ID}
spring.security.oauth2.client.registration.naver.client-secret={YOUR_NAVER_CLIENT_SECRET}
spring.security.oauth2.client.registration.naver.redirect-uri=http://localhost:7896/login/oauth2/code/naver
spring.security.oauth2.client.registration.naver.authorization-grant-type=authorization_code
spring.security.oauth2.client.registration.naver.scope=name, email, profile_image
spring.security.oauth2.client.registration.naver.client-name=Naver
#Provider-Naver
spring.security.oauth2.client.provider.naver.authorization-uri=https://nid.naver.com/oauth2.0/authorize
spring.security.oauth2.client.provider.naver.token-uri=https://nid.naver.com/oauth2.0/token
spring.security.oauth2.client.provider.naver.user-info-uri=https://openapi.naver.com/v1/nid/me
spring.security.oauth2.client.provider.naver.user-name-attribute=response

#Kakao
spring.security.oauth2.client.registration.kakao.client-id={YOUR_KAKAO_CLIENT_ID}
spring.security.oauth2.client.registration.kakao.redirect-uri=http://localhost:7896/login/oauth2/code/kakao
spring.security.oauth2.client.registration.kakao.client-authentication-method=POST
spring.security.oauth2.client.registration.kakao.authorization-grant-type = authorization_code
spring.security.oauth2.client.registration.kakao.scope=profile_nickname, profile_image, account_email
spring.security.oauth2.client.registration.kakao.client-name=Kakao
#Provider-Kakao
spring.security.oauth2.client.provider.kakao.authorization-uri=https://kauth.kakao.com/oauth/authorize
spring.security.oauth2.client.provider.kakao.token-uri=https://kauth.kakao.com/oauth/token
spring.security.oauth2.client.provider.kakao.user-info-uri=https://kapi.kakao.com/v2/user/me
spring.security.oauth2.client.provider.kakao.user-name-attribute=id

# Frontend Configuration
frontend.main-page.url=/
cors.allowed-origin=
37 changes: 0 additions & 37 deletions src/main/resources/application.properties
Original file line number Diff line number Diff line change
Expand Up @@ -46,40 +46,3 @@ spring.jpa.hibernate.ddl-auto=update
spring.datasource.url=jdbc:mysql://localhost:3306/lpvs
spring.datasource.username=
spring.datasource.password=

# Login Configuration
#Google
spring.security.oauth2.client.registration.google.client-id={YOUR_GOOGLE_CLIENT_ID}
spring.security.oauth2.client.registration.google.client-secret={YOUR_GOOGLE_CLIENT_SECRET}
spring.security.oauth2.client.registration.google.redirect-uri=http://localhost:7896/login/oauth2/code/google
spring.security.oauth2.client.registration.google.scope=profile, email

#Naver
spring.security.oauth2.client.registration.naver.client-id={YOUR_NAVER_CLIENT_ID}
spring.security.oauth2.client.registration.naver.client-secret={YOUR_NAVER_CLIENT_SECRET}
spring.security.oauth2.client.registration.naver.redirect-uri=http://localhost:7896/login/oauth2/code/naver
spring.security.oauth2.client.registration.naver.authorization-grant-type=authorization_code
spring.security.oauth2.client.registration.naver.scope=name, email, profile_image
spring.security.oauth2.client.registration.naver.client-name=Naver
#Provider-Naver
spring.security.oauth2.client.provider.naver.authorization-uri=https://nid.naver.com/oauth2.0/authorize
spring.security.oauth2.client.provider.naver.token-uri=https://nid.naver.com/oauth2.0/token
spring.security.oauth2.client.provider.naver.user-info-uri=https://openapi.naver.com/v1/nid/me
spring.security.oauth2.client.provider.naver.user-name-attribute=response

#Kakao
spring.security.oauth2.client.registration.kakao.client-id={YOUR_KAKAO_CLIENT_ID}
spring.security.oauth2.client.registration.kakao.redirect-uri=http://localhost:7896/login/oauth2/code/kakao
spring.security.oauth2.client.registration.kakao.client-authentication-method=POST
spring.security.oauth2.client.registration.kakao.authorization-grant-type = authorization_code
spring.security.oauth2.client.registration.kakao.scope=profile_nickname, profile_image, account_email
spring.security.oauth2.client.registration.kakao.client-name=Kakao
#Provider-Kakao
spring.security.oauth2.client.provider.kakao.authorization-uri=https://kauth.kakao.com/oauth/authorize
spring.security.oauth2.client.provider.kakao.token-uri=https://kauth.kakao.com/oauth/token
spring.security.oauth2.client.provider.kakao.user-info-uri=https://kapi.kakao.com/v2/user/me
spring.security.oauth2.client.provider.kakao.user-name-attribute=id

# Frontend Configuration
frontend.main-page.url=/
cors.allowed-origin=
Original file line number Diff line number Diff line change
Expand Up @@ -15,20 +15,20 @@
import static org.junit.jupiter.api.Assertions.assertEquals;
import static org.mockito.Mockito.*;

public class LicensePreValidationSystemTest {
public class LicensePreValidationServiceTest {
final int testNumCores = 42;
LicensePreValidationSystem licensePreValidationSystem;
LicensePreValidationService licensePreValidationService;

@BeforeEach
void setUp() {
licensePreValidationSystem = new LicensePreValidationSystem(42);
licensePreValidationService = new LicensePreValidationService(42);
}

@Test
public void testGetAsyncExecutor() {
try (MockedConstruction<ThreadPoolTaskExecutor> mocked =
mockConstruction(ThreadPoolTaskExecutor.class)) {
TaskExecutor executor = licensePreValidationSystem.getAsyncExecutor();
TaskExecutor executor = licensePreValidationService.getAsyncExecutor();

assertEquals(1, mocked.constructed().size());
ThreadPoolTaskExecutor mocked_constructed_executor = mocked.constructed().get(0);
Expand Down

0 comments on commit f7dddb7

Please sign in to comment.