Esempio n. 1
0
    def test_remote_sha_put_hash_fail(self):
        class MockSSHShell2(MockSSHShell):
            def run(self, cmd, timeout=30):
                return True, ""

        scput = SplitCopyPut()
        scput.sshshell = MockSSHShell2()
        scput.scs = MockSplitCopyShared()
        sha_bin = "shasum"
        sha_len = 224
        sha_hash = {
            224: "d2a90f1c9edd2e9771306d8c8f4a4fc802181b973ee8167fcaff98f4"
        }
        with raises(SystemExit):
            scput.remote_sha_put(sha_bin, sha_len, sha_hash)
Esempio n. 2
0
    def test_remote_sha_put_cmd_fail(self, capsys, monkeypatch: MonkeyPatch):
        class MockSSHShell2(MockSSHShell):
            def run(self, cmd, timeout=30):
                return False, ""

        scput = SplitCopyPut()
        scput.sshshell = MockSSHShell2()
        scput.scs = MockSplitCopyShared()
        sha_bin = "shasum"
        sha_len = 224
        sha_hash = {
            224: "d2a90f1c9edd2e9771306d8c8f4a4fc802181b973ee8167fcaff98f4"
        }
        scput.remote_sha_put(sha_bin, sha_len, sha_hash)
        captured = capsys.readouterr()
        assert re.search(r"remote sha hash generation failed", captured.out)
Esempio n. 3
0
    def test_remote_sha_put_hash_mismatch(self):
        class MockSSHShell2(MockSSHShell):
            def run(self, cmd, timeout=30):
                stdout = (
                    "foo@bar ~ % shasum -a 224 /var/tmp/foo\n"
                    "d2a90f1c9edd2e9771306d8c8f4a4fc802181b973ee8167fceff98f4 "
                    "/var/tmp/foo\n"
                    "foo@bar ~ % \n")
                return True, stdout

        scput = SplitCopyPut()
        scput.sshshell = MockSSHShell2()
        scput.scs = MockSplitCopyShared()
        sha_bin = "shasum"
        sha_len = 224
        sha_hash = {
            224: "d2a90f1c9edd2e9771306d8c8f4a4fc802181b973ee8167fcaff98f4"
        }
        with raises(SystemExit):
            scput.remote_sha_put(sha_bin, sha_len, sha_hash)
Esempio n. 4
0
    def test_remote_sha_put(self, monkeypatch: MonkeyPatch):
        class MockSSHShell2(MockSSHShell):
            def run(self, cmd, timeout=30):
                stdout = (
                    "foo@bar ~ % sha224sum -a 224 /var/tmp/foo\n"
                    "d2a90f1c9edd2e9771306d8c8f4a4fc802181b973ee8167fcaff98f4 "
                    "/var/tmp/foo\n"
                    "foo@bar ~ % \n")
                return True, stdout

        scput = SplitCopyPut()
        scput.sshshell = MockSSHShell2()
        scput.scs = MockSplitCopyShared()
        sha_bin = "sha224sum"
        sha_len = 224
        sha_hash = {
            224: "d2a90f1c9edd2e9771306d8c8f4a4fc802181b973ee8167fcaff98f4"
        }
        result = scput.remote_sha_put(sha_bin, sha_len, sha_hash)
        expected = None
        assert expected == result