1
1
# -*- Mode:Python; indent-tabs-mode:nil; tab-width:4 -*-
3
# Copyright 2002 Ben Escoto <ben@emerose.org>
4
# Copyright 2007 Kenneth Loafman <kenneth@loafman.com>
6
# This file is part of duplicity.
8
# Duplicity is free software; you can redistribute it and/or modify it
9
# under the terms of the GNU General Public License as published by the
10
# Free Software Foundation; either version 2 of the License, or (at your
11
# option) any later version.
13
# Duplicity is distributed in the hope that it will be useful, but
14
# WITHOUT ANY WARRANTY; without even the implied warranty of
15
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
16
# General Public License for more details.
18
# You should have received a copy of the GNU General Public License
19
# along with duplicity; if not, write to the Free Software Foundation,
20
# Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
4
import sys, os, unittest, cStringIO, random
23
import sys, os, unittest, random
5
24
sys.path.insert(0, "../")
6
from duplicity import gpg, path
26
from duplicity import gpg
27
from duplicity import path
12
33
class GPGTest(unittest.TestCase):
36
assert not os.system("tar xzf testfiles.tar.gz > /dev/null 2>&1")
39
assert not os.system("rm -rf testfiles tempdir temp2.tar")
15
42
"""Delete testfiles/output and recreate"""
16
43
assert not os.system("rm -rf testfiles/output")
88
115
gwfh = GPGWriteFile_Helper()
89
116
profile = gpg.GPGProfile(passphrase = "foobar")
117
for i in range(10): #@UnusedVariable
91
118
gpg.GPGWriteFile(gwfh, "testfiles/output/gpgwrite.gpg",
92
119
profile, size = size)
93
120
#print os.stat("testfiles/output/gpgwrite.gpg").st_size-size
103
130
size = 400 * 1000
104
131
gwfh = GPGWriteFile_Helper()
132
for i in range(10): #@UnusedVariable
106
133
gpg.GzipWriteFile(gwfh, "testfiles/output/gzwrite.gz",
108
135
#print os.stat("testfiles/output/gzwrite.gz").st_size-size
110
137
gwfh.set_at_end()
111
138
gpg.GzipWriteFile(gwfh, "testfiles/output/gzwrite.gpg", size = size)
112
139
#print os.stat("testfiles/output/gzwrite.gz").st_size
115
142
class GPGWriteHelper2:
116
143
def __init__(self, data): self.data = data
145
172
class SHATest(unittest.TestCase):
146
173
"""Test making sha signatures"""
175
assert not os.system("tar xzf testfiles.tar.gz > /dev/null 2>&1")
178
assert not os.system("rm -rf testfiles tempdir temp2.tar")
147
180
def test_sha(self):
148
181
hash = gpg.get_hash("SHA1", path.Path("testfiles/various_file_types/regular_file"))
149
182
assert hash == "886d722999862724e1e62d0ac51c468ee336ef8e", hash