def test_different_mixed_caps(self): secret_01 = new.generate_auth_key() secret_02 = new.generate_auth_key() key_path_01 = self.test_dir + "/01.keyring" key_path_02 = self.test_dir + "/02.keyring" write_key_mon_with_caps(key_path_01, secret_01) write_key_mon_without_caps(key_path_02, secret_02) same = gatherkeys._keyring_equivalent(key_path_01, key_path_02) assert same is False
def test_different_without_caps(self): secret_01 = new.generate_auth_key() secret_02 = new.generate_auth_key() key_path_01 = self.test_dir + "/01.keyring" key_path_02 = self.test_dir + "/02.keyring" write_key_mon_without_caps(key_path_01, secret_01) write_key_mon_without_caps(key_path_02, secret_02) same = gatherkeys._keyring_equivalent(key_path_01, key_path_02) assert same is False
def mock_hosts_get_file_key_content(host, **kwargs): output = mock_distro() mon_keyring = '[mon.]\nkey = %s\ncaps mon = allow *\n' % new.generate_auth_key( ) output.conn.remote_module.get_file_result = mon_keyring.encode('utf-8') output.conn.remote_module.longhostname = host return output
def test_missing_key_2(self): secret_01 = new.generate_auth_key() key_path_01 = self.test_dir + "/01.keyring" key_path_02 = self.test_dir + "/02.keyring" write_key_mon_with_caps_with_tab_quote(key_path_01, secret_01) with pytest.raises(IOError): gatherkeys._keyring_equivalent(key_path_01, key_path_02)
def test_identical_with_caps(self): secret_01 = new.generate_auth_key() key_path_01 = self.test_dir + "/01.keyring" key_path_02 = self.test_dir + "/02.keyring" write_key_mon_with_caps(key_path_01, secret_01) write_key_mon_with_caps(key_path_02, secret_01) same = gatherkeys._keyring_equivalent(key_path_01, key_path_02) assert same is True
def get_key_dynamic(keytype, key_path): with open(key_path, 'w', 0o600) as f: f.write("[%s]\n" % (gatherkeys.keytype_identity(keytype))) f.write("key='%s'" % (new.generate_auth_key()))
def get_key_dynamic(keytype, key_path): with open(key_path, 'w', 0600) as f: f.write("[%s]\n" % (gatherkeys.keytype_identity(keytype))) f.write("key='%s'" % (new.generate_auth_key()))
def mock_remoto_process_check_success(conn, args): secret = new.generate_auth_key() out = '[mon.]\nkey = %s\ncaps mon = allow *\n' % secret return out.split('\n'), "", 0
def mock_remoto_process_check_success(conn, args): secret = new.generate_auth_key() out = '[mon.]\nkey = %s\ncaps mon = allow *\n' % secret return out.encode('utf-8').split(b'\n'), [], 0
def mock_hosts_get_file_key_content(host, **kwargs): output = mock_distro() mon_keyring = '[mon.]\nkey = %s\ncaps mon = allow *\n' % new.generate_auth_key() output.conn.remote_module.get_file_result = mon_keyring.encode('utf-8') output.conn.remote_module.longhostname = host return output