Skip to content

Commit

Permalink
Merge pull request #251 from blockchain-certificates/test/vc-compliance
Browse files Browse the repository at this point in the history
Test/vc compliance
  • Loading branch information
lemoustachiste authored May 26, 2023
2 parents 48420fa + 1413e52 commit 9133b17
Show file tree
Hide file tree
Showing 14 changed files with 3,835 additions and 25 deletions.
3 changes: 2 additions & 1 deletion .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -25,12 +25,13 @@ node_modules/*
requirements.txt
.idea/*
*.ini*
pk_issuer.txt
blockcerts testnet bitcoin address.txt
.vscode/*
.cache/*
.tox/*
*.egg-info/*
docs/_build/*
site/*
pk_issuer.txt
priv*.txt
pk.txt
13 changes: 12 additions & 1 deletion .travis.yml
Original file line number Diff line number Diff line change
@@ -1,11 +1,22 @@
sudo: false
language: python
dist: focal
branches:
only:
- master
python:
- "3.6"
- "3.10"
install: pip install tox-travis
script: tox
after_success:
- pip install python-semantic-release
- git config user.name botcerts
- git config user.email [email protected]
- semantic-release publish
after_script:
- nvm install 16
- sh prepare-vc-compliance-tests-config.sh
- python3 setup.py install
- npm ci
- npm run test:vc-compliance
- 'if [ "$TRAVIS_PULL_REQUEST" = "false" ]; then sh publish-vc-compliance-result.sh; fi' # if no changes, no commit
1 change: 1 addition & 0 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
[![Verifiable Credential Compliance result](https://badgen.net/badge/Verifiable%20Credentials%20v1/compliant/green?icon=https://www.w3.org/Icons/WWW/w3c_home_nb-v.svg)](https://github.com/blockchain-certificates/cert-issuer/vc-compliance-report.html)
[![Build Status](https://travis-ci.org/blockchain-certificates/cert-issuer.svg?branch=master)](https://travis-ci.org/blockchain-certificates/cert-issuer)
[![PyPI version](https://badge.fury.io/py/cert-issuer.svg)](https://badge.fury.io/py/cert-issuer)

Expand Down
4 changes: 2 additions & 2 deletions cert_issuer/config.py
Original file line number Diff line number Diff line change
Expand Up @@ -33,8 +33,8 @@ def configure_logger():
def add_arguments(p):
p.add('-c', '--my-config', required=False, env_var='CONFIG_FILE',
is_config_file=True, help='config file path')
p.add_argument('--issuing_address', required=True, help='issuing address', env_var='ISSUING_ADDRESS')
p.add_argument('--verification_method', required=True, help='Verification method for the Linked Data Proof', env_var='VERIFICATION_METHOD')
p.add_argument('--issuing_address', required=False, help='issuing address', env_var='ISSUING_ADDRESS')
p.add_argument('--verification_method', required=False, help='Verification method for the Linked Data Proof', env_var='VERIFICATION_METHOD')
p.add_argument('--usb_name', required=True, help='usb path to key_file', env_var='USB_NAME')
p.add_argument('--key_file', required=True,
help='name of file on USB containing private key', env_var='KEY_FILE')
Expand Down
19 changes: 17 additions & 2 deletions cert_issuer/models/verifiable_credential.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
import re
import logging
from urllib.parse import urlparse
from cert_schema import ContextUrls

Expand Down Expand Up @@ -42,15 +43,29 @@ def validate_context (context, type):
if len(type) > 1 and len(context) == 1:
raise ValueError('A more specific type: {}, was detected, yet no context seems provided for that type'.format(type[1]))
if context[-1] not in blockcerts_valid_context_url:
raise ValueError('Last @context declared must be one of valid blockcerts context url, preferably {}, was given {}'.format(blockcerts_valid_context_url[-1]), context[-1])
logging.warning("""
Last `@context` is not blockcerts' context. It is not a critical issue but some issues have come up at times
because of some properties of a different context overwriting blockcerts' taxonomy. Check this property
again in case of verification issue.
""")

pass

def validate_credential_subject (credential_subject):
pass

def validate_issuer (certificate_issuer):
if not is_valid_url(certificate_issuer) and not is_valid_url(certificate_issuer['id']):
has_error = False
if isinstance(certificate_issuer, str) and not is_valid_url(certificate_issuer):
has_error = True

if isinstance(certificate_issuer, dict) and not is_valid_url(certificate_issuer['id']):
has_error = True

if isinstance(certificate_issuer, list):
has_error = True

if has_error:
raise ValueError('`issuer` property must be a URL string or an object with an `id` property containing a URL string')
pass

Expand Down
Original file line number Diff line number Diff line change
@@ -1,20 +1,23 @@
{
"@context": [
"https://www.w3.org/2018/credentials/v1",
"https://www.w3.org/2018/credentials/examples/v1",
"https://w3id.org/blockcerts/v3"
],
"id": "urn:uuid:bbba8553-8ec1-445f-82c9-a57251dd731c",
"type": [
"VerifiableCredential",
"BlockcertsCredential"
],
"issuer": "did:example:23adb1f712ebc6f1c276eba4dfa",
"issuanceDate": "2022-01-01T19:33:24Z",
"issuer": "https://www.blockcerts.org/samples/3.0/issuer-blockcerts.json",
"issuanceDate": "2022-08-18T14:04:24Z",
"credentialSubject": {
"id": "did:example:ebfeb1f712ebc6f1c276e12ec21",
"alumniOf": {
"id": "did:example:c276e12ec21ebfeb1f712ebc6f1"
}
"name": "Julien Fraichot",
"email": "[email protected]",
"publicKey": "ecdsa-koblitz-pubkey:1BPQXndcz5Uf3qZQkgnvJC87LUD5n7a2mC"
},
"display": {
"contentMediaType": "text/html",
"content": "<div style=\"background-color:transparent;padding:6px;display:inline-flex;align-items:center;flex-direction:column\">Hello world</div>"
}
}
}
Loading

0 comments on commit 9133b17

Please sign in to comment.