From 6108e59ed58137c1fae6888bce8223d62dfaa494 Mon Sep 17 00:00:00 2001 From: anilgupta Date: Mon, 10 Jul 2023 18:41:41 +0530 Subject: [PATCH 01/14] Issue #LR-627 feat: Removed the dead code from the repo to make it cloud agnostic. --- .../main/java/org/sunbird/keys/JsonKey.java | 2 - .../java/org/sunbird/util/ProjectUtil.java | 38 +++++-------------- .../resources/externalresource.properties | 3 -- .../org/sunbird/util/ProjectUtilTest.java | 2 - helm/learner/templates/configmap.yaml | 13 ------- helm/learner/values.yaml | 5 --- .../org/sunbird/util/DataCacheHandler.java | 13 +++---- 7 files changed, 14 insertions(+), 62 deletions(-) diff --git a/core/platform-common/src/main/java/org/sunbird/keys/JsonKey.java b/core/platform-common/src/main/java/org/sunbird/keys/JsonKey.java index 08fa0316c6..64beaad0d3 100644 --- a/core/platform-common/src/main/java/org/sunbird/keys/JsonKey.java +++ b/core/platform-common/src/main/java/org/sunbird/keys/JsonKey.java @@ -414,8 +414,6 @@ public final class JsonKey { public static final String SUNBIRD_GZIP_ENABLE = "sunbird_gzip_enable"; public static final String SUNBIRD_SYNC_READ_WAIT_TIME = "sunbird_sync_read_wait_time"; public static final String SUNBIRD_GZIP_SIZE_THRESHOLD = "sunbird_gzip_size_threshold"; - public static final String ANALYTICS_ACCOUNT_NAME = "sunbird_analytics_blob_account_name"; - public static final String ANALYTICS_ACCOUNT_KEY = "sunbird_analytics_blob_account_key"; public static final String SIGNUP_TYPE = "signupType"; public static final String REQUEST_SOURCE = "source"; diff --git a/core/platform-common/src/main/java/org/sunbird/util/ProjectUtil.java b/core/platform-common/src/main/java/org/sunbird/util/ProjectUtil.java index 47d4b15b2e..52e0666598 100644 --- a/core/platform-common/src/main/java/org/sunbird/util/ProjectUtil.java +++ b/core/platform-common/src/main/java/org/sunbird/util/ProjectUtil.java @@ -4,20 +4,6 @@ import com.google.i18n.phonenumbers.NumberParseException; import com.google.i18n.phonenumbers.PhoneNumberUtil; import com.google.i18n.phonenumbers.Phonenumber; -import java.io.IOException; -import java.text.MessageFormat; -import java.text.ParseException; -import java.text.SimpleDateFormat; -import java.util.Arrays; -import java.util.Date; -import java.util.HashMap; -import java.util.List; -import java.util.Map; -import java.util.Random; -import java.util.UUID; -import java.util.concurrent.atomic.AtomicInteger; -import java.util.regex.Matcher; -import java.util.regex.Pattern; import org.apache.commons.lang3.StringUtils; import org.apache.velocity.VelocityContext; import org.sunbird.exception.ProjectCommonException; @@ -27,6 +13,15 @@ import org.sunbird.request.Request; import org.sunbird.request.RequestContext; +import java.io.IOException; +import java.text.MessageFormat; +import java.text.ParseException; +import java.text.SimpleDateFormat; +import java.util.*; +import java.util.concurrent.atomic.AtomicInteger; +import java.util.regex.Matcher; +import java.util.regex.Pattern; + /** * This class will contains all the common utility methods. * @@ -288,21 +283,6 @@ public static SimpleDateFormat getDateFormatter() { return simpleDateFormat; } - /** @author Manzarul */ - public enum AzureContainer { - userProfileImg("userprofileimg"), - orgImage("orgimg"); - private String name; - - private AzureContainer(String name) { - this.name = name; - } - - public String getName() { - return name; - } - } - public static VelocityContext getContext(Map map) { propertiesCache = PropertiesCache.getInstance(); VelocityContext context = new VelocityContext(); diff --git a/core/platform-common/src/main/resources/externalresource.properties b/core/platform-common/src/main/resources/externalresource.properties index 0f4f0d02a9..dd60239686 100644 --- a/core/platform-common/src/main/resources/externalresource.properties +++ b/core/platform-common/src/main/resources/externalresource.properties @@ -61,8 +61,6 @@ sunbird_rate_limit_enabled=true sunbird_health_check_enable=true sunbird_sync_read_wait_time=1500 sunbird_gzip_size_threshold=262144 -sunbird_analytics_blob_account_name= -sunbird_analytics_blob_account_key= kafka_urls=localhost:9092 sunbird_fuzzy_search_threshold=0.5 sunbird_state_img_url=https://sunbirddev.blob.core.windows.net/orgemailtemplate/img/File-0128212938260643843.png @@ -105,4 +103,3 @@ channel_registration_disabled=false sunbird_password_reset_login_page_url=/resources isFormValidationRequired=true userProfileConfigMap={\"type\":\"profileconfig\",\"subtype\":\"28\",\"action\":\"get\",\"component\":\"*\",\"framework\":\"*\",\"data\":{\"templateName\":\"profileConfig_v2\",\"action\":\"get\",\"fields\":[{\"code\":\"persona\",\"children\":{\"administrator\":[{\"code\":\"district\"},{\"code\":\"state\"},{\"code\":\"subPersona\",\"type\":\"select\",\"default\":null,\"templateOptions\":{\"options\":[{\"label\":\"Headmaster\",\"value\":\"hm\"},{\"label\":\"Cluster Resource Person\",\"value\":\"crp\"}]}},{\"code\":\"block\"},{\"code\":\"cluster\"},{\"code\":\"school\"}],\"teacher\":[{\"code\":\"state\"},{\"code\":\"district\"},{\"code\":\"block\"},{\"code\":\"cluster\"},{\"code\":\"school\"}],\"student\":[{\"code\":\"state\"},{\"code\":\"district\"},{\"code\":\"block\"},{\"code\":\"cluster\"},{\"code\":\"school\"}],\"parent\":[{\"code\":\"state\"},{\"code\":\"district\"},{\"code\":\"block\"},{\"code\":\"cluster\"},{\"code\":\"school\"}],\"other\":[{\"code\":\"state\"},{\"code\":\"district\"},{\"code\":\"subPersona\",\"templateOptions\":{\"options\":[{\"value\":\"Doctor (Allopathy)\",\"label\":\"Doctor (Allopathy)\"},{\"value\":\"AYUSH Professional\",\"label\":\"AYUSH Professional\"}]}},{\"code\":\"block\"},{\"code\":\"cluster\"},{\"code\":\"school\"}]}}]},\"created_on\":\"2022-02-10T14:16:51.852Z\",\"last_modified_on\":\"2022-11-14T05:45:02.685Z\",\"rootOrgId\":\"*\"} -sunbird_cloud_service_provider=azure diff --git a/core/platform-common/src/test/java/org/sunbird/util/ProjectUtilTest.java b/core/platform-common/src/test/java/org/sunbird/util/ProjectUtilTest.java index 70c0c76d39..d843436fa7 100644 --- a/core/platform-common/src/test/java/org/sunbird/util/ProjectUtilTest.java +++ b/core/platform-common/src/test/java/org/sunbird/util/ProjectUtilTest.java @@ -241,8 +241,6 @@ public void testStatusSuccess() { assertEquals(0, ProjectUtil.Status.INACTIVE.getValue()); assertFalse(ProjectUtil.ActiveStatus.INACTIVE.getValue()); assertTrue(ProjectUtil.ActiveStatus.ACTIVE.getValue()); - assertEquals("orgimg", ProjectUtil.AzureContainer.orgImage.getName()); - assertEquals("userprofileimg", ProjectUtil.AzureContainer.userProfileImg.getName()); assertEquals("username", ProjectUtil.UserLookupType.USERNAME.getType()); assertEquals("email", ProjectUtil.UserLookupType.EMAIL.getType()); diff --git a/helm/learner/templates/configmap.yaml b/helm/learner/templates/configmap.yaml index f5ab89b07d..f39a2e88c4 100644 --- a/helm/learner/templates/configmap.yaml +++ b/helm/learner/templates/configmap.yaml @@ -67,18 +67,6 @@ data: {{- printf "ERROR | %s | Please provide a value for \"cloud_public_storage_secret\"" .Chart.Name | fail }} {{- end }} - sunbird_analytics_blob_account_name: {{ if .Values.cloud_private_storage_accountname }} - {{- .Values.cloud_private_storage_accountname }} - {{- else -}} - {{- printf "ERROR | %s | Please provide a value for \"cloud_private_storage_accountname\"" .Chart.Name | fail }} - {{- end }} - - sunbird_analytics_blob_account_key: {{ if .Values.cloud_private_storage_secret }} - {{- .Values.cloud_private_storage_secret }} - {{- else -}} - {{- printf "ERROR | %s | Please provide a value for \"cloud_private_storage_secret\"" .Chart.Name | fail }} - {{- end }} - sunbird_cloud_service_provider: {{ if eq (include "common.csp.validation" .Values.cloud_service_provider) "true" }} {{- .Values.cloud_service_provider }} {{- else -}} @@ -220,7 +208,6 @@ data: sunbird_cassandra_port: {{ .Values.sunbird_cassandra_port | quote }} sunbird_cassandra_username: {{ .Values.sunbird_cassandra_username }} sunbird_cert_service_base_url: {{ .Values.sunbird_cert_service_base_url }} - sunbird_content_azure_storage_container: {{ .Values.sunbird_content_azure_storage_container }} sunbird_course_batch_notification_enabled: {{ .Values.sunbird_course_batch_notification_enabled | quote }} sunbird_course_batch_notification_signature: {{ .Values.sunbird_course_batch_notification_signature }} sunbird_cs_search_path: {{ .Values.sunbird_cs_search_path }} diff --git a/helm/learner/values.yaml b/helm/learner/values.yaml index 403a271a58..32d03df656 100644 --- a/helm/learner/values.yaml +++ b/helm/learner/values.yaml @@ -91,7 +91,6 @@ sunbird_cassandra_port: 9042 sunbird_cassandra_username: admin sunbird_cert_service_base_url: http://cert-service.lern.svc.cluster.local:9000 ## Storage bucket name where the contents are stores -sunbird_content_azure_storage_container: contents sunbird_course_batch_notification_enabled: true sunbird_course_batch_notification_signature: sunbird sunbird_cs_search_path: /v1/content/search @@ -314,10 +313,6 @@ initcontainer_resources: # sunbird_account_name: "" # sunbird_account_key: "" -## Refers to private storage bucket details -# sunbird_analytics_blob_account_name: "" -# sunbird_analytics_blob_account_key: "" - ## Uses the keycloak lms client from sunbird realm #sunbird_sso_client_id: lms #sunbird_sso_realm: sunbird \ No newline at end of file diff --git a/service/src/main/java/org/sunbird/util/DataCacheHandler.java b/service/src/main/java/org/sunbird/util/DataCacheHandler.java index c847ccedef..99f69f0f3d 100644 --- a/service/src/main/java/org/sunbird/util/DataCacheHandler.java +++ b/service/src/main/java/org/sunbird/util/DataCacheHandler.java @@ -1,15 +1,7 @@ package org.sunbird.util; -import com.fasterxml.jackson.core.JsonProcessingException; import com.fasterxml.jackson.core.type.TypeReference; -import com.fasterxml.jackson.databind.JsonMappingException; import com.fasterxml.jackson.databind.ObjectMapper; -import java.util.*; -import java.util.concurrent.ConcurrentHashMap; -import java.util.concurrent.CopyOnWriteArrayList; -import java.util.stream.Collectors; - -import com.microsoft.azure.storage.core.Logger; import org.apache.commons.collections.MapUtils; import org.apache.commons.collections4.CollectionUtils; import org.apache.commons.lang3.StringUtils; @@ -23,6 +15,11 @@ import org.sunbird.response.Response; import org.sunbird.service.role.RoleService; +import java.util.*; +import java.util.concurrent.ConcurrentHashMap; +import java.util.concurrent.CopyOnWriteArrayList; +import java.util.stream.Collectors; + /** * This class will handle the data cache. * From 7a47079e5e8a8188b558f6432b5a179fad15b99f Mon Sep 17 00:00:00 2001 From: anilgupta Date: Mon, 24 Jul 2023 13:08:41 +0530 Subject: [PATCH 02/14] Issue #LR-627 feat: Pass the cloud-store-sdk dependency from mvn command. --- .circleci/config.yml | 2 +- Dockerfile.Build | 2 +- Jenkinsfile | 4 ++-- README.md | 2 +- auto_build_deploy | 2 +- controller/pom.xml | 2 +- core/es-utils/pom.xml | 2 +- core/notification-utils/dependency-reduced-pom.xml | 2 +- core/notification-utils/pom.xml | 2 +- core/platform-common/pom.xml | 10 +++++----- pom.xml | 2 +- setup.md | 2 +- 12 files changed, 17 insertions(+), 17 deletions(-) diff --git a/.circleci/config.yml b/.circleci/config.yml index 1bb1be47ff..2cca91e107 100644 --- a/.circleci/config.yml +++ b/.circleci/config.yml @@ -7,7 +7,7 @@ jobs: - checkout - restore_cache: key: lms-dependency-cache-{{ checksum "pom.xml" }} - - run: mvn clean install + - run: mvn clean install -DCLOUD_STORAGE_GROUP_ID=org.sunbird -DCLOUD_STORAGE_ARTIFACT_ID=cloud-store-sdk -DCLOUD_STORAGE_VERSION=1.4.6 - run: cd controller && mvn play2:dist - save_cache: key: lms-dependency-cache-{{ checksum "pom.xml" }} diff --git a/Dockerfile.Build b/Dockerfile.Build index 245be1eaf8..3e4737dcbe 100644 --- a/Dockerfile.Build +++ b/Dockerfile.Build @@ -10,6 +10,6 @@ ENV M2_HOME /opt/apache-maven-3.3.9 ENV PATH ${M2_HOME}/bin:${PATH} COPY learner /opt/learner/ WORKDIR /opt/learner/services -RUN mvn clean install -DskipTests +RUN mvn clean install -DskipTests -DCLOUD_STORAGE_GROUP_ID=org.sunbird -DCLOUD_STORAGE_ARTIFACT_ID=cloud-store-sdk -DCLOUD_STORAGE_VERSION=1.4.6 WORKDIR /opt/learner/services/learning-service CMD ["mvn", "play2:dist"] \ No newline at end of file diff --git a/Jenkinsfile b/Jenkinsfile index 698c9a1386..e2521bb478 100644 --- a/Jenkinsfile +++ b/Jenkinsfile @@ -26,11 +26,11 @@ node('build-slave') { env.NODE_ENV = "build" print "Environment will be : ${env.NODE_ENV}" sh 'git log -1' - sh 'mvn clean install -U -DskipTests=true ' + sh 'mvn clean install -U -DskipTests=true -DCLOUD_STORAGE_GROUP_ID=org.sunbird -DCLOUD_STORAGE_ARTIFACT_ID=cloud-store-sdk -DCLOUD_STORAGE_VERSION=1.4.6-DCLOUD_STORAGE_GROUP_ID=org.sunbird -DCLOUD_STORAGE_ARTIFACT_ID=cloud-store-sdk -DCLOUD_STORAGE_VERSION=1.4.6 ' } stage('Unit Tests') { - sh "mvn clean install '-Dtest=!%regex[io.opensaber.registry.client.*]' -DfailIfNoTests=false" + sh "mvn clean install '-Dtest=!%regex[io.opensaber.registry.client.*]' -DfailIfNoTests=false -DCLOUD_STORAGE_GROUP_ID=org.sunbird -DCLOUD_STORAGE_ARTIFACT_ID=cloud-store-sdk -DCLOUD_STORAGE_VERSION=1.4.6" } stage('Package') { dir('controller') { diff --git a/README.md b/README.md index 1cd5306adc..5931569205 100644 --- a/README.md +++ b/README.md @@ -219,7 +219,7 @@ git clone https://github.com/Sunbird-Lern/sunbird-lms-service.git 3. Build the application using the following maven command in the path `/sunbird-lms-service`: ```shell -mvn clean install -DskipTests +mvn clean install -DskipTests -DCLOUD_STORAGE_GROUP_ID=org.sunbird -DCLOUD_STORAGE_ARTIFACT_ID=cloud-store-sdk -DCLOUD_STORAGE_VERSION=1.4.6 ``` Make sure the build is successful before proceeding to the next step. If the build is not successful, fix any configuration issues and rebuild the application. diff --git a/auto_build_deploy b/auto_build_deploy index 639e29b7f8..dbdbb77fc4 100644 --- a/auto_build_deploy +++ b/auto_build_deploy @@ -28,7 +28,7 @@ node('build-slave') { // stage Build env.NODE_ENV = "build" - sh 'mvn clean install -U -DskipTests=false ' + sh 'mvn clean install -U -DskipTests=false -DCLOUD_STORAGE_GROUP_ID=org.sunbird -DCLOUD_STORAGE_ARTIFACT_ID=cloud-store-sdk -DCLOUD_STORAGE_VERSION=1.4.6' // stage Package dir('controller') { diff --git a/controller/pom.xml b/controller/pom.xml index a07e9a1f31..6fc247c83e 100644 --- a/controller/pom.xml +++ b/controller/pom.xml @@ -212,7 +212,7 @@ junit junit - 4.12 + 4.13.1 test diff --git a/core/es-utils/pom.xml b/core/es-utils/pom.xml index f975e40a9d..d501570052 100644 --- a/core/es-utils/pom.xml +++ b/core/es-utils/pom.xml @@ -34,7 +34,7 @@ junit junit - 4.12 + 4.13.1 test diff --git a/core/notification-utils/dependency-reduced-pom.xml b/core/notification-utils/dependency-reduced-pom.xml index ec20fac3d2..be370caaaa 100644 --- a/core/notification-utils/dependency-reduced-pom.xml +++ b/core/notification-utils/dependency-reduced-pom.xml @@ -40,7 +40,7 @@ junit junit - 4.12 + 4.13.1 test diff --git a/core/notification-utils/pom.xml b/core/notification-utils/pom.xml index f1e7c9f9cc..afb4ba773d 100644 --- a/core/notification-utils/pom.xml +++ b/core/notification-utils/pom.xml @@ -29,7 +29,7 @@ junit junit - 4.12 + 4.13.1 test diff --git a/core/platform-common/pom.xml b/core/platform-common/pom.xml index d507909d44..b0afe8e9f8 100644 --- a/core/platform-common/pom.xml +++ b/core/platform-common/pom.xml @@ -83,7 +83,7 @@ junit junit - 4.12 + 4.13.1 test @@ -112,9 +112,9 @@ 7.0.1 - org.sunbird - cloud-store-sdk - 1.4.6 + ${CLOUD_STORAGE_GROUP_ID} + ${CLOUD_STORAGE_ARTIFACT_ID} + ${CLOUD_STORAGE_VERSION} com.sun.jersey @@ -145,7 +145,7 @@ org.apache.kafka kafka-clients - 0.10.0.1 + 0.10.2.2 org.jboss.resteasy diff --git a/pom.xml b/pom.xml index 8fbc8805fc..833aef59ac 100644 --- a/pom.xml +++ b/pom.xml @@ -23,7 +23,7 @@ junit junit - 4.12 + 4.13.1 test diff --git a/setup.md b/setup.md index 2f072deeb3..0094291dff 100644 --- a/setup.md +++ b/setup.md @@ -78,7 +78,7 @@ ## Build 1. Run "git submodule foreach git pull origin master" to pull the latest sunbird-common submodule. -2. Run "mvn clean install" to build the services. +2. Run "mvn clean install -DCLOUD_STORAGE_GROUP_ID=org.sunbird -DCLOUD_STORAGE_ARTIFACT_ID=cloud-store-sdk -DCLOUD_STORAGE_VERSION=1.4.6" to build the services. 2. Go to "controller" and run the command "mvn play2:dist" to generate the dist file for controller. 3. The build file "controller-1.0-SNAPSHOT-dist.zip" is generated in "sunbird-lms-service/controller/target" folder. From c8e276d80e19fdc98a12dc064a54f9d0bc920e16 Mon Sep 17 00:00:00 2001 From: anilgupta Date: Mon, 24 Jul 2023 14:58:17 +0530 Subject: [PATCH 03/14] Issue #LR-627 test: Fixed unit test --- .../organisation/OrgManagementActorTest.java | 28 ++--- .../resources/externalresource.properties | 107 ++++++++++++++++++ 2 files changed, 121 insertions(+), 14 deletions(-) create mode 100644 service/src/test/resources/externalresource.properties diff --git a/service/src/test/java/org/sunbird/actor/organisation/OrgManagementActorTest.java b/service/src/test/java/org/sunbird/actor/organisation/OrgManagementActorTest.java index 75ca5552aa..c8d0b02087 100644 --- a/service/src/test/java/org/sunbird/actor/organisation/OrgManagementActorTest.java +++ b/service/src/test/java/org/sunbird/actor/organisation/OrgManagementActorTest.java @@ -1,23 +1,11 @@ package org.sunbird.actor.organisation; -import static akka.testkit.JavaTestKit.duration; -import static org.junit.Assert.assertTrue; -import static org.powermock.api.mockito.PowerMockito.*; - import akka.actor.ActorRef; import akka.actor.ActorSelection; import akka.actor.ActorSystem; import akka.actor.Props; import akka.dispatch.Futures; import akka.testkit.javadsl.TestKit; -import java.io.File; -import java.nio.file.Files; -import java.nio.file.Path; -import java.nio.file.Paths; -import java.util.ArrayList; -import java.util.HashMap; -import java.util.List; -import java.util.Map; import org.junit.Assert; import org.junit.Before; import org.junit.Ignore; @@ -56,6 +44,18 @@ import scala.Option; import scala.concurrent.Promise; +import java.io.File; +import java.nio.file.Files; +import java.nio.file.Path; +import java.nio.file.Paths; +import java.util.ArrayList; +import java.util.HashMap; +import java.util.List; +import java.util.Map; + +import static org.junit.Assert.assertTrue; +import static org.powermock.api.mockito.PowerMockito.*; + @RunWith(PowerMockRunner.class) @PrepareForTest({ ServiceFactory.class, @@ -516,11 +516,11 @@ private boolean testScenario(Request request, ResponseCode errorCode) { subject.tell(request, probe.getRef()); if (errorCode == null) { - Response res = probe.expectMsgClass(duration("100 second"), Response.class); + Response res = probe.expectMsgClass(Response.class); return null != res && res.getResponseCode() == ResponseCode.OK; } else { ProjectCommonException res = - probe.expectMsgClass(duration("100 second"), ProjectCommonException.class); + probe.expectMsgClass(ProjectCommonException.class); return res.getResponseCode().name().equals(errorCode.name()) || res.getErrorResponseCode() == errorCode.getResponseCode(); } diff --git a/service/src/test/resources/externalresource.properties b/service/src/test/resources/externalresource.properties new file mode 100644 index 0000000000..6898bc95c7 --- /dev/null +++ b/service/src/test/resources/externalresource.properties @@ -0,0 +1,107 @@ +sunbird_authorization= +ekstep.tag.api.url=/tag/register +sunbird_installation=sunbird +sunbird_analytics_api_base_url=http://analytics-service:9000 +sunbird_mail_server_host= +sunbird_mail_server_port= +sunbird_mail_server_username= +sunbird_mail_server_password= +sunbird_mail_server_from_email=support@open-sunbird.org +sunbird_username_num_digits=4 +sunbird_account_name= +sunbird_account_key= +download_link_expiry_timeout=300 +sunbird_encryption_key=SunBird +sunbird_encryption=ON +sunbird_allowed_login=You can use your cellphone number to login +#size of bulk upload data is 1001 including header in csv file +sunbird_user_bulk_upload_size=1001 +bulk_upload_org_data_size=300 +sunbird_web_url=https://dev.sunbirded.org +sunbird_framework_read_api=/v1/framework/read +fcm.url=https://fcm.googleapis.com/fcm/send +sunbird_default_country_code=+91 +#put the default evn logo url here or System Env variable with +#same key. code will first search from EVN then here. +sunbird_env_logo_url=http://via.placeholder.com/100x50 +system_settings_properties=phoneUnique,emailUnique +sunbird_default_welcome_sms=Welcome to DIKSHA. +sunbird_url_shortner_base_url=https://api-ssl.bitly.com/v3/shorten?access_token= +sunbird_url_shortner_access_token= +sunbird_content_service_api_base_url=http://content-service:9000 +sunbird.channel.create.api.url=/channel/v3/create +sunbird.channel.update.api.url=/channel/v3/update +sunbird_otp_allowed_attempt=2 + +#Telemetry producer related info +telemetry_pdata_id=local.sunbird.learning.service +telemetry_pdata_pid=learning-service +telemetry_pdata_ver=5.3.0 +#elastic search top n result count for telemetry +searchTopN=5 +sunbird_valid_location_types=state,district,block,cluster,school; +# Bulk upload file max size in MB +file_upload_max_size=10 +sunbird_default_channel= +# Batch size for cassandra batch operation +cassandra_write_batch_size=100 +sunbird_sso_client_id= +sunbird_sso_username= +sunbird_sso_password= +sunbird_sso_url= +sunbird_sso_realm= +sunbird_keycloak_required_action_link_expiration_seconds=155520000 +sunbird_url_shortner_enable=false +sunbird_api_request_lower_case_fields=source,externalId,userName,provider,loginId,email,prevUsedEmail +sunbird_otp_expiration=1800 +sunbird_otp_length=6 +sunbird_otp_hour_rate_limit=5 +sunbird_otp_day_rate_limit=20 +sunbird_rate_limit_enabled=true +sunbird_health_check_enable=true +sunbird_sync_read_wait_time=1500 +sunbird_gzip_size_threshold=262144 +kafka_urls=localhost:9092 +sunbird_fuzzy_search_threshold=0.5 +sunbird_state_img_url=https://sunbirddev.blob.core.windows.net/orgemailtemplate/img/File-0128212938260643843.png +sunbird_diksha_img_url=https://sunbirddev.blob.core.windows.net/orgemailtemplate/img/File-0128212989820190722.png +sunbird_cert_completion_img_url=https://sunbirddev.blob.core.windows.net/orgemailtemplate/img/File-0128212919987568641.png +sunbird_reset_pass_msg=Your have requested to reset password. Click on the link to set a password: {0} +sunbird_reset_pass_mail_subject=Reset Password +sunbird_subdomain_keycloak_base_url=https://merge.dev.sunbirded.org/auth/ +kafka_linger_ms=5 +sunbird_user_upload_error_visualization_threshold=20001 +migrate_user_template=You can now access your {0} state teacher account using {1}. Please log out and login once again to see updated details. +sunbird_account_merge_subject=Account merged successfully +sunbird_pass_regex=(?=.*[0-9])(?=.*[a-z])(?=.*[A-Z])(?=.*[!\"#$%&'()*+,-./:;<=>?@\\[\\]^_`{|}~])(?=\\S+$).{8,} +sunbird_user_create_sync_type=ES +sunbird_user_create_sync_topic=local.user.events +sigterm_stop_delay=40 +limit_managed_user_creation=true +managed_user_limit=30 +adminutil_base_url = http://adminutil:4000/ +adminutil_sign_endpoint = v1/sign/payload +self_declared_mandatory_fields = Diksha UUID,Status,State provided ext. ID,Channel,Persona +self_declared_optional_fields = School Name,School UDISE ID,Email ID,Phone number,Error Type +enable_captcha=true +consent_expiry_in_days=100 +feed_limit=30 +learner_in_memory_cache_ttl=14400 +user_index_alias=user_alias +defaultMonthDate = -12-31 +org_index_alias=org_alias +nic_sms_gateway_provider_base_url=https://smsgw.sms.gov.in/failsafe/HttpLink +sms_gateway_provider=91SMS +stacktrace_char_length=2500 +notification_service_base_url= +notification_service_v2_send_url=/private/v2/notification/send +notification_service_v1_update_url=/private/v1/notification/feed/update +notification_service_v1_read_url=/private/v1/notification/feed/read +notification_service_v1_delete_url=/private/v1/notification/feed/delete +channel_registration_disabled=false +#Login Page URL used as redirect URL in Password set / reset action. This will be suffixed with sunbird_web_url value. +sunbird_password_reset_login_page_url=/resources +isFormValidationRequired=true +userProfileConfigMap={\"type\":\"profileconfig\",\"subtype\":\"28\",\"action\":\"get\",\"component\":\"*\",\"framework\":\"*\",\"data\":{\"templateName\":\"profileConfig_v2\",\"action\":\"get\",\"fields\":[{\"code\":\"persona\",\"children\":{\"administrator\":[{\"code\":\"district\"},{\"code\":\"state\"},{\"code\":\"subPersona\",\"type\":\"select\",\"default\":null,\"templateOptions\":{\"options\":[{\"label\":\"Headmaster\",\"value\":\"hm\"},{\"label\":\"Cluster Resource Person\",\"value\":\"crp\"}]}},{\"code\":\"block\"},{\"code\":\"cluster\"},{\"code\":\"school\"}],\"teacher\":[{\"code\":\"state\"},{\"code\":\"district\"},{\"code\":\"block\"},{\"code\":\"cluster\"},{\"code\":\"school\"}],\"student\":[{\"code\":\"state\"},{\"code\":\"district\"},{\"code\":\"block\"},{\"code\":\"cluster\"},{\"code\":\"school\"}],\"parent\":[{\"code\":\"state\"},{\"code\":\"district\"},{\"code\":\"block\"},{\"code\":\"cluster\"},{\"code\":\"school\"}],\"other\":[{\"code\":\"state\"},{\"code\":\"district\"},{\"code\":\"subPersona\",\"templateOptions\":{\"options\":[{\"value\":\"Doctor (Allopathy)\",\"label\":\"Doctor (Allopathy)\"},{\"value\":\"AYUSH Professional\",\"label\":\"AYUSH Professional\"}]}},{\"code\":\"block\"},{\"code\":\"cluster\"},{\"code\":\"school\"}]}}]},\"created_on\":\"2022-02-10T14:16:51.852Z\",\"last_modified_on\":\"2022-11-14T05:45:02.685Z\",\"rootOrgId\":\"*\"} + +sunbird_cloud_service_provider=azure \ No newline at end of file From b3897e3468574297c414e562aef8b9630fa524ea Mon Sep 17 00:00:00 2001 From: anilgupta Date: Mon, 24 Jul 2023 15:15:50 +0530 Subject: [PATCH 04/14] Issue #LR-627 chore: Updated the play version to fix vulnerability --- controller/pom.xml | 4 ++-- core/platform-common/pom.xml | 2 +- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/controller/pom.xml b/controller/pom.xml index 6fc247c83e..1f167d903b 100644 --- a/controller/pom.xml +++ b/controller/pom.xml @@ -33,7 +33,7 @@ - 2.7.2 + 2.7.9 1.0.0-rc5 1.0.0 2.11 @@ -96,7 +96,7 @@ com.typesafe.play play-netty-server_2.11 - 2.7.2 + ${play2.version} runtime diff --git a/core/platform-common/pom.xml b/core/platform-common/pom.xml index b0afe8e9f8..219a47b22f 100644 --- a/core/platform-common/pom.xml +++ b/core/platform-common/pom.xml @@ -195,7 +195,7 @@ com.typesafe.play play_2.11 - 2.7.2 + 2.7.9 compile From f6f439f1280c3a6d68572ec02b23d6a8d321031a Mon Sep 17 00:00:00 2001 From: anilgupta Date: Mon, 24 Jul 2023 16:54:26 +0530 Subject: [PATCH 05/14] Issue #LR-627 feat: Fixed the STORAGE to STORE --- .circleci/config.yml | 2 +- Dockerfile.Build | 2 +- Jenkinsfile | 4 +- README.md | 2 +- auto_build_deploy | 2 +- .../OrganisationControllerTest.java | 115 +++++------------- core/platform-common/pom.xml | 6 +- .../actor/user/TenantMigrationActorTest.java | 22 ++-- setup.md | 2 +- 9 files changed, 50 insertions(+), 107 deletions(-) diff --git a/.circleci/config.yml b/.circleci/config.yml index 2cca91e107..71ed37ec67 100644 --- a/.circleci/config.yml +++ b/.circleci/config.yml @@ -7,7 +7,7 @@ jobs: - checkout - restore_cache: key: lms-dependency-cache-{{ checksum "pom.xml" }} - - run: mvn clean install -DCLOUD_STORAGE_GROUP_ID=org.sunbird -DCLOUD_STORAGE_ARTIFACT_ID=cloud-store-sdk -DCLOUD_STORAGE_VERSION=1.4.6 + - run: mvn clean install -DCLOUD_STORE_GROUP_ID=org.sunbird -DCLOUD_STORE_ARTIFACT_ID=cloud-store-sdk -DCLOUD_STORE_VERSION=1.4.6 - run: cd controller && mvn play2:dist - save_cache: key: lms-dependency-cache-{{ checksum "pom.xml" }} diff --git a/Dockerfile.Build b/Dockerfile.Build index 3e4737dcbe..c46fe46d0b 100644 --- a/Dockerfile.Build +++ b/Dockerfile.Build @@ -10,6 +10,6 @@ ENV M2_HOME /opt/apache-maven-3.3.9 ENV PATH ${M2_HOME}/bin:${PATH} COPY learner /opt/learner/ WORKDIR /opt/learner/services -RUN mvn clean install -DskipTests -DCLOUD_STORAGE_GROUP_ID=org.sunbird -DCLOUD_STORAGE_ARTIFACT_ID=cloud-store-sdk -DCLOUD_STORAGE_VERSION=1.4.6 +RUN mvn clean install -DskipTests -DCLOUD_STORE_GROUP_ID=org.sunbird -DCLOUD_STORE_ARTIFACT_ID=cloud-store-sdk -DCLOUD_STORE_VERSION=1.4.6 WORKDIR /opt/learner/services/learning-service CMD ["mvn", "play2:dist"] \ No newline at end of file diff --git a/Jenkinsfile b/Jenkinsfile index e2521bb478..95f24224a8 100644 --- a/Jenkinsfile +++ b/Jenkinsfile @@ -26,11 +26,11 @@ node('build-slave') { env.NODE_ENV = "build" print "Environment will be : ${env.NODE_ENV}" sh 'git log -1' - sh 'mvn clean install -U -DskipTests=true -DCLOUD_STORAGE_GROUP_ID=org.sunbird -DCLOUD_STORAGE_ARTIFACT_ID=cloud-store-sdk -DCLOUD_STORAGE_VERSION=1.4.6-DCLOUD_STORAGE_GROUP_ID=org.sunbird -DCLOUD_STORAGE_ARTIFACT_ID=cloud-store-sdk -DCLOUD_STORAGE_VERSION=1.4.6 ' + sh 'mvn clean install -U -DskipTests=true -DCLOUD_STORE_GROUP_ID=org.sunbird -DCLOUD_STORE_ARTIFACT_ID=cloud-store-sdk -DCLOUD_STORE_VERSION=1.4.6 ' } stage('Unit Tests') { - sh "mvn clean install '-Dtest=!%regex[io.opensaber.registry.client.*]' -DfailIfNoTests=false -DCLOUD_STORAGE_GROUP_ID=org.sunbird -DCLOUD_STORAGE_ARTIFACT_ID=cloud-store-sdk -DCLOUD_STORAGE_VERSION=1.4.6" + sh "mvn clean install '-Dtest=!%regex[io.opensaber.registry.client.*]' -DfailIfNoTests=false -DCLOUD_STORE_GROUP_ID=org.sunbird -DCLOUD_STORE_ARTIFACT_ID=cloud-store-sdk -DCLOUD_STORE_VERSION=1.4.6" } stage('Package') { dir('controller') { diff --git a/README.md b/README.md index 5931569205..3adf2aab7b 100644 --- a/README.md +++ b/README.md @@ -219,7 +219,7 @@ git clone https://github.com/Sunbird-Lern/sunbird-lms-service.git 3. Build the application using the following maven command in the path `/sunbird-lms-service`: ```shell -mvn clean install -DskipTests -DCLOUD_STORAGE_GROUP_ID=org.sunbird -DCLOUD_STORAGE_ARTIFACT_ID=cloud-store-sdk -DCLOUD_STORAGE_VERSION=1.4.6 +mvn clean install -DskipTests -DCLOUD_STORE_GROUP_ID=org.sunbird -DCLOUD_STORE_ARTIFACT_ID=cloud-store-sdk -DCLOUD_STORE_VERSION=1.4.6 ``` Make sure the build is successful before proceeding to the next step. If the build is not successful, fix any configuration issues and rebuild the application. diff --git a/auto_build_deploy b/auto_build_deploy index dbdbb77fc4..edb9b9a653 100644 --- a/auto_build_deploy +++ b/auto_build_deploy @@ -28,7 +28,7 @@ node('build-slave') { // stage Build env.NODE_ENV = "build" - sh 'mvn clean install -U -DskipTests=false -DCLOUD_STORAGE_GROUP_ID=org.sunbird -DCLOUD_STORAGE_ARTIFACT_ID=cloud-store-sdk -DCLOUD_STORAGE_VERSION=1.4.6' + sh 'mvn clean install -U -DskipTests=false -DCLOUD_STORE_GROUP_ID=org.sunbird -DCLOUD_STORE_ARTIFACT_ID=cloud-store-sdk -DCLOUD_STORE_VERSION=1.4.6' // stage Package dir('controller') { diff --git a/controller/test/controllers/organisationmanagement/OrganisationControllerTest.java b/controller/test/controllers/organisationmanagement/OrganisationControllerTest.java index 157a89a225..f22bb07372 100644 --- a/controller/test/controllers/organisationmanagement/OrganisationControllerTest.java +++ b/controller/test/controllers/organisationmanagement/OrganisationControllerTest.java @@ -1,26 +1,12 @@ package controllers.organisationmanagement; -import static org.junit.Assert.assertEquals; -import static org.junit.Assert.assertTrue; -import static org.powermock.api.mockito.PowerMockito.when; - import akka.stream.javadsl.FileIO; import akka.stream.javadsl.Source; import akka.util.ByteString; import com.fasterxml.jackson.databind.JsonNode; -import com.fasterxml.jackson.databind.ObjectMapper; import controllers.BaseApplicationTest; import controllers.DummyActor; -import java.io.File; -import java.io.IOException; -import java.nio.file.Files; -import java.nio.file.Paths; -import java.util.Arrays; -import java.util.Collections; -import java.util.HashMap; -import java.util.Map; import modules.OnRequestHandler; -import org.apache.commons.lang3.StringUtils; import org.junit.Before; import org.junit.Test; import org.mockito.Mockito; @@ -29,15 +15,24 @@ import org.powermock.core.classloader.annotations.PrepareForTest; import org.sunbird.exception.ResponseCode; import org.sunbird.keys.JsonKey; -import org.sunbird.response.Response; -import org.sunbird.response.ResponseParams; -import play.libs.Json; import play.mvc.Http; import play.mvc.Result; import play.test.Helpers; import util.ACTORS; import util.RequestInterceptor; +import java.io.File; +import java.io.IOException; +import java.nio.file.Files; +import java.nio.file.Paths; +import java.util.Arrays; +import java.util.Collections; +import java.util.HashMap; +import java.util.Map; + +import static org.junit.Assert.assertEquals; +import static org.powermock.api.mockito.PowerMockito.when; + @PrepareForTest(OnRequestHandler.class) @PowerMockIgnore({"javax.management.*", "jdk.internal.reflect.*", "javax.crypto.*"}) // @Ignore @@ -63,7 +58,7 @@ public void testCreateOrgSuccess() { "POST", createOrUpdateOrganisationRequest(orgName, null, false, null, null)); assertEquals(getResponseCode(result), ResponseCode.SUCCESS.name()); - assertTrue(getResponseStatus(result) == 200); + assertEquals(200, getResponseStatus(result)); } @Test @@ -73,7 +68,7 @@ public void testCreateSubOrgWithLicenseSuccess() { ((Map) reqMap.get(JsonKey.REQUEST)).put(JsonKey.LICENSE, "Test MIT license"); Result result = performTest("/v1/org/create", "POST", reqMap); assertEquals(getResponseCode(result), ResponseCode.SUCCESS.name()); - assertTrue(getResponseStatus(result) == 200); + assertEquals(200, getResponseStatus(result)); } @Test @@ -83,7 +78,7 @@ public void testCreateRootOrgWithLicenseSuccess() { ((Map) reqMap.get(JsonKey.REQUEST)).put(JsonKey.LICENSE, "Test MIT license"); Result result = performTest("/v1/org/create", "POST", reqMap); assertEquals(getResponseCode(result), ResponseCode.SUCCESS.name()); - assertTrue(getResponseStatus(result) == 200); + assertEquals(200, getResponseStatus(result)); } @Test @@ -93,7 +88,7 @@ public void testCreateRootOrgWithLicenseEmptyFailure() { ((Map) reqMap.get(JsonKey.REQUEST)).put(JsonKey.LICENSE, ""); Result result = performTest("/v1/org/create", "POST", reqMap); assertEquals(getResponseCode(result), ResponseCode.CLIENT_ERROR.name()); - assertTrue(getResponseStatus(result) == 400); + assertEquals(400, getResponseStatus(result)); } @Test @@ -104,7 +99,7 @@ public void testCreateOrgFailureWithoutOrgName() { "POST", createOrUpdateOrganisationRequest(null, null, false, null, null)); assertEquals(getResponseCode(result), ResponseCode.CLIENT_ERROR.name()); - assertTrue(getResponseStatus(result) == 400); + assertEquals(400, getResponseStatus(result)); } @Test @@ -115,7 +110,7 @@ public void testCreateOrgFailureWithRootOrgWithoutChannel() { "POST", createOrUpdateOrganisationRequest(orgName, null, true, rootOrgId, null)); assertEquals(getResponseCode(result), ResponseCode.CLIENT_ERROR.name()); - assertTrue(getResponseStatus(result) == 400); + assertEquals(400, getResponseStatus(result)); } @Test @@ -126,7 +121,7 @@ public void testUpdateOrgSuccess() { "PATCH", createOrUpdateOrganisationRequest(null, orgId, false, rootOrgId, null)); assertEquals(getResponseCode(result), ResponseCode.SUCCESS.name()); - assertTrue(getResponseStatus(result) == 200); + assertEquals(200, getResponseStatus(result)); } @Test @@ -137,7 +132,7 @@ public void testUpdateOrgFailureWithoutOrgId() { "PATCH", createOrUpdateOrganisationRequest(null, null, false, rootOrgId, null)); assertEquals(getResponseCode(result), ResponseCode.CLIENT_ERROR.name()); - assertTrue(getResponseStatus(result) == 400); + assertEquals(400, getResponseStatus(result)); } @Test @@ -148,7 +143,7 @@ public void testUpdateOrgStatusSuccess() { "PATCH", createOrUpdateOrganisationRequest(null, orgId, false, null, status)); assertEquals(getResponseCode(result), ResponseCode.SUCCESS.name()); - assertTrue(getResponseStatus(result) == 200); + assertEquals(200, getResponseStatus(result)); } @Test @@ -159,21 +154,21 @@ public void testUpdateOrgStatusFailureWithoutOrgId() { "PATCH", createOrUpdateOrganisationRequest(null, null, false, null, status)); assertEquals(getResponseCode(result), ResponseCode.CLIENT_ERROR.name()); - assertTrue(getResponseStatus(result) == 400); + assertEquals(400, getResponseStatus(result)); } @Test public void testGetOrgDetailsSuccess() { Result result = performTest("/v1/org/read", "POST", getOrganisationRequest(orgId, status)); assertEquals(getResponseCode(result), ResponseCode.SUCCESS.name()); - assertTrue(getResponseStatus(result) == 200); + assertEquals(200, getResponseStatus(result)); } @Test public void testGetOrgDetailsFailureWithoutOrgId() { Result result = performTest("/v1/org/read", "POST", getOrganisationRequest(null, status)); assertEquals(getResponseCode(result), ResponseCode.CLIENT_ERROR.name()); - assertTrue(getResponseStatus(result) == 400); + assertEquals(400, getResponseStatus(result)); } @Test @@ -181,7 +176,7 @@ public void testSearchOrgSuccess() { Result result = performTest("/v1/org/search", "POST", searchOrganisationRequest(status, new HashMap<>())); assertEquals(getResponseCode(result), ResponseCode.SUCCESS.name()); - assertTrue(getResponseStatus(result) == 200); + assertEquals(200, getResponseStatus(result)); } @Test @@ -189,14 +184,14 @@ public void testSearchOrgV2Success() { Result result = performTest("/v2/org/search", "POST", searchOrganisationRequest(status, new HashMap<>())); assertEquals(getResponseCode(result), ResponseCode.SUCCESS.name()); - assertTrue(getResponseStatus(result) == 200); + assertEquals(200, getResponseStatus(result)); } @Test public void testSearchOrgFailureWithoutFilters() { Result result = performTest("/v1/org/search", "POST", searchOrganisationRequest(status, null)); assertEquals(getResponseCode(result), ResponseCode.CLIENT_ERROR.name()); - assertTrue(getResponseStatus(result) == 400); + assertEquals(400, getResponseStatus(result)); } @Test @@ -280,7 +275,7 @@ private Map createOrUpdateOrganisationRequest( innerMap.put(JsonKey.IS_TENANT, isRootOrg); innerMap.put(JsonKey.ORG_TYPE, "board"); - if (status != null) innerMap.put(JsonKey.STATUS, new Integer(status)); + if (status != null) innerMap.put(JsonKey.STATUS, Integer.valueOf(status)); requestMap.put(JsonKey.REQUEST, innerMap); @@ -292,7 +287,7 @@ private Map getOrganisationRequest(String orgId, String status) { Map innerMap = new HashMap<>(); innerMap.put(JsonKey.ORGANISATION_ID, orgId); - if (status != null) innerMap.put(JsonKey.STATUS, new Integer(status)); + if (status != null) innerMap.put(JsonKey.STATUS, Integer.valueOf(status)); requestMap.put(JsonKey.REQUEST, innerMap); @@ -304,60 +299,10 @@ private Map searchOrganisationRequest(String status, HashMap fil Map innerMap = new HashMap<>(); innerMap.put(JsonKey.FILTERS, filterMap); - if (status != null) innerMap.put(JsonKey.STATUS, new Integer(status)); + if (status != null) innerMap.put(JsonKey.STATUS, Integer.valueOf(status)); requestMap.put(JsonKey.REQUEST, innerMap); return requestMap; } - - public Result performTest(String url, String method, Map map) { - String data = mapToJson(map); - Http.RequestBuilder req; - if (StringUtils.isNotBlank(data)) { - JsonNode json = Json.parse(data); - req = new Http.RequestBuilder().bodyJson(json).uri(url).method(method); - } else { - req = new Http.RequestBuilder().uri(url).method(method); - } - // req.headers(new Http.Headers(headerMap)); - Result result = Helpers.route(application, req); - return result; - } - - public String mapToJson(Map map) { - ObjectMapper mapperObj = new ObjectMapper(); - String jsonResp = ""; - - if (map != null) { - try { - jsonResp = mapperObj.writeValueAsString(map); - } catch (IOException e) { - e.printStackTrace(); - } - } - return jsonResp; - } - - public String getResponseCode(Result result) { - String responseStr = Helpers.contentAsString(result); - ObjectMapper mapper = new ObjectMapper(); - - try { - Response response = mapper.readValue(responseStr, Response.class); - ResponseParams params = response.getParams(); - if (result.status() != 200) { - return response.getResponseCode().name(); - } else { - return params.getStatus(); - } - } catch (Exception e) { - e.printStackTrace(); - } - return ""; - } - - public int getResponseStatus(Result result) { - return result.status(); - } } diff --git a/core/platform-common/pom.xml b/core/platform-common/pom.xml index 219a47b22f..da78fe48d0 100644 --- a/core/platform-common/pom.xml +++ b/core/platform-common/pom.xml @@ -112,9 +112,9 @@ 7.0.1 - ${CLOUD_STORAGE_GROUP_ID} - ${CLOUD_STORAGE_ARTIFACT_ID} - ${CLOUD_STORAGE_VERSION} + ${CLOUD_STORE_GROUP_ID} + ${CLOUD_STORE_ARTIFACT_ID} + ${CLOUD_STORE_VERSION} com.sun.jersey diff --git a/service/src/test/java/org/sunbird/actor/user/TenantMigrationActorTest.java b/service/src/test/java/org/sunbird/actor/user/TenantMigrationActorTest.java index 57c05a4391..dbf5b8cdec 100644 --- a/service/src/test/java/org/sunbird/actor/user/TenantMigrationActorTest.java +++ b/service/src/test/java/org/sunbird/actor/user/TenantMigrationActorTest.java @@ -1,17 +1,10 @@ package org.sunbird.actor.user; -import static akka.testkit.JavaTestKit.duration; -import static org.junit.Assert.assertEquals; -import static org.junit.Assert.assertTrue; -import static org.powermock.api.mockito.PowerMockito.mock; -import static org.powermock.api.mockito.PowerMockito.when; - import akka.actor.ActorRef; import akka.actor.ActorSystem; import akka.actor.Props; import akka.dispatch.Futures; import akka.testkit.javadsl.TestKit; -import java.util.*; import org.junit.Assert; import org.junit.Before; import org.junit.Test; @@ -43,6 +36,13 @@ import org.sunbird.util.ProjectUtil; import scala.concurrent.Promise; +import java.util.*; + +import static org.junit.Assert.assertEquals; +import static org.junit.Assert.assertTrue; +import static org.powermock.api.mockito.PowerMockito.mock; +import static org.powermock.api.mockito.PowerMockito.when; + @RunWith(PowerMockRunner.class) @PrepareForTest({ ServiceFactory.class, @@ -216,11 +216,10 @@ public boolean testScenario(Request reqObj, ResponseCode errorCode, Props props) ActorRef subject = system.actorOf(props); subject.tell(reqObj, probe.getRef()); if (errorCode == null) { - Response res = probe.expectMsgClass(duration("100 second"), Response.class); + Response res = probe.expectMsgClass(Response.class); return null != res && res.getResponseCode() == ResponseCode.OK; } else { - ProjectCommonException res = - probe.expectMsgClass(duration("100 second"), ProjectCommonException.class); + ProjectCommonException res = probe.expectMsgClass(ProjectCommonException.class); return res.getResponseCode().name().equals(errorCode.name()) || res.getErrorResponseCode() == errorCode.getResponseCode(); } @@ -284,8 +283,7 @@ public void testWithInvalidRequest() { Request request = new Request(); request.setOperation("invalidOperation"); subject.tell(request, probe.getRef()); - ProjectCommonException exception = - probe.expectMsgClass(duration("10 second"), ProjectCommonException.class); + ProjectCommonException exception = probe.expectMsgClass(ProjectCommonException.class); Assert.assertNotNull(exception); } diff --git a/setup.md b/setup.md index 0094291dff..1eb16afa11 100644 --- a/setup.md +++ b/setup.md @@ -78,7 +78,7 @@ ## Build 1. Run "git submodule foreach git pull origin master" to pull the latest sunbird-common submodule. -2. Run "mvn clean install -DCLOUD_STORAGE_GROUP_ID=org.sunbird -DCLOUD_STORAGE_ARTIFACT_ID=cloud-store-sdk -DCLOUD_STORAGE_VERSION=1.4.6" to build the services. +2. Run "mvn clean install -DCLOUD_STORE_GROUP_ID=org.sunbird -DCLOUD_STORE_ARTIFACT_ID=cloud-store-sdk -DCLOUD_STORE_VERSION=1.4.6" to build the services. 2. Go to "controller" and run the command "mvn play2:dist" to generate the dist file for controller. 3. The build file "controller-1.0-SNAPSHOT-dist.zip" is generated in "sunbird-lms-service/controller/target" folder. From 1a0db40322fba0b723ebbf0c886401983d900cf0 Mon Sep 17 00:00:00 2001 From: anilgupta Date: Tue, 25 Jul 2023 10:42:37 +0530 Subject: [PATCH 06/14] Issue #LR-627 chore: Align the version of all the jackson libraries. --- controller/pom.xml | 2 +- core/actor-core/pom.xml | 4 ++-- core/cassandra-utils/pom.xml | 2 +- core/notification-utils/pom.xml | 2 +- core/platform-common/pom.xml | 6 +++--- 5 files changed, 8 insertions(+), 8 deletions(-) diff --git a/controller/pom.xml b/controller/pom.xml index 1f167d903b..10fa5514f4 100644 --- a/controller/pom.xml +++ b/controller/pom.xml @@ -47,7 +47,7 @@ com.fasterxml.jackson.core jackson-databind - 2.10.1 + 2.10.5.1 diff --git a/core/actor-core/pom.xml b/core/actor-core/pom.xml index 45557b15eb..c0aa98090a 100644 --- a/core/actor-core/pom.xml +++ b/core/actor-core/pom.xml @@ -54,12 +54,12 @@ com.fasterxml.jackson.core jackson-core - 2.10.1 + 2.10.5 com.fasterxml.jackson.core jackson-databind - 2.10.1 + 2.10.5.1 diff --git a/core/cassandra-utils/pom.xml b/core/cassandra-utils/pom.xml index 7c6ba6fd93..32564d93cb 100644 --- a/core/cassandra-utils/pom.xml +++ b/core/cassandra-utils/pom.xml @@ -54,7 +54,7 @@ com.fasterxml.jackson.core jackson-databind - 2.10.1 + 2.10.5.1 org.sunbird diff --git a/core/notification-utils/pom.xml b/core/notification-utils/pom.xml index afb4ba773d..daeacaac14 100644 --- a/core/notification-utils/pom.xml +++ b/core/notification-utils/pom.xml @@ -53,7 +53,7 @@ com.fasterxml.jackson.core jackson-databind - 2.9.5 + 2.10.5.1 org.sunbird diff --git a/core/platform-common/pom.xml b/core/platform-common/pom.xml index da78fe48d0..c48166ddd3 100644 --- a/core/platform-common/pom.xml +++ b/core/platform-common/pom.xml @@ -47,17 +47,17 @@ com.fasterxml.jackson.core jackson-core - 2.10.1 + 2.10.5 com.fasterxml.jackson.core jackson-databind - 2.10.1 + 2.10.5.1 com.fasterxml.jackson.core jackson-annotations - 2.10.1 + 2.10.5 com.typesafe.akka From a1837a24ebc5e8177469355fd8a649645438097d Mon Sep 17 00:00:00 2001 From: anilgupta Date: Tue, 25 Jul 2023 16:44:18 +0530 Subject: [PATCH 07/14] Issue #LR-627 chore: Updated the resteasy-jackson2-provider --- core/platform-common/pom.xml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/core/platform-common/pom.xml b/core/platform-common/pom.xml index c48166ddd3..a70da038e9 100644 --- a/core/platform-common/pom.xml +++ b/core/platform-common/pom.xml @@ -32,7 +32,7 @@ org.jboss.resteasy resteasy-jackson2-provider - 3.1.3.Final + 3.15.6.Final com.fasterxml.jackson.core From 4be56ce6a58ea4fdbb3bef6ee031567acd3e6646 Mon Sep 17 00:00:00 2001 From: anilgupta Date: Tue, 25 Jul 2023 17:03:20 +0530 Subject: [PATCH 08/14] Issue #LR-627 chore: Updated the maven-surefire-plugin --- pom.xml | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/pom.xml b/pom.xml index 833aef59ac..500cbb713b 100644 --- a/pom.xml +++ b/pom.xml @@ -32,7 +32,7 @@ org.apache.maven.plugins maven-surefire-plugin - 3.0.0-M5 + 3.0.0 @@ -55,7 +55,7 @@ org.jacoco jacoco-maven-plugin - 0.8.5 + 0.8.6 ${basedir}/target/jacoco-unit.exec ${basedir}/target/jacoco-unit.exec From c310e0c13a0322ca170cad0d05c2c4e96496ca5a Mon Sep 17 00:00:00 2001 From: anilgupta Date: Tue, 25 Jul 2023 17:14:03 +0530 Subject: [PATCH 09/14] Issue #LR-627 chore: Updated the maven-surefire-plugin forkCount 0 --- pom.xml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/pom.xml b/pom.xml index 500cbb713b..32ebc43557 100644 --- a/pom.xml +++ b/pom.xml @@ -34,7 +34,7 @@ maven-surefire-plugin 3.0.0 - + 0 false From 7ee50d09b543b3a840fc5bb76fb01c34ec5a1b0c Mon Sep 17 00:00:00 2001 From: kumarks1122 Date: Thu, 27 Jul 2023 19:01:04 +0530 Subject: [PATCH 10/14] LR-627 | Circle CI fixes --- core/platform-common/pom.xml | 3 +++ .../sunbird/actor/organisation/OrgManagementActorTest.java | 5 +++-- 2 files changed, 6 insertions(+), 2 deletions(-) diff --git a/core/platform-common/pom.xml b/core/platform-common/pom.xml index a70da038e9..aef85b35b3 100644 --- a/core/platform-common/pom.xml +++ b/core/platform-common/pom.xml @@ -20,6 +20,9 @@ 11 UTF-8 2.5.19 + org.sunbird + cloud-store-sdk + 1.4.6 diff --git a/service/src/test/java/org/sunbird/actor/organisation/OrgManagementActorTest.java b/service/src/test/java/org/sunbird/actor/organisation/OrgManagementActorTest.java index c8d0b02087..652986e860 100644 --- a/service/src/test/java/org/sunbird/actor/organisation/OrgManagementActorTest.java +++ b/service/src/test/java/org/sunbird/actor/organisation/OrgManagementActorTest.java @@ -53,6 +53,7 @@ import java.util.List; import java.util.Map; +import static akka.testkit.JavaTestKit.duration; import static org.junit.Assert.assertTrue; import static org.powermock.api.mockito.PowerMockito.*; @@ -516,7 +517,7 @@ private boolean testScenario(Request request, ResponseCode errorCode) { subject.tell(request, probe.getRef()); if (errorCode == null) { - Response res = probe.expectMsgClass(Response.class); + Response res = probe.expectMsgClass(duration("5 second"), Response.class); return null != res && res.getResponseCode() == ResponseCode.OK; } else { ProjectCommonException res = @@ -549,7 +550,7 @@ private byte[] getFileAsBytes() { new File( Paths.get("").toAbsolutePath() + File.separator - + "src/test/resources/samplepublic.pem"); + + "service/src/test/resources/samplepublic.pem"); Path path = Paths.get(file.getPath()); bytes = Files.readAllBytes(path); } catch (Exception e) { From df80450fe91be139f98ad4294b5c125c2f92a13b Mon Sep 17 00:00:00 2001 From: anilgupta Date: Mon, 31 Jul 2023 15:39:19 +0530 Subject: [PATCH 11/14] Issue #LR-627 chore: Updated the com.typesafe.play --- controller/pom.xml | 2 +- core/platform-common/pom.xml | 3 ++- 2 files changed, 3 insertions(+), 2 deletions(-) diff --git a/controller/pom.xml b/controller/pom.xml index 10fa5514f4..cb42eafd71 100644 --- a/controller/pom.xml +++ b/controller/pom.xml @@ -33,7 +33,7 @@ - 2.7.9 + 2.7.2 1.0.0-rc5 1.0.0 2.11 diff --git a/core/platform-common/pom.xml b/core/platform-common/pom.xml index aef85b35b3..b90834832a 100644 --- a/core/platform-common/pom.xml +++ b/core/platform-common/pom.xml @@ -20,6 +20,7 @@ 11 UTF-8 2.5.19 + 2.7.2 org.sunbird cloud-store-sdk 1.4.6 @@ -198,7 +199,7 @@ com.typesafe.play play_2.11 - 2.7.9 + ${play2.version} compile From a38a57ebd615f2d9cb26b98c565dbfbbc8016a17 Mon Sep 17 00:00:00 2001 From: anilgupta Date: Wed, 2 Aug 2023 11:23:02 +0530 Subject: [PATCH 12/14] Issue #LR-627 chore: Variablalize the values in mvn command --- Jenkinsfile | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Jenkinsfile b/Jenkinsfile index 95f24224a8..ff2e128902 100644 --- a/Jenkinsfile +++ b/Jenkinsfile @@ -26,7 +26,7 @@ node('build-slave') { env.NODE_ENV = "build" print "Environment will be : ${env.NODE_ENV}" sh 'git log -1' - sh 'mvn clean install -U -DskipTests=true -DCLOUD_STORE_GROUP_ID=org.sunbird -DCLOUD_STORE_ARTIFACT_ID=cloud-store-sdk -DCLOUD_STORE_VERSION=1.4.6 ' + sh "mvn clean install -DskipTests=true -DCLOUD_STORE_GROUP_ID=${params.cloud_store_group_id} -DCLOUD_STORE_ARTIFACT_ID=${params.cloud_store_artifact_id} -DCLOUD_STORE_VERSION=${params.cloud_store_version}" } stage('Unit Tests') { From e5f4b0db8fa6d267d6dfb02a82a67f5f87c9cb22 Mon Sep 17 00:00:00 2001 From: Hari-stackroute <40484996+Hari-stackroute@users.noreply.github.com> Date: Wed, 2 Aug 2023 13:17:48 +0530 Subject: [PATCH 13/14] Update Jenkinsfile --- Jenkinsfile | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Jenkinsfile b/Jenkinsfile index ff2e128902..08f7c76929 100644 --- a/Jenkinsfile +++ b/Jenkinsfile @@ -30,7 +30,7 @@ node('build-slave') { } stage('Unit Tests') { - sh "mvn clean install '-Dtest=!%regex[io.opensaber.registry.client.*]' -DfailIfNoTests=false -DCLOUD_STORE_GROUP_ID=org.sunbird -DCLOUD_STORE_ARTIFACT_ID=cloud-store-sdk -DCLOUD_STORE_VERSION=1.4.6" + sh "mvn clean install '-Dtest=!%regex[io.opensaber.registry.client.*]' -DfailIfNoTests=false -Dsurefire.failIfNoSpecifiedTests=false -DCLOUD_STORE_GROUP_ID=org.sunbird -DCLOUD_STORE_ARTIFACT_ID=cloud-store-sdk -DCLOUD_STORE_VERSION=1.4.6" } stage('Package') { dir('controller') { From 9dc4ffccc5847a59f44c27c125a7f30dadd0bf6c Mon Sep 17 00:00:00 2001 From: Hari-stackroute <40484996+Hari-stackroute@users.noreply.github.com> Date: Wed, 2 Aug 2023 15:38:35 +0530 Subject: [PATCH 14/14] Update OrganisationControllerTest.java checking controller path --- .../organisationmanagement/OrganisationControllerTest.java | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/controller/test/controllers/organisationmanagement/OrganisationControllerTest.java b/controller/test/controllers/organisationmanagement/OrganisationControllerTest.java index f22bb07372..18525c98c2 100644 --- a/controller/test/controllers/organisationmanagement/OrganisationControllerTest.java +++ b/controller/test/controllers/organisationmanagement/OrganisationControllerTest.java @@ -196,9 +196,10 @@ public void testSearchOrgFailureWithoutFilters() { @Test public void testAddEncyptionKeyPublicPem() throws IOException { + String controllerPath = (Paths.get("").toAbsolutePath().toString().endsWith("controller"))?Paths.get("").toAbsolutePath().toString():Paths.get("").toAbsolutePath().toString()+File.separator +"controller"; File file = new File( - Paths.get("").toAbsolutePath() + File.separator + "test/resources/samplepublic.pem"); + controllerPath + File.separator + "test/resources/samplepublic.pem"); Http.MultipartFormData.Part> part = new Http.MultipartFormData.FilePart<>( "fileName", @@ -222,8 +223,9 @@ public void testAddEncyptionKeyPublicPem() throws IOException { @Test public void testAddEncyptionKeyPDF() throws IOException { + String controllerPath = (Paths.get("").toAbsolutePath().toString().endsWith("controller"))?Paths.get("").toAbsolutePath().toString():Paths.get("").toAbsolutePath().toString()+File.separator +"controller"; File file = - new File(Paths.get("").toAbsolutePath() + File.separator + "test/resources/sample.pdf"); + new File(controllerPath + File.separator + "test/resources/sample.pdf"); Http.MultipartFormData.Part> part = new Http.MultipartFormData.FilePart<>( "fileName",