"Fossies" - the Fresh Open Source Software Archive  

Source code changes of the file "tests/pytests/unit/modules/test_tls.py" between
salt-3002.1.tar.gz and salt-3002.2.tar.gz

About: SaltStack is a systems management software for data center automation, cloud orchestration, server provisioning, configuration management and more. Community version.

test_tls.py  (salt-3002.1):test_tls.py  (salt-3002.2)
skipping to change at line 25 skipping to change at line 25
"L": "Salt Lake City", "L": "Salt Lake City",
"O": "SaltStack", "O": "SaltStack",
"OU": "Test Unit", "OU": "Test Unit",
"emailAddress": "xyz@pdq.net", "emailAddress": "xyz@pdq.net",
"digest": "sha256", "digest": "sha256",
"replace": False, "replace": False,
} }
} }
@pytest.fixture(autouse=True) @pytest.fixture(autouse=True)
def setup_loader(request): def setup_loader():
setup_loader_modules = {tls: {}} setup_loader_modules = {tls: {}}
with pytest.helpers.loader_mock(request, setup_loader_modules) as loader_moc k: with pytest.helpers.loader_mock(setup_loader_modules) as loader_mock:
yield loader_mock yield loader_mock
def test_create_ca_permissions_on_cert_and_key(tmpdir, tls_test_data): def test_create_ca_permissions_on_cert_and_key(tmpdir, tls_test_data):
ca_name = "test_ca" ca_name = "test_ca"
certp = tmpdir.join(ca_name).join("{}_ca_cert.crt".format(ca_name)).strpath certp = tmpdir.join(ca_name).join("{}_ca_cert.crt".format(ca_name)).strpath
certk = tmpdir.join(ca_name).join("{}_ca_cert.key".format(ca_name)).strpath certk = tmpdir.join(ca_name).join("{}_ca_cert.key".format(ca_name)).strpath
mock_opt = MagicMock(return_value=tmpdir) mock_opt = MagicMock(return_value=tmpdir)
mock_ret = MagicMock(return_value=0) mock_ret = MagicMock(return_value=0)
print(tls_test_data) print(tls_test_data)
with patch.dict( with patch.dict(
tls.__salt__, {"config.option": mock_opt, "cmd.retcode": mock_ret} tls.__salt__, {"config.option": mock_opt, "cmd.retcode": mock_ret}
), patch.dict(tls.__opts__, {"hash_type": "sha256", "cachedir": tmpdir}): ), patch.dict(tls.__opts__, {"hash_type": "sha256", "cachedir": str(tmpdir)} ):
tls.create_ca(ca_name, days=365, fixmode=False, **tls_test_data["create_ ca"]) tls.create_ca(ca_name, days=365, fixmode=False, **tls_test_data["create_ ca"])
certp_mode = os.stat(certp).st_mode & 0o7777 certp_mode = os.stat(certp).st_mode & 0o7777
certk_mode = os.stat(certk).st_mode & 0o7777 certk_mode = os.stat(certk).st_mode & 0o7777
assert 0o644 == certp_mode assert 0o644 == certp_mode
assert 0o600 == certk_mode assert 0o600 == certk_mode
def test_create_csr_permissions_on_csr_and_key(tmpdir, tls_test_data): def test_create_csr_permissions_on_csr_and_key(tmpdir, tls_test_data):
ca_name = "test_ca" ca_name = "test_ca"
csrp = ( csrp = (
skipping to change at line 71 skipping to change at line 71
.strpath .strpath
) )
mock_opt = MagicMock(return_value=tmpdir) mock_opt = MagicMock(return_value=tmpdir)
mock_ret = MagicMock(return_value=0) mock_ret = MagicMock(return_value=0)
mock_pgt = MagicMock(return_value=False) mock_pgt = MagicMock(return_value=False)
with patch.dict( with patch.dict(
tls.__salt__, tls.__salt__,
{"config.option": mock_opt, "cmd.retcode": mock_ret, "pillar.get": mock_ pgt}, {"config.option": mock_opt, "cmd.retcode": mock_ret, "pillar.get": mock_ pgt},
), patch.dict(tls.__opts__, {"hash_type": "sha256", "cachedir": tmpdir}): ), patch.dict(tls.__opts__, {"hash_type": "sha256", "cachedir": str(tmpdir)} ):
tls.create_ca(ca_name, days=365, **tls_test_data["create_ca"]) tls.create_ca(ca_name, days=365, **tls_test_data["create_ca"])
tls.create_csr(ca_name, **tls_test_data["create_ca"]) tls.create_csr(ca_name, **tls_test_data["create_ca"])
csrp_mode = os.stat(csrp).st_mode & 0o7777 csrp_mode = os.stat(csrp).st_mode & 0o7777
keyp_mode = os.stat(keyp).st_mode & 0o7777 keyp_mode = os.stat(keyp).st_mode & 0o7777
assert 0o644 == csrp_mode assert 0o644 == csrp_mode
assert 0o600 == keyp_mode assert 0o600 == keyp_mode
def test_create_self_signed_cert_permissions_on_csr_cert_and_key(tmpdir, tls_tes t_data): def test_create_self_signed_cert_permissions_on_csr_cert_and_key(tmpdir, tls_tes t_data):
skipping to change at line 103 skipping to change at line 103
.strpath .strpath
) )
mock_opt = MagicMock(return_value=tmpdir) mock_opt = MagicMock(return_value=tmpdir)
mock_ret = MagicMock(return_value=0) mock_ret = MagicMock(return_value=0)
mock_pgt = MagicMock(return_value=False) mock_pgt = MagicMock(return_value=False)
with patch.dict( with patch.dict(
tls.__salt__, tls.__salt__,
{"config.option": mock_opt, "cmd.retcode": mock_ret, "pillar.get": mock_ pgt}, {"config.option": mock_opt, "cmd.retcode": mock_ret, "pillar.get": mock_ pgt},
), patch.dict(tls.__opts__, {"hash_type": "sha256", "cachedir": tmpdir}): ), patch.dict(tls.__opts__, {"hash_type": "sha256", "cachedir": str(tmpdir)} ):
tls.create_self_signed_cert(ca_name, days=365, **tls_test_data["create_c a"]) tls.create_self_signed_cert(ca_name, days=365, **tls_test_data["create_c a"])
certp_mode = os.stat(certp).st_mode & 0o7777 certp_mode = os.stat(certp).st_mode & 0o7777
keyp_mode = os.stat(keyp).st_mode & 0o7777 keyp_mode = os.stat(keyp).st_mode & 0o7777
assert 0o644 == certp_mode assert 0o644 == certp_mode
assert 0o600 == keyp_mode assert 0o600 == keyp_mode
 End of changes. 5 change blocks. 
5 lines changed or deleted 5 lines changed or added

Home  |  About  |  Features  |  All  |  Newest  |  Dox  |  Diffs  |  RSS Feeds  |  Screenshots  |  Comments  |  Imprint  |  Privacy  |  HTTP(S)