def test_installed_cert_hash_different(self):
        expected = {
            'changes': {'installed': 'Friendly Name', 'uninstalled': 'Friendly Name'},
            'comment': 'Found a certificate with the same name but different hash, removing it.\n',
            'name': '/path/to/cert.p12',
            'result': True
        }

        list_mock = MagicMock(side_effect=[['Friendly Name'], []])
        friendly_mock = MagicMock(return_value='Friendly Name')
        install_mock = MagicMock(return_value='1 identity imported.')
        uninstall_mock = MagicMock(return_value='removed.')
        hash_mock = MagicMock(side_effect=['ABCD', 'XYZ'])
        with patch.dict(keychain.__salt__, {'keychain.list_certs': list_mock,
                                            'keychain.get_friendly_name': friendly_mock,
                                            'keychain.install': install_mock,
                                            'keychain.uninstall': uninstall_mock,
                                            'keychain.get_hash': hash_mock}):
            out = keychain.installed('/path/to/cert.p12', 'passw0rd')
            list_mock.assert_has_calls(calls=[call('/Library/Keychains/System.keychain'),
                                              call('/Library/Keychains/System.keychain')])
            friendly_mock.assert_called_once_with('/path/to/cert.p12', 'passw0rd')
            install_mock.assert_called_once_with('/path/to/cert.p12', 'passw0rd', '/Library/Keychains/System.keychain')
            uninstall_mock.assert_called_once_with('Friendly Name', '/Library/Keychains/System.keychain',
                                                   keychain_password=None)
            self.assertEqual(out, expected)
Test installing a certificate into the OSX keychain when it's already installed but
dataset/ETHPy150Open saltstack/salt/tests/unit/states/mac_keychain_test.py/KeychainTestCase.test_installed_cert_hash_different