aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorWill Bond <will@wbond.net>2022-01-26 22:52:27 -0500
committerGitHub <noreply@github.com>2022-01-26 22:52:27 -0500
commitf9133f084cc73c6dd1e55fcb56800d1792c68bfc (patch)
treeb7e9881bbd9c1ce89ab3377f48a1412c5eaef083
parentf8214f908c40bfec4050d26b61b17e90ddf9e962 (diff)
parentc6fe6cd9b03767d36062f5a2f16c76b2d212ad76 (diff)
downloadasn1crypto-f9133f084cc73c6dd1e55fcb56800d1792c68bfc.tar.gz
Merge branch 'master' into bugfix/attcertissuer-tagging-fix
-rw-r--r--.github/workflows/ci.yml12
-rw-r--r--asn1crypto/cms.py10
-rw-r--r--dev/ci-cleanup.py28
-rw-r--r--tests/test_cms.py34
4 files changed, 79 insertions, 5 deletions
diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml
index c7b805b..581e205 100644
--- a/.github/workflows/ci.yml
+++ b/.github/workflows/ci.yml
@@ -173,10 +173,16 @@ jobs:
run: python2 run.py deps
- name: Run test suite (2.7)
run: python2 run.py ci-driver
+ - name: Cleanup deps (2.7)
+ if: always()
+ run: python2 run.py ci-cleanup
- name: Install dependencies (3.8)
run: python3 run.py deps
- name: Run test suite (3.8)
run: python3 run.py ci-driver
+ - name: Cleanup deps (3.8)
+ if: always()
+ run: python3 run.py ci-cleanup
build-arm64:
name: Python 2.7/3.8 on arm64
@@ -187,7 +193,13 @@ jobs:
run: python2 run.py deps
- name: Run test suite (2.7)
run: python2 run.py ci-driver
+ - name: Cleanup deps (2.7)
+ if: always()
+ run: python2 run.py ci-cleanup
- name: Install dependencies (3.8)
run: python3 run.py deps
- name: Run test suite (3.8)
run: python3 run.py ci-driver
+ - name: Cleanup deps (3.8)
+ if: always()
+ run: python3 run.py ci-cleanup
diff --git a/asn1crypto/cms.py b/asn1crypto/cms.py
index 8ee3ff0..7ce583d 100644
--- a/asn1crypto/cms.py
+++ b/asn1crypto/cms.py
@@ -315,7 +315,7 @@ class SetOfSvceAuthInfo(SetOf):
class RoleSyntax(Sequence):
_fields = [
('role_authority', GeneralNames, {'implicit': 0, 'optional': True}),
- ('role_name', GeneralName, {'implicit': 1}),
+ ('role_name', GeneralName, {'explicit': 1}),
]
@@ -337,7 +337,7 @@ class ClassList(BitString):
class SecurityCategory(Sequence):
_fields = [
('type', ObjectIdentifier, {'implicit': 0}),
- ('value', Any, {'implicit': 1}),
+ ('value', Any, {'explicit': 1}),
]
@@ -347,9 +347,9 @@ class SetOfSecurityCategory(SetOf):
class Clearance(Sequence):
_fields = [
- ('policy_id', ObjectIdentifier, {'implicit': 0}),
- ('class_list', ClassList, {'implicit': 1, 'default': 'unclassified'}),
- ('security_categories', SetOfSecurityCategory, {'implicit': 2, 'optional': True}),
+ ('policy_id', ObjectIdentifier),
+ ('class_list', ClassList, {'default': set(['unclassified'])}),
+ ('security_categories', SetOfSecurityCategory, {'optional': True}),
]
diff --git a/dev/ci-cleanup.py b/dev/ci-cleanup.py
new file mode 100644
index 0000000..92ca6da
--- /dev/null
+++ b/dev/ci-cleanup.py
@@ -0,0 +1,28 @@
+# coding: utf-8
+from __future__ import unicode_literals, division, absolute_import, print_function
+
+import os
+import shutil
+
+from . import build_root, other_packages
+
+
+def run():
+ """
+ Cleans up CI dependencies - used for persistent GitHub Actions
+ Runners since they don't clean themselves up.
+ """
+
+ print("Removing ci dependencies")
+ deps_dir = os.path.join(build_root, 'modularcrypto-deps')
+ if os.path.exists(deps_dir):
+ shutil.rmtree(deps_dir, ignore_errors=True)
+
+ print("Removing modularcrypto packages")
+ for other_package in other_packages:
+ pkg_dir = os.path.join(build_root, other_package)
+ if os.path.exists(pkg_dir):
+ shutil.rmtree(pkg_dir, ignore_errors=True)
+ print()
+
+ return True
diff --git a/tests/test_cms.py b/tests/test_cms.py
index 3f8c98c..52d852e 100644
--- a/tests/test_cms.py
+++ b/tests/test_cms.py
@@ -21,6 +21,30 @@ tests_root = os.path.dirname(__file__)
fixtures_dir = os.path.join(tests_root, 'fixtures')
+class ClearanceTests(unittest.TestCase):
+
+ def test_clearance_decode_bad_tagging(self):
+ rfc_3281_wrong_tagging = b'\x30\x08\x80\x02\x88\x37\x81\x02\x02\x4c'
+ # This test documents the fact that we can't deal with the "wrong"
+ # version of Clearance in RFC 3281
+ self.assertRaises(
+ ValueError,
+ lambda: cms.Clearance.load(rfc_3281_wrong_tagging).native
+ )
+
+ def test_clearance_decode_correct_tagging(self):
+ correct_tagging = b'\x30\x08\x06\x02\x88\x37\x03\x02\x02\x4c'
+ clearance_obj = cms.Clearance.load(correct_tagging)
+ self.assertEqual(
+ util.OrderedDict([
+ ('policy_id', '2.999'),
+ ('class_list', set(['secret', 'top_secret', 'unclassified'])),
+ ('security_categories', None)
+ ]),
+ clearance_obj.native
+ )
+
+
class CMSTests(unittest.TestCase):
def test_create_content_info_data(self):
@@ -913,3 +937,13 @@ class CMSTests(unittest.TestCase):
ac_info = ac_parsed['ac_info']
self.assertIsInstance(ac_info['issuer'].chosen, cms.V2Form)
self.assertEqual(1, len(ac_info['issuer'].chosen['issuer_name']))
+
+ def test_create_role_syntax(self):
+ rs = cms.RoleSyntax({'role_name': {'rfc822_name': 'test@example.com'}})
+ self.assertEqual(
+ util.OrderedDict([
+ ('role_authority', None),
+ ('role_name', 'test@example.com')
+ ]),
+ rs.native
+ )