From eb90712567e2f9730617b975b614a6d6e643f8e2 Mon Sep 17 00:00:00 2001 From: Harsh Vardhan Date: Mon, 14 Oct 2024 20:22:51 +0530 Subject: [PATCH] [INJICERT-434] fix integration test Signed-off-by: Harsh Vardhan --- .../src/main/java/io/mosip/certify/config/AppConfig.java | 1 + .../io/mosip/certify/services/KeyManagerConstants.java | 9 +++++++++ .../src/test/resources/application-test.properties | 5 ++++- certify-service/src/test/resources/data.sql | 2 +- certify-service/src/test/resources/schema.sql | 7 +++++++ db_scripts/mosip_certify/ddl/template_data.sql | 6 ++++++ 6 files changed, 28 insertions(+), 2 deletions(-) create mode 100644 certify-service/src/main/java/io/mosip/certify/services/KeyManagerConstants.java create mode 100644 db_scripts/mosip_certify/ddl/template_data.sql diff --git a/certify-service/src/main/java/io/mosip/certify/config/AppConfig.java b/certify-service/src/main/java/io/mosip/certify/config/AppConfig.java index 75cb9bab..265d30ae 100644 --- a/certify-service/src/main/java/io/mosip/certify/config/AppConfig.java +++ b/certify-service/src/main/java/io/mosip/certify/config/AppConfig.java @@ -87,6 +87,7 @@ public void run(ApplicationArguments args) throws Exception { // TODO: Generate an EC & ED key via K8s Job(INJICERT-469) KeyPairGenerateRequestDto rsaKeyRequest = new KeyPairGenerateRequestDto(); rsaKeyRequest.setApplicationId(Constants.CERTIFY_MOCK_RSA); + rsaKeyRequest.setReferenceId(Constants.EMPTY_REF_ID); rsaKeyRequest.setForce(false); keymanagerService.generateMasterKey("certificate", rsaKeyRequest); if(!StringUtils.isEmpty(cacheSecretKeyRefId)) { diff --git a/certify-service/src/main/java/io/mosip/certify/services/KeyManagerConstants.java b/certify-service/src/main/java/io/mosip/certify/services/KeyManagerConstants.java new file mode 100644 index 00000000..f9f22fc8 --- /dev/null +++ b/certify-service/src/main/java/io/mosip/certify/services/KeyManagerConstants.java @@ -0,0 +1,9 @@ +package io.mosip.certify.services; + +public class KeyManagerConstants { + public static final String VC_SIGN_ALGO = "VCsignAlgo"; + public static final String PUBLIC_KEY_URL = "publicKeyURL"; + public static final String KEY_APP_ID = "keyAppId"; + public static final String KEY_REF_ID = "keyRefId"; + public static final String KEYMGR_SIGN_ALGO = "KeyMgrSignAlgo"; +} diff --git a/certify-service/src/test/resources/application-test.properties b/certify-service/src/test/resources/application-test.properties index 3e05675a..909f76df 100644 --- a/certify-service/src/test/resources/application-test.properties +++ b/certify-service/src/test/resources/application-test.properties @@ -7,10 +7,12 @@ mosip.certify.integration.scan-base-package=io.mosip.certify mosip.certify.integration.audit-plugin=TestAuditPlugin mosip.certify.integration.vci-plugin=TestVCIPluginImpl +mosip.certify.dataprovider.types={'MockVerifiableCredential','StudentCredential','UniversityCredential'} ## ------------------------------------------ Discovery openid-configuration ------------------------------------------- mosipbox.public.url=http://localhost:8090 mosip.certify.discovery.issuer-id=${mosipbox.public.url}${server.servlet.path} +mosip.certify.pub.key=http://localhost/pub.key.json ##--------------------------------------------------------------------------------------------------------------------- spring.autoconfigure.exclude=org.springframework.boot.autoconfigure.security.servlet.SecurityAutoConfiguration,org.springframework.boot.actuate.autoconfigure.security.servlet.ManagementWebSecurityAutoConfiguration @@ -23,6 +25,7 @@ mosip.certify.authn.filter-urls={ '${server.servlet.path}/issuance/credential' } mosip.certify.authn.issuer-uri=${mosipbox.public.url}${server.servlet.path} mosip.certify.authn.jwk-set-uri=${mosipbox.public.url}${server.servlet.path}/oauth/.well-known/jwks.json mosip.certify.authn.allowed-audiences={ '${mosipbox.public.url}${server.servlet.path}/issuance/credential' } +mosip.certify.mock.authenticator.get-identity-url=http://localhost:8082/v1/mock-identity-system/identity mosip.certify.supported.jwt-proof-alg={'RS256'} mosip.certify.key-values={\ @@ -282,4 +285,4 @@ spring.datasource.driverClassName=org.h2.Driver spring.datasource.username=test spring.datasource.password=test -spring.jpa.properties.hibernate.jdbc.lob.non_contextual_creation=true \ No newline at end of file +spring.jpa.properties.hibernate.jdbc.lob.non_contextual_creation=true diff --git a/certify-service/src/test/resources/data.sql b/certify-service/src/test/resources/data.sql index 87d0ebbd..ee9d9314 100644 --- a/certify-service/src/test/resources/data.sql +++ b/certify-service/src/test/resources/data.sql @@ -1,2 +1,2 @@ -MERGE INTO KEY_POLICY_DEF (APP_ID,KEY_VALIDITY_DURATION,PRE_EXPIRE_DAYS,ACCESS_ALLOWED,IS_ACTIVE,CR_BY,CR_DTIMES) KEY(APP_ID) VALUES ('ROOT', 1095, 50, 'NA', true, 'mosipadmin', now()), ('CERTIFY_SERVICE', 1095, 50, 'NA', true, 'mosipadmin', now()), ('CERTIFY_PARTNER', 1095, 50, 'NA', true, 'mosipadmin', now()); +MERGE INTO KEY_POLICY_DEF (APP_ID,KEY_VALIDITY_DURATION,PRE_EXPIRE_DAYS,ACCESS_ALLOWED,IS_ACTIVE,CR_BY,CR_DTIMES) KEY(APP_ID) VALUES ('ROOT', 1095, 50, 'NA', true, 'mosipadmin', now()), ('CERTIFY_SERVICE', 1095, 50, 'NA', true, 'mosipadmin', now()), ('CERTIFY_PARTNER', 1095, 50, 'NA', true, 'mosipadmin', now()), ('CERTIFY_MOCK_RSA', 1095, 50, 'NA', true, 'mosipadmin', now()); diff --git a/certify-service/src/test/resources/schema.sql b/certify-service/src/test/resources/schema.sql index fdfcf541..119f315c 100644 --- a/certify-service/src/test/resources/schema.sql +++ b/certify-service/src/test/resources/schema.sql @@ -45,3 +45,10 @@ CREATE TABLE IF NOT EXISTS key_store( del_dtimes timestamp, CONSTRAINT pk_keystr_id PRIMARY KEY (id) ); + +CREATE TABLE IF NOT EXISTS template_data( + context character varying(1024) NOT NULL, + credential_type character varying(512) NOT NULL, + template VARCHAR NOT NULL, + CONSTRAINT pk_template PRIMARY KEY (context, credential_type) +); diff --git a/db_scripts/mosip_certify/ddl/template_data.sql b/db_scripts/mosip_certify/ddl/template_data.sql new file mode 100644 index 00000000..212e1290 --- /dev/null +++ b/db_scripts/mosip_certify/ddl/template_data.sql @@ -0,0 +1,6 @@ +CREATE TABLE IF NOT EXISTS template_data( + context character varying(1024) NOT NULL, + credential_type character varying(512) NOT NULL, + template VARCHAR NOT NULL, + CONSTRAINT pk_template PRIMARY KEY (context, credential_type) +);