Skip to content

Commit

Permalink
Resolved merge issues
Browse files Browse the repository at this point in the history
  • Loading branch information
holashchand committed Nov 8, 2023
1 parent cf8cab3 commit b679e78
Show file tree
Hide file tree
Showing 9 changed files with 71 additions and 71 deletions.
4 changes: 2 additions & 2 deletions Jenkinsfile
Original file line number Diff line number Diff line change
Expand Up @@ -27,11 +27,11 @@ node {


stage('Push image') {
docker.withRegistry('', 'dockerhub') {
docker.withRegistry('ghcr.io', 'sunbird-rc') {
app.push("${env.BUILD_NUMBER}")
app.push("latest")
}
docker.withRegistry('', 'dockerhub') {
docker.withRegistry('ghrc.io', 'sunbird-rc') {
claimApp.push("${env.BUILD_NUMBER}")
claimApp.push("latest")
}
Expand Down
6 changes: 3 additions & 3 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -52,18 +52,18 @@ test: build
@docker-compose down
@rm -rf db-data-2 || echo "no permission to delete"
# test with fusionauth
@RELEASE_VERSION=latest DB_DIR=db-data-7 SEARCH_PROVIDER_NAME=dev.sunbirdrc.registry.service.NativeSearchService FUSION_WRAPPER_BUILD=services/sample-fusionauth-service/ FUSIONAUTH_ISSUER_URL=http://fusionauth:9011/ oauth2_resource_uri=http://fusionauth:9011/ oauth2_resource_roles_path=roles identity_provider=dev.sunbirdrc.auth.genericiam.AuthProviderImpl sunbird_sso_url=http://fusionauthwrapper:3990/fusionauth/api/v1/user IMPORTS_DIR=services/sample-fusionauth-service/imports docker-compose -f docker-compose.yml -f services/sample-fusionauth-service/docker-compose.yml up -d db es fusionauth fusionauthwrapper
@docker-compose --env-file test_environments/test_with_fusionauth.env -f docker-compose.yml -f services/sample-fusionauth-service/docker-compose.yml up -d db es fusionauth fusionauthwrapper
sleep 20
@echo "Starting the test" && sh build/wait_for_port.sh 9011
@echo "Starting the test" && sh build/wait_for_port.sh 3990
sleep 20
@RELEASE_VERSION=latest DB_DIR=db-data-7 SEARCH_PROVIDER_NAME=dev.sunbirdrc.registry.service.NativeSearchService FUSION_WRAPPER_BUILD=services/sample-fusionauth-service/ FUSIONAUTH_ISSUER_URL=http://fusionauth:9011/ oauth2_resource_uri=http://fusionauth:9011/ oauth2_resource_roles_path=roles identity_provider=dev.sunbirdrc.auth.genericiam.AuthProviderImpl sunbird_sso_url=http://fusionauthwrapper:3990/fusionauth/api/v1/user IMPORTS_DIR=services/sample-fusionauth-service/imports docker-compose -f docker-compose.yml -f services/sample-fusionauth-service/docker-compose.yml up -d --no-deps registry
@docker-compose --env-file test_environments/test_with_fusionauth.env -f docker-compose.yml -f services/sample-fusionauth-service/docker-compose.yml up -d --no-deps registry
@echo "Starting the test" && sh build/wait_for_port.sh 8081
@docker-compose -f docker-compose.yml -f services/sample-fusionauth-service/docker-compose.yml ps
@curl -v http://localhost:8081/health
@cd java/apitest && MODE=fusionauth ../mvnw -Pe2e test || echo 'Tests failed'
@docker-compose -f docker-compose.yml -f services/sample-fusionauth-service/docker-compose.yml down
@rm -rf db-data-7 || echo "no permission to delete"
@rm -rf db-data-3 || echo "no permission to delete"
make -C services/certificate-signer test
make -C services/public-key-service test
make -C services/context-proxy-service test
Expand Down
3 changes: 3 additions & 0 deletions java/apitest/src/test/java/e2e/registry/certificate.feature
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,8 @@ Feature: Get certificate pdf
Background:
* def certUrl = "http://localhost:8078"
* def templateBody = {"certificate": "{\"name\":\"Test Name\", \"dob\":\"2002-12-22\"}","templateUrl": "http://registry:8081/api/v1/templates/Student.html"}

@envnot=fusionauth
Scenario:
And header Accept = 'application/pdf'
Given url certUrl
Expand All @@ -11,6 +13,7 @@ Feature: Get certificate pdf
Then status 200
#* print response

@envnot=fusionauth
Scenario:
And header Accept = 'application/pdf'
Given url certUrl
Expand Down
12 changes: 9 additions & 3 deletions java/apitest/src/test/java/e2e/registry/registry.feature
Original file line number Diff line number Diff line change
Expand Up @@ -9,12 +9,12 @@ Feature: Registry api tests
* def admin_token = ""
* def client_secret = 'a52c5f4a-89fd-40b9-aea2-3f711f14c889'
* def sleep = function(millis){ java.lang.Thread.sleep(millis) }

@envnot=fusionauth
Scenario: health check
Given path 'health'
When method get
Then status 200

@envnot=fusionauth
Scenario: Create birth certificate schema and issue credentials
# get admin token
* url authUrl
Expand Down Expand Up @@ -102,7 +102,7 @@ Feature: Registry api tests
And response.params.status == "UNSUCCESSFUL"
And response.params.errmsg == "entity status is inactive"


@envnot=fusionauth
Scenario: Create student schema and verify crud apis
# get admin token
* url authUrl
Expand Down Expand Up @@ -234,6 +234,7 @@ Feature: Registry api tests
And response.length == 1
And response[0].contact == '#notpresent'

@envnot=fusionauth
Scenario: Create Board and invite institutes
# get admin token
* url authUrl
Expand Down Expand Up @@ -347,6 +348,7 @@ Feature: Registry api tests
And assert response[0].address[0].phoneNo.length == 1
And assert response[0].address[0].phoneNo[0] == "444"

@envnot=fusionauth
Scenario: write a api test, to test the schema not found error
# get admin token
* url authUrl
Expand Down Expand Up @@ -486,6 +488,7 @@ Feature: Registry api tests
And response.params.status =="UNSUCCESSFUL"
And response.params.errmsg == "Schema 'Teacher1' not found"

@envnot=fusionauth
Scenario: Create student with password schema and verify if password is set
# get admin token
* url authUrl
Expand Down Expand Up @@ -544,6 +547,8 @@ Feature: Registry api tests
When method get
Then status 200
* match response.contactDetails == { mobile: '#notpresent', email: '#present', osid: '#present' }

@envnot=fusionauth
Scenario: Create birth certificate schema, issue credentials then revoke the credential and check for CRUD APIS
# get admin token
* url authUrl
Expand Down Expand Up @@ -678,6 +683,7 @@ Feature: Registry api tests
And print response[notificationStudent]
And assert response[notificationStudent] != null

@envnot=fusionauth
Scenario: Test unique constraints with nested and composite fields
# create entity
Given url registryUrl
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -64,11 +64,7 @@
import dev.sunbirdrc.registry.identity_providers.providers.IdentityProvider;

import java.io.IOException;
import java.util.ArrayList;
import java.util.HashMap;
import java.util.Map;
import java.util.Set;
import java.util.HashSet;
import java.util.*;

import static dev.sunbirdrc.registry.Constants.ATTESTATION_POLICY;

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -663,11 +663,11 @@ public ResponseEntity<Object> getEntityByToken(@PathVariable String entityName,
Response response = new Response(Response.API_ID.GET, "OK", responseParams);
try {
checkEntityNameInDefinitionManager(entityName);
String userId = registryHelper.getUserId(request, entityName);
String userId = registryHelper.getUserId(entityName);
if (!Strings.isEmpty(userId)) {
JsonNode responseFromDb = registryHelper.searchEntitiesByUserId(entityName, userId, viewTemplateId);
JsonNode entities = responseFromDb.get(entityName);
if (entities.size() > 0) {
if (!entities.isEmpty()) {
return new ResponseEntity<>(entities, HttpStatus.OK);
} else {
responseParams.setErrmsg("No record found");
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -434,8 +434,14 @@ public String triggerAttestation(AttestationRequest attestationRequest, Attestat

updateGetFileUrl(attestationRequest.getAdditionalInput());

String propertyData = null;
if (attestationRequest.getPropertyData() != null) {
propertyData = attestationRequest.getPropertyData().toString();
}


PluginRequestMessage message = PluginRequestMessageCreator.create(
attestationRequest.getPropertyData().toString(), condition, attestationOSID, attestationRequest.getEntityName(),
propertyData, condition, attestationOSID, attestationRequest.getEntityName(),
attestationRequest.getEmailId(), attestationRequest.getEntityId(), attestationRequest.getAdditionalInput(),
Action.RAISE_CLAIM.name(), attestationPolicy.getName(), attestationPolicy.getAttestorPlugin(),
attestationPolicy.getAttestorEntity(), attestationPolicy.getAttestorSignin(),
Expand Down Expand Up @@ -484,7 +490,9 @@ private void addAttestationProperty(AttestationRequest attestationRequest) throw
JsonNode parentNode = nodeToUpdate.get(attestationRequest.getEntityName());
JsonNode propertyNode = parentNode.get(attestationRequest.getName());
ObjectNode attestationJsonNode = (ObjectNode) JSONUtil.convertObjectJsonNode(attestationRequest);
attestationJsonNode.set("propertyData", JsonNodeFactory.instance.textNode(attestationRequest.getPropertyData().toString()));
if (attestationRequest.getPropertyData() != null) {
attestationJsonNode.set("propertyData", JsonNodeFactory.instance.textNode(attestationRequest.getPropertyData().toString()));
}
createOrUpdateProperty(attestationRequest.getEntityName(), attestationJsonNode, nodeToUpdate, attestationRequest.getName(), (ObjectNode) parentNode, propertyNode);
updateEntityAndState(existingEntityNode, nodeToUpdate, attestationRequest.getUserId());
}
Expand Down
85 changes: 31 additions & 54 deletions services/certificate-api/main.js
Original file line number Diff line number Diff line change
@@ -1,56 +1,33 @@
const axios = require('axios');
let token = '';
let osids = [""];
osids.forEach(osid => {


let config = {
method: 'get',
maxBodyLength: Infinity,
url: 'http://localhost:8081/api/v1/ProofOfAchievement/'+osid,
headers: {
'Content-Type': 'application/json',
'Authorization': 'Bearer ' + token,
const certificateController = require("./src/routes/certificate_controller");
const http = require('http');
const port = process.env.PORT || 4321;

const server = http.createServer(async (req, res) => {
const label = `${req.url}-${new Date().getTime()}`;
console.time(label)
console.log(`API ${req.method} ${req.url} called`);
try {
if (req.method === 'GET' && req.url.startsWith("/health")) {
res.end("OK")
} else if (req.method === 'POST' && req.url.startsWith("/api/v1/certificate") && ["application/pdf"].includes(req.headers.accept)) {
const data = await certificateController.getCertificatePDF(req, res);
res.end(data)
} else if (req.method === 'POST' && req.url.startsWith("/api/v1/certificate") && ["text/html", "image/svg+xml"].includes(req.headers.accept)) {
const data = await certificateController.getCertificate(req, res);
res.end(data)
} else {
res.statusCode = 404;
res.end("Not found");
}
};

axios.request(config)
.then((response) => {
const getResp = response.data;
delete getResp["osUpdatedAt"]
delete getResp["osUpdatedBy"]
delete getResp["_osSignedData"]
delete getResp["osOwner"]
delete getResp["osCreatedAt"]
delete getResp["osCreatedBy"]
getResp["achievementTitle"] = "Participation"
console.log(getResp)
let config = {
method: 'put',
maxBodyLength: Infinity,
url: 'http://localhost:8081/api/v1/ProofOfAchievement/' + getResp["osid"],
headers: {
'Content-Type': 'application/json',
'Authorization': 'Bearer ' + token,
},
data : getResp
};

axios.request(config)
.then((response) => {
console.log(JSON.stringify(response.data));
})
.catch((error) => {
console.log(error);
});


})
.catch((error) => {
console.log(error);
});
})



} finally {
if (!res.writableEnded) {
res.statusCode = 500;
res.end("Error occurred");
}
}
console.timeEnd(label)
});

server.listen(port, async () => {
console.log(`Server listening on port ${port}`);
});
10 changes: 10 additions & 0 deletions test_environments/test_with_fusionauth.env
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
RELEASE_VERSION=latest
DB_DIR=db-data-3
SEARCH_PROVIDER_NAME=dev.sunbirdrc.registry.service.NativeSearchService
FUSION_WRAPPER_BUILD=services/sample-fusionauth-service/
FUSIONAUTH_ISSUER_URL=http://fusionauth:9011/
oauth2_resource_uri=http://fusionauth:9011/
oauth2_resource_roles_path=roles
identity_provider=dev.sunbirdrc.auth.genericiam.AuthProviderImpl
sunbird_sso_url=http://fusionauthwrapper:3990/fusionauth/api/v1/user
IMPORTS_DIR=services/sample-fusionauth-service/imports

0 comments on commit b679e78

Please sign in to comment.