Skip to content

Commit

Permalink
ES-2130 ES-2142 ES-2143 (#511)
Browse files Browse the repository at this point in the history
* ES-2130 ES-2142 ES-2143

Signed-off-by: ase-101 <sunkadaeanusha@gmail.com>

* ES-2130 ES-2142 ES-2143

Signed-off-by: ase-101 <sunkadaeanusha@gmail.com>

* ES-2130 ES-2142 ES-2143

Signed-off-by: ase-101 <sunkadaeanusha@gmail.com>

* ES-2130 ES-2142 ES-2143

Signed-off-by: ase-101 <sunkadaeanusha@gmail.com>

* ES-2130 ES-2142 ES-2143

Signed-off-by: ase-101 <sunkadaeanusha@gmail.com>

---------

Signed-off-by: ase-101 <sunkadaeanusha@gmail.com>
  • Loading branch information
ase-101 authored Jan 15, 2025
1 parent 4df69ca commit f99c94c
Show file tree
Hide file tree
Showing 14 changed files with 225 additions and 62 deletions.
7 changes: 3 additions & 4 deletions docker-compose/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -5,10 +5,9 @@ This is the docker-compose setup to run eSignet Signup service with mock identit
## Run signup service in local with all its dependencies

1. Run `docker compose --file dependent-docker-compose.yml up` to start all the dependent services.
2. Go to command line for the project root directory and run `mvn clean install -Dgpg.skip=true -DskipTests=true`
3. Add [esignet-mock-plugin.jar](../signup-service/target/signup-plugins/esignet-mock-plugin.jar) to signup-service classpath in your IDE.
4. Add [kernel-auth-adapter-lite.jar](../signup-service/target/signup-plugins/kernel-auth-adapter-lite.jar) to signup-service classpath in your IDE.
5. Update below properties in [application-local.properties](../signup-service/src/main/resources/application-local.properties) with valid values:
2. Go to [signup-with-plugins](../signup-with-plugins) folder and run `mvn clean install -Dgpg.skip=true` from the command line.
3. Add [esignet-mock-plugin.jar](../signup-with-plugins/target/esignet-mock-plugin.jar) to signup-service classpath in your IDE.
4. Update below properties in [application-local.properties](../signup-service/src/main/resources/application-local.properties) with valid values:

mosip.internal.domain.url=https://api-internal.dev.mosip.net

Expand Down
2 changes: 1 addition & 1 deletion docker-compose/dependent-docker-compose.yml
Original file line number Diff line number Diff line change
Expand Up @@ -54,7 +54,7 @@ services:


esignet:
image: 'mosipdev/esignet:release-1.5.x'
image: 'mosipdev/esignet-with-plugins:release-1.5.x'
user: root
ports:
- 8088:8088
Expand Down
7 changes: 2 additions & 5 deletions signup-service/Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -55,14 +55,11 @@ RUN apt-get -y update \
&& chmod +x configure_start.sh \
&& chown -R ${container_user}:${container_user} /home/${container_user}

# copy all files under target/esignet-plugins to the plugins folder
COPY ./target/*-plugin.jar ${plugins_path}
COPY ./target/kernel-auth-adapter-lite.jar ${loader_path}

# select container user for all tasks
USER ${container_user_uid}:${container_user_gid}

EXPOSE 8089

ENTRYPOINT [ "./configure_start.sh" ]
CMD java -jar -Dloader.path="${loader_path_env}" -Dspring.cloud.config.label="${spring_config_label_env}" -Dspring.profiles.active="${active_profile_env}" -Dspring.cloud.config.uri="${spring_config_url_env}" signup-service.jar

CMD ["java", "-jar", "-Dloader.path=${loader_path_env}", "-Dspring.cloud.config.label=${spring_config_label_env}", "-Dspring.profiles.active=${active_profile_env}", "-Dspring.cloud.config.uri=${spring_config_url_env}", "signup-service.jar"]
51 changes: 6 additions & 45 deletions signup-service/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -200,6 +200,12 @@
<artifactId>shedlock-provider-redis-spring</artifactId>
<version>4.47.0</version>
</dependency>

<dependency>
<groupId>io.mosip.kernel</groupId>
<artifactId>kernel-auth-adapter-lite</artifactId>
<version>1.2.0.1-B4</version>
</dependency>
</dependencies>

<build>
Expand All @@ -221,51 +227,6 @@
</execution>
</executions>
</plugin>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-dependency-plugin</artifactId>
<version>3.5.0</version>
<executions>
<execution>
<id>copy</id>
<phase>package</phase>
<goals>
<goal>copy</goal>
</goals>
</execution>
</executions>
<configuration>
<artifactItems>
<artifactItem>
<groupId>io.mosip.kernel</groupId>
<artifactId>kernel-auth-adapter-lite</artifactId>
<version>${kernel-auth-adapter-lite.version}</version>
<outputDirectory>${signup-plugins.location}</outputDirectory>
<destFileName>${kernel-auth-adapter-lite.fileName}</destFileName>
<type>jar</type>
</artifactItem>
<artifactItem>
<groupId>io.mosip.esignet</groupId>
<artifactId>mosip-identity-plugin</artifactId>
<version>${mosip-identity-plugin.version}</version>
<outputDirectory>${signup-plugins.location}</outputDirectory>
<destFileName>${mosip-identity-plugin.fileName}</destFileName>
<type>jar</type>
</artifactItem>
<artifactItem>
<groupId>io.mosip.esignet</groupId>
<artifactId>mock-plugin</artifactId>
<version>${signup-mock-plugin.version}</version>
<outputDirectory>${signup-plugins.location}</outputDirectory>
<destFileName>${signup-mock-plugin.fileName}</destFileName>
<type>jar</type>
</artifactItem>
</artifactItems>
<overWriteReleases>true</overWriteReleases>
<overWriteSnapshots>true</overWriteSnapshots>
<overWriteIfNewer>true</overWriteIfNewer>
</configuration>
</plugin>
</plugins>
</build>

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,13 +7,15 @@

import com.fasterxml.jackson.core.JsonProcessingException;
import com.fasterxml.jackson.databind.ObjectMapper;
import io.mosip.kernel.auth.defaultadapter.config.SecurityConfig;
import org.junit.jupiter.api.Test;
import org.junit.runner.RunWith;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.boot.autoconfigure.security.servlet.SecurityAutoConfiguration;
import org.springframework.boot.test.autoconfigure.web.servlet.WebMvcTest;
import org.springframework.boot.test.mock.mockito.MockBean;
import org.springframework.context.annotation.Profile;
import org.springframework.context.annotation.ComponentScan;
import org.springframework.context.annotation.FilterType;
import org.springframework.http.MediaType;
import org.springframework.security.web.csrf.CsrfToken;
import org.springframework.security.web.csrf.DefaultCsrfToken;
Expand All @@ -25,7 +27,9 @@
import static org.springframework.test.web.servlet.result.MockMvcResultMatchers.status;

@RunWith(SpringRunner.class)
@WebMvcTest(value = CsrfController.class, excludeAutoConfiguration = {SecurityAutoConfiguration.class})
@WebMvcTest(value = CsrfController.class,
excludeFilters = @ComponentScan.Filter(type = FilterType.ASSIGNABLE_TYPE, classes = {SecurityConfig.class}),
excludeAutoConfiguration = {SecurityAutoConfiguration.class})
class CsrfControllerTest {

@Autowired
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@

import com.fasterxml.jackson.databind.ObjectMapper;
import com.fasterxml.jackson.databind.node.ObjectNode;
import io.mosip.kernel.auth.defaultadapter.config.SecurityConfig;
import io.mosip.signup.dto.*;
import io.mosip.esignet.core.dto.RequestWrapper;
import io.mosip.signup.dto.InitiateIdentityVerificationRequest;
Expand All @@ -26,6 +27,8 @@
import org.springframework.boot.autoconfigure.security.servlet.SecurityAutoConfiguration;
import org.springframework.boot.test.autoconfigure.web.servlet.WebMvcTest;
import org.springframework.boot.test.mock.mockito.MockBean;
import org.springframework.context.annotation.ComponentScan;
import org.springframework.context.annotation.FilterType;
import org.springframework.http.MediaType;
import org.springframework.test.context.ActiveProfiles;
import org.springframework.test.context.junit4.SpringRunner;
Expand All @@ -38,7 +41,9 @@
import java.time.format.DateTimeFormatter;

@RunWith(SpringRunner.class)
@WebMvcTest(value = IdentityVerificationController.class, excludeAutoConfiguration = {SecurityAutoConfiguration.class})
@WebMvcTest(value = IdentityVerificationController.class,
excludeFilters = @ComponentScan.Filter(type = FilterType.ASSIGNABLE_TYPE, classes = {SecurityConfig.class}),
excludeAutoConfiguration = {SecurityAutoConfiguration.class})
@ActiveProfiles(value = {"test"})
public class IdentityVerificationControllerTest {

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@
import io.mosip.esignet.core.dto.RequestWrapper;
import io.mosip.esignet.core.exception.EsignetException;
import io.mosip.esignet.core.util.IdentityProviderUtil;
import io.mosip.kernel.auth.defaultadapter.config.SecurityConfig;
import io.mosip.signup.api.dto.ProfileDto;
import io.mosip.signup.api.exception.InvalidProfileException;
import io.mosip.signup.api.spi.ProfileRegistryPlugin;
Expand All @@ -28,6 +29,8 @@
import org.springframework.boot.autoconfigure.security.servlet.SecurityAutoConfiguration;
import org.springframework.boot.test.autoconfigure.web.servlet.WebMvcTest;
import org.springframework.boot.test.mock.mockito.MockBean;
import org.springframework.context.annotation.ComponentScan;
import org.springframework.context.annotation.FilterType;
import org.springframework.http.MediaType;
import org.springframework.test.context.ActiveProfiles;
import org.springframework.test.context.junit4.SpringRunner;
Expand Down Expand Up @@ -55,7 +58,9 @@


@RunWith(SpringRunner.class)
@WebMvcTest(value = RegistrationController.class, excludeAutoConfiguration = {SecurityAutoConfiguration.class})
@WebMvcTest(value = RegistrationController.class,
excludeFilters = @ComponentScan.Filter(type = FilterType.ASSIGNABLE_TYPE, classes = {SecurityConfig.class}),
excludeAutoConfiguration = {SecurityAutoConfiguration.class})
@ActiveProfiles(value = {"test"})
public class RegistrationControllerTest {

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@

import com.fasterxml.jackson.databind.ObjectMapper;
import io.mosip.esignet.core.dto.RequestWrapper;
import io.mosip.kernel.auth.defaultadapter.config.SecurityConfig;
import io.mosip.signup.api.util.ProfileCreateUpdateStatus;
import io.mosip.signup.dto.RegistrationStatusResponse;
import io.mosip.signup.dto.ResetPasswordRequest;
Expand All @@ -20,6 +21,8 @@
import org.springframework.boot.autoconfigure.security.servlet.SecurityAutoConfiguration;
import org.springframework.boot.test.autoconfigure.web.servlet.WebMvcTest;
import org.springframework.boot.test.mock.mockito.MockBean;
import org.springframework.context.annotation.ComponentScan;
import org.springframework.context.annotation.FilterType;
import org.springframework.http.MediaType;
import org.springframework.test.context.ActiveProfiles;
import org.springframework.test.context.junit4.SpringRunner;
Expand All @@ -39,7 +42,9 @@


@RunWith(SpringRunner.class)
@WebMvcTest(value = ResetPasswordController.class, excludeAutoConfiguration = {SecurityAutoConfiguration.class})
@WebMvcTest(value = ResetPasswordController.class,
excludeFilters = @ComponentScan.Filter(type = FilterType.ASSIGNABLE_TYPE, classes = {SecurityConfig.class}),
excludeAutoConfiguration = {SecurityAutoConfiguration.class})
@ActiveProfiles(value = {"test"})
public class ResetPasswordControllerTest {

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@
package io.mosip.signup.controllers;

import com.fasterxml.jackson.databind.ObjectMapper;
import io.mosip.kernel.auth.defaultadapter.config.SecurityConfig;
import io.mosip.signup.helper.AuditHelper;
import io.mosip.signup.services.RegistrationService;
import org.junit.Test;
Expand All @@ -14,6 +15,8 @@
import org.springframework.boot.autoconfigure.security.servlet.SecurityAutoConfiguration;
import org.springframework.boot.test.autoconfigure.web.servlet.WebMvcTest;
import org.springframework.boot.test.mock.mockito.MockBean;
import org.springframework.context.annotation.ComponentScan;
import org.springframework.context.annotation.FilterType;
import org.springframework.http.MediaType;
import org.springframework.test.context.ActiveProfiles;
import org.springframework.test.context.junit4.SpringRunner;
Expand All @@ -26,7 +29,9 @@


@RunWith(SpringRunner.class)
@WebMvcTest(value = SignUpController.class, excludeAutoConfiguration = {SecurityAutoConfiguration.class})
@WebMvcTest(value = SignUpController.class,
excludeFilters = @ComponentScan.Filter(type = FilterType.ASSIGNABLE_TYPE, classes = {SecurityConfig.class}),
excludeAutoConfiguration = {SecurityAutoConfiguration.class})
@ActiveProfiles(value = {"test"})
public class SignUpControllerTest {

Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
package io.mosip.signup.controllers;

import io.mosip.kernel.auth.defaultadapter.config.SecurityConfig;
import io.mosip.signup.api.dto.IdentityVerificationResult;
import io.mosip.signup.api.exception.IdentityVerifierException;
import io.mosip.signup.api.util.VerificationStatus;
Expand All @@ -19,6 +20,8 @@
import org.springframework.boot.autoconfigure.security.servlet.SecurityAutoConfiguration;
import org.springframework.boot.test.autoconfigure.web.servlet.WebMvcTest;
import org.springframework.boot.test.mock.mockito.MockBean;
import org.springframework.context.annotation.ComponentScan;
import org.springframework.context.annotation.FilterType;
import org.springframework.test.context.ActiveProfiles;
import org.springframework.test.context.junit4.SpringRunner;
import org.springframework.test.util.ReflectionTestUtils;
Expand All @@ -33,7 +36,9 @@


@RunWith(SpringRunner.class)
@WebMvcTest(value = WebSocketController.class, excludeAutoConfiguration = {SecurityAutoConfiguration.class})
@WebMvcTest(value = WebSocketController.class,
excludeFilters = @ComponentScan.Filter(type = FilterType.ASSIGNABLE_TYPE, classes = {SecurityConfig.class}),
excludeAutoConfiguration = {SecurityAutoConfiguration.class})
@ActiveProfiles(value = {"test"})
public class WebSocketControllerTest {

Expand Down
2 changes: 2 additions & 0 deletions signup-service/src/test/resources/application-test.properties
Original file line number Diff line number Diff line change
Expand Up @@ -98,6 +98,8 @@ mosip.iam.adapter.self-token-renewal-enable=true
mosip.service-context=${server.servlet.context-path}
mosip.service.end-points=/**/*
mosip.service.exclude.auth.allowed.method=GET,POST
mosip.security.csrf-enable=false
mosip.security.cors-enable=false

## -------------------------- External endpoints -----------------------------------------------------------------------
mosip.signup.integration.impl.basepackage=io.signup.plugin.mosipid
Expand Down
4 changes: 4 additions & 0 deletions signup-with-plugins/Dockerfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
FROM mosipdev/signup-service:develop

# copy all files under target to the plugins folder
COPY ./target/*.jar ${plugins_path_env}
16 changes: 16 additions & 0 deletions signup-with-plugins/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
## Signup service with plugins docker

This directory contains files required to build the Signup docker with default plugins preloaded. All the plugins
available under [esignet-plugins](https://github.com/mosip/esignet-plugins) repository is included in the "signup-with-plugins" docker image.

Based on the configured plugin name during the runtime, corresponding plugin jar will be copied to the Signup service
classpath from the plugins directory in the docker container.
For example, "plugin_name_env" environment variable is set to "esignet-mock-plugin.jar", then "esignet-mock-plugin.jar" is copied
to loader_path in the signup service container. After successful copy Signup service is started.

"signup-with-plugins" docker image is created with "signup-service" base image. The base image can also be directly used to start the signup
service. Mount external directory with the plugin onto "/home/mosip/plugins" directory in the container and finally set "plugin_name_env" environment variable.
With this setup, signup service should get started with the configured plugin.

## License
This project is licensed under the terms of [Mozilla Public License 2.0](../LICENSE).
Loading

0 comments on commit f99c94c

Please sign in to comment.