Skip to content

Commit

Permalink
Merge pull request #224 from blockchain-certificates/fix/context-check
Browse files Browse the repository at this point in the history
fix(Context): limit valid context addresses according to cert-schema preloading
  • Loading branch information
lemoustachiste committed Mar 24, 2022
2 parents cf8b581 + 67693ad commit a51608a
Show file tree
Hide file tree
Showing 3 changed files with 3 additions and 51 deletions.
2 changes: 1 addition & 1 deletion cert_issuer/__init__.py
Original file line number Diff line number Diff line change
@@ -1 +1 @@
__version__ = '3.0.1'
__version__ = '3.0.2'
4 changes: 0 additions & 4 deletions cert_issuer/models.py
Original file line number Diff line number Diff line change
Expand Up @@ -35,10 +35,6 @@ def validate_context (context, type):
vc_context_url = 'https://www.w3.org/2018/credentials/v1'
blockcerts_valid_context_url = [
'https://www.blockcerts.org/schema/3.0/context.json',
'https://blockcerts.org/schema/3.0/context.json',
'https://www.w3id.org/blockcerts/schema/3.0/context.json',
'https://w3id.org/blockcerts/schema/3.0/context.json',
'https://www.w3id.org/blockcerts/v3',
'https://w3id.org/blockcerts/v3'
]

Expand Down
48 changes: 2 additions & 46 deletions tests/v3_certificate_validation/test_unit_context.py
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@ def test_validate_context_invalid_missing_context (self):
assert False

def test_validate_context_invalid_last_context (self):
candidate_context_url = ['https://www.w3.org/2018/credentials/v1', 'https://www.w3id.org/blockcerts/v3', 'link.to.another.context']
candidate_context_url = ['https://www.w3.org/2018/credentials/v1', 'https://w3id.org/blockcerts/v3', 'link.to.another.context']
candidate_type = ['VerifiableCredential', 'BlockcertsCredential']
try:
validate_context(candidate_context_url, candidate_type)
Expand All @@ -47,17 +47,6 @@ def test_validate_context_invalid_last_context (self):

assert False

def test_validate_context_valid_wwww3idcanon (self):
candidate_context_url = ['https://www.w3.org/2018/credentials/v1', 'https://www.w3id.org/blockcerts/v3']
candidate_type = ['VerifiableCredential', 'BlockcertsCredential']
try:
validate_context(candidate_context_url, candidate_type)
except:
assert False
return

assert True

def test_validate_context_valid_w3idcanon (self):
candidate_context_url = ['https://www.w3.org/2018/credentials/v1', 'https://w3id.org/blockcerts/v3']
candidate_type = ['VerifiableCredential', 'BlockcertsCredential']
Expand All @@ -69,41 +58,8 @@ def test_validate_context_valid_w3idcanon (self):

assert True

def test_validate_context_valid_wwwblockcerts (self):
candidate_context_url = ['https://www.w3.org/2018/credentials/v1', 'https://www.blockcerts.org/schema/3.0/context.json']
candidate_type = ['VerifiableCredential', 'BlockcertsCredential']
try:
validate_context(candidate_context_url, candidate_type)
except:
assert False
return

assert True

def test_validate_context_valid_blockcerts (self):
candidate_context_url = ['https://www.w3.org/2018/credentials/v1', 'https://blockcerts.org/schema/3.0/context.json']
candidate_type = ['VerifiableCredential', 'BlockcertsCredential']
try:
validate_context(candidate_context_url, candidate_type)
except:
assert False
return

assert True

def test_validate_context_valid_wwww3id (self):
candidate_context_url = ['https://www.w3.org/2018/credentials/v1', 'https://www.w3id.org/blockcerts/schema/3.0/context.json']
candidate_type = ['VerifiableCredential', 'BlockcertsCredential']
try:
validate_context(candidate_context_url, candidate_type)
except:
assert False
return

assert True

def test_validate_context_valid_w3id (self):
candidate_context_url = ['https://www.w3.org/2018/credentials/v1', 'https://w3id.org/blockcerts/schema/3.0/context.json']
candidate_context_url = ['https://www.w3.org/2018/credentials/v1', 'https://www.blockcerts.org/schema/3.0/context.json']
candidate_type = ['VerifiableCredential', 'BlockcertsCredential']
try:
validate_context(candidate_context_url, candidate_type)
Expand Down

0 comments on commit a51608a

Please sign in to comment.