Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Feat: Credential Service #217

Merged
merged 67 commits into from
Jul 25, 2023
Merged

Conversation

techsavvyash
Copy link
Contributor

@techsavvyash techsavvyash commented Apr 18, 2023

Description

This PR contains the actual code for the Credential service unlike the previous PR which was submodules based.

Signed-off-by: Yash Mittal <mittal.yash12@hotmail.com>

Feat: Add credentials-service

Signed-off-by: Yash Mittal <mittal.yash12@hotmail.com>
Signed-off-by: Yash Mittal <mittal.yash12@hotmail.com>
Signed-off-by: Yash Mittal <mittal.yash12@hotmail.com>
@techsavvyash techsavvyash marked this pull request as draft April 18, 2023 12:42
CREATE TYPE "VCStatus" AS ENUM ('PENDING', 'ISSUED', 'REVOKED');

-- CreateTable
CREATE TABLE "VC" (
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

is this for storing credential schema?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This table has been deprecated and will be removed. Initially it was meant to store the issued credentials in the postgres db associated with the credentials service.

);

-- CreateTable
CREATE TABLE "VCV2" (
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

what is this table used for?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Since the APIs are not connected with the registry right now, so we have a postgres instance associated wih the credential service to save the issued credentials in the postgres instance. This table stores those credentials.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

we need to fix the table name

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Will rename this to "VerifiableCredentials".

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

are these fixed? @techsavvyash

);

-- CreateTable
CREATE TABLE "Counter" (
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

you can use SERIAL pseudo-type

@techsavvyash techsavvyash marked this pull request as ready for review June 15, 2023 08:57
@techsavvyash techsavvyash requested a review from tejash-jl June 15, 2023 09:26
@techsavvyash
Copy link
Contributor Author

Hey @tejash-jl,
If everything is aligned can we merge this PR and #218 and #219 ?
Thanks

cc: @ChakshuGautam

@tejash-jl
Copy link
Member

remove commented codes

@tejash-jl
Copy link
Member

integrate e2e test to the top level Makefile

@tejash-jl
Copy link
Member

@techsavvyash you would need to document about this service here,

@tejash-jl
Copy link
Member

Create e2e tests for all v2 APIs
Existing tests are present here, https://github.com/Sunbird-RC/sunbird-rc-core/tree/main/java/apitest/src/test/java/e2e/registry

Makefile Outdated
@@ -41,16 +43,16 @@ test: build
@echo "Starting the test" && sh build/wait_for_port.sh 8081
@docker-compose ps
@curl -v http://localhost:8081/health
@cd java/apitest && ../mvnw -Pe2e test || echo 'Tests failed'
@cd java/apitest && ../mvnw -Pe2e test
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Could you add the tests failure message as well.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Currently, the services will throw an error and fail the test target if any test fails with the test report. Adding an '||condition will not fail the Makefile'stest` target, probably.

@@ -223,7 +223,7 @@ Feature: Registry api tests
When method post
Then status 200
And response.result.Teacher.transactionId.length > 0
* sleep(3000)
* sleep(7000)
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Why is this changed.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This happened due to one of the rebase probably, undid all these changes.

@@ -468,10 +468,10 @@ Feature: Registry api tests
And response.params.errmsg == "Schema 'Teacher1' not found"
# patch unavailable schema with sign
Given url registryUrl
And path '/api/v1/Teacher/sign'
And path '/api/v1/Teacher1/sign'
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Why was this changed.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

resolved to original

And header Authorization = admin_token
And request read('TeacherRequest.json')
When method patch
When method get
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Why is this changed.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

reverted to original

}
});

// it('should show a stremable file', async () => {
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Please remove comments.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

done, thanks

import { Extensible } from "did-resolver";


// class Credential implements W3CCredential {
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Remove commented Code.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

done, thanks

@tushar5526
Copy link
Contributor

Screenshot 2023-07-11 at 7 26 42 PM

@@ -50,7 +48,7 @@ services:
VAULT_ADDR: "http://vault:8200"
# This will be replaced automatically on initialisation
# make compose-init will call setup_vault.sh
VAULT_TOKEN: hvs.ZBCv64FQYZibBmfa6cgcc8ls
VAULT_TOKEN: hvs.ANn8uBxHYvRCv5Q3FXuqzoIG
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Can you move these to .env file.

@srprasanna
Copy link
Collaborator

Screenshot 2023-07-11 at 7 26 42 PM

Can you try to increase overall coverage. Some of the files have about 40-50% coverage. Can you look at the credential service and controller.

@tushar5526
Copy link
Contributor

Screenshot 2023-07-18 at 11 43 41 AM

I have increased the test coverage. Please take a look. 72-101 line in the controller is tested in e2e tests but not reflected here. It is the header parsing logic for accept header

@tushar5526
Copy link
Contributor

Moving to vault token to .env will require a bit of refactoring in all 3 services and I am planning to make it as a different PR. For now, I am just removing it from the compose.

@srprasanna srprasanna merged commit f404659 into Sunbird-RC:release-2.0.0 Jul 25, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
Status: Released
Development

Successfully merging this pull request may close these issues.

5 participants