def test_install_cert(self): ''' Test installing a certificate into the OSX keychain ''' mock = MagicMock() with patch.dict(keychain.__salt__, {'cmd.run': mock}): keychain.install('/path/to/cert.p12', 'passw0rd') mock.assert_called_once_with('security import /path/to/cert.p12 -P passw0rd ' '-k /Library/Keychains/System.keychain')
def test_install_cert(self): """ Test installing a certificate into the macOS keychain """ mock = MagicMock() with patch.dict(keychain.__salt__, {"cmd.run": mock}): keychain.install("/path/to/cert.p12", "passw0rd") mock.assert_called_once_with( "security import /path/to/cert.p12 -P passw0rd " "-k /Library/Keychains/System.keychain")
def test_install_cert_extras(self, unlock_mock): ''' Test installing a certificate into the OSX keychain with extras ''' mock = MagicMock() with patch.dict(keychain.__salt__, {'cmd.run': mock}): keychain.install('/path/to/cert.p12', 'passw0rd', '/path/to/chain', allow_any=True, keychain_password='******') unlock_mock.assert_called_once_with('/path/to/chain', 'passw0rd1') mock.assert_called_once_with('security import /path/to/cert.p12 -P passw0rd -k /path/to/chain -A')
def test_install_cert_extras(self): """ Test installing a certificate into the macOS keychain with extras """ mock = MagicMock() with patch.dict(keychain.__salt__, { "cmd.run": mock }), patch("salt.modules.mac_keychain.unlock_keychain") as unlock_mock: keychain.install( "/path/to/cert.p12", "passw0rd", "/path/to/chain", allow_any=True, keychain_password="******", ) unlock_mock.assert_called_once_with("/path/to/chain", "passw0rd1") mock.assert_called_once_with( "security import /path/to/cert.p12 -P passw0rd -k /path/to/chain -A" )