Ejemplo n.º 1
0
    def test_key_recovery(self):
        mkfs_output = self.mkfs()

        hit = re.search(r'^---BEGIN MASTER KEY---\n'
                        r'(.+)\n'
                        r'---END MASTER KEY---$', mkfs_output, re.MULTILINE)
        assert hit
        master_key = hit.group(1)

        plain_backend = local.Backend(Namespace(
            storage_url=self.storage_url))
        del plain_backend['s3ql_passphrase']  # Oops

        backend = ComprencBackend(self.passphrase.encode(), ('zlib', 6), plain_backend)
        with pytest.raises(CorruptedObjectError):
            backend.fetch('s3ql_metadata')

        passphrase_new = 'sd982jhd'

        proc = subprocess.Popen(self.s3ql_cmd_argv('s3qladm') +
                                [ '--quiet', '--log', 'none', '--authfile',
                                  '/dev/null', 'recover-key', self.storage_url ],
                                stdin=subprocess.PIPE, universal_newlines=True)

        print(master_key, file=proc.stdin)
        print(passphrase_new, file=proc.stdin)
        print(passphrase_new, file=proc.stdin)
        proc.stdin.close()
        self.assertEqual(proc.wait(), 0)

        backend = ComprencBackend(passphrase_new.encode(), ('zlib', 6), plain_backend)

        backend.fetch('s3ql_passphrase') # will fail with wrong pw
Ejemplo n.º 2
0
Archivo: t4_adm.py Proyecto: mkhon/s3ql
    def test_passphrase(self):
        self.mkfs()

        passphrase_new = 'sd982jhd'

        proc = subprocess.Popen(self.s3ql_cmd_argv('s3qladm') +
                                [ '--quiet', '--fatal-warnings', '--log', 'none', '--authfile',
                                  '/dev/null', 'passphrase', self.storage_url ],
                                stdin=subprocess.PIPE, universal_newlines=True)

        print(self.passphrase, file=proc.stdin)
        print(passphrase_new, file=proc.stdin)
        print(passphrase_new, file=proc.stdin)
        proc.stdin.close()

        self.assertEqual(proc.wait(), 0)

        plain_backend = local.Backend(self.storage_url, None, None)
        backend = ComprencBackend(passphrase_new.encode(), ('zlib', 6), plain_backend)

        backend.fetch('s3ql_passphrase') # will fail with wrong pw
Ejemplo n.º 3
0
    def test_key_recovery(self):
        mkfs_output = self.mkfs()

        hit = re.search(
            r'^---BEGIN MASTER KEY---\n'
            r'(.+)\n'
            r'---END MASTER KEY---$', mkfs_output, re.MULTILINE)
        assert hit
        master_key = hit.group(1)

        plain_backend = local.Backend(Namespace(storage_url=self.storage_url))
        del plain_backend['s3ql_passphrase']  # Oops

        backend = ComprencBackend(self.passphrase.encode(), ('zlib', 6),
                                  plain_backend)
        with pytest.raises(CorruptedObjectError):
            backend.fetch('s3ql_metadata')

        passphrase_new = 'sd982jhd'

        proc = subprocess.Popen(self.s3ql_cmd_argv('s3qladm') + [
            '--quiet', '--log', 'none', '--authfile', '/dev/null',
            'recover-key', self.storage_url
        ],
                                stdin=subprocess.PIPE,
                                universal_newlines=True)

        print(master_key, file=proc.stdin)
        print(passphrase_new, file=proc.stdin)
        print(passphrase_new, file=proc.stdin)
        proc.stdin.close()
        self.assertEqual(proc.wait(), 0)

        backend = ComprencBackend(passphrase_new.encode(), ('zlib', 6),
                                  plain_backend)

        backend.fetch('s3ql_passphrase')  # will fail with wrong pw