예제 #1
0
 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
예제 #2
0
 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
예제 #3
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
예제 #4
0
 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)
예제 #5
0
 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)
예제 #6
0
 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
예제 #7
0
 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
예제 #8
0
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()))
예제 #9
0
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
예제 #11
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
예제 #12
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