Skip to content
This repository was archived by the owner on Oct 10, 2020. It is now read-only.
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
14 changes: 14 additions & 0 deletions tests/unit/test_trust.py
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,14 @@
REGISTRIESD = "etc/containers/registries.d"
TEST_POLICY = os.path.join(os.path.join(FIXTURE_DIR, "etc/containers"), "policy.json")

def _new_enough():
py_version = sys.version_info
if (py_version.major, py_version.minor, py_version.micro) >= (2, 7, 6):
return True
return False

new_enough = _new_enough()

class TestAtomicTrust(unittest.TestCase):

class Args():
Expand Down Expand Up @@ -78,6 +86,7 @@ def test_add_repo_sigstore(self):
conf_modified = yaml.load(f)
self.assertEqual(conf_expected, conf_modified)

@unittest.skipUnless(new_enough, "Requires 2.7.6 or newer")
def test_add_trust_keys(self):
args = self.Args()
args.sigstore = None
Expand All @@ -90,6 +99,7 @@ def test_add_trust_keys(self):
self.assertEqual(d["transports"]["atomic"]["docker.io"][0]["keyPath"],
os.path.join(FIXTURE_DIR, "key1.pub"))

@unittest.skipUnless(new_enough, "Requires 2.7.6 or newer")
def test_modify_trust_2_keys(self):
args = self.Args()
args.sigstore = None
Expand All @@ -103,6 +113,7 @@ def test_modify_trust_2_keys(self):
self.assertEqual(d["transports"]["atomic"]["docker.io"][1]["keyPath"],
os.path.join(FIXTURE_DIR, "key2.pub"))

@unittest.skipUnless(new_enough, "Requires 2.7.6 or newer")
def test_add_reject_type(self):
args = self.Args()
args.trust_type = "reject"
Expand All @@ -118,6 +129,7 @@ def test_add_reject_type(self):
self.assertEqual(d["transports"]["docker"][args.registry][0]["type"],
args.trust_type)

@unittest.skipUnless(new_enough, "Requires 2.7.6 or newer")
def test_delete_trust(self):
args = self.Args()
args.pubkeys = []
Expand Down Expand Up @@ -198,5 +210,7 @@ def tearDownClass(cls):
"""
shutil.copyfile(os.path.join(FIXTURE_DIR, "default_policy.json"), TEST_POLICY)



if __name__ == '__main__':
unittest.main()
10 changes: 9 additions & 1 deletion tests/unit/test_util.py
Original file line number Diff line number Diff line change
@@ -1,8 +1,15 @@
import unittest
import selinux

import sys
from Atomic import util

def _new_enough():
py_version = sys.version_info
if (py_version.major, py_version.minor, py_version.micro) >= (2, 7, 6):
return True
return False

new_enough = _new_enough()

class TestAtomicUtil(unittest.TestCase):

Expand Down Expand Up @@ -80,6 +87,7 @@ def test_decompose(self):
for image in images:
self.assertEqual(util.Decompose(image[0]).all, image[1])

@unittest.skipUnless(new_enough, "Requires 2.7.6 or newer")
def test_valid_uri(self):
valid_uris = ['example.com', 'example.com:5000', 'example.US.com', 'example.com/image/name:version1', 'example.com:5000/foo/bar/image:tag', 'example_inc.com']
invalid_uris = ['example.com/Image/name', 'example.com/image(name):latest', 'example.com/foo_bar', 'example.com:5000:8888', 'example.com:foo', 'example[us].com', 'example.com#foo/bar']
Expand Down