5171.3.7
by Martin von Gagern
Added blackbox tests for --directory option. |
1 |
# Copyright (C) 2005-2010 Canonical Ltd
|
1185.78.1
by John Arbash Meinel
Updating bzr re-sign to allow multiple arguments, and updating tests |
2 |
# -*- coding: utf-8 -*-
|
1887.1.1
by Adeodato Simó
Do not separate paragraphs in the copyright statement with blank lines, |
3 |
#
|
1185.78.1
by John Arbash Meinel
Updating bzr re-sign to allow multiple arguments, and updating tests |
4 |
# This program is free software; you can redistribute it and/or modify
|
5 |
# it under the terms of the GNU General Public License as published by
|
|
6 |
# the Free Software Foundation; either version 2 of the License, or
|
|
7 |
# (at your option) any later version.
|
|
1887.1.1
by Adeodato Simó
Do not separate paragraphs in the copyright statement with blank lines, |
8 |
#
|
1185.78.1
by John Arbash Meinel
Updating bzr re-sign to allow multiple arguments, and updating tests |
9 |
# This program is distributed in the hope that it will be useful,
|
10 |
# but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
11 |
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
12 |
# GNU General Public License for more details.
|
|
1887.1.1
by Adeodato Simó
Do not separate paragraphs in the copyright statement with blank lines, |
13 |
#
|
1185.78.1
by John Arbash Meinel
Updating bzr re-sign to allow multiple arguments, and updating tests |
14 |
# You should have received a copy of the GNU General Public License
|
15 |
# along with this program; if not, write to the Free Software
|
|
4183.7.1
by Sabin Iacob
update FSF mailing address |
16 |
# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
|
1185.78.1
by John Arbash Meinel
Updating bzr re-sign to allow multiple arguments, and updating tests |
17 |
|
18 |
||
1185.78.5
by John Arbash Meinel
Fix doc bug |
19 |
"""Black-box tests for bzr re-sign.
|
1185.78.1
by John Arbash Meinel
Updating bzr re-sign to allow multiple arguments, and updating tests |
20 |
"""
|
21 |
||
4985.1.5
by Vincent Ladeuil
Deploying the new overrideAttr facility further reduces the complexity |
22 |
from bzrlib import ( |
23 |
gpg, |
|
24 |
tests, |
|
25 |
)
|
|
6472.2.2
by Jelmer Vernooij
Use controldir rather than bzrdir in a couple more places. |
26 |
from bzrlib.controldir import ControlDir |
1185.78.1
by John Arbash Meinel
Updating bzr re-sign to allow multiple arguments, and updating tests |
27 |
from bzrlib.testament import Testament |
4985.1.5
by Vincent Ladeuil
Deploying the new overrideAttr facility further reduces the complexity |
28 |
|
29 |
||
30 |
class ReSign(tests.TestCaseInTempDir): |
|
1185.78.1
by John Arbash Meinel
Updating bzr re-sign to allow multiple arguments, and updating tests |
31 |
|
32 |
def monkey_patch_gpg(self): |
|
33 |
"""Monkey patch the gpg signing strategy to be a loopback.
|
|
34 |
||
35 |
This also registers the cleanup, so that we will revert to
|
|
36 |
the original gpg strategy when done.
|
|
37 |
"""
|
|
38 |
# monkey patch gpg signing mechanism
|
|
4985.1.5
by Vincent Ladeuil
Deploying the new overrideAttr facility further reduces the complexity |
39 |
self.overrideAttr(gpg, 'GPGStrategy', gpg.LoopbackGPGStrategy) |
1185.78.1
by John Arbash Meinel
Updating bzr re-sign to allow multiple arguments, and updating tests |
40 |
|
41 |
def setup_tree(self): |
|
6472.2.2
by Jelmer Vernooij
Use controldir rather than bzrdir in a couple more places. |
42 |
wt = ControlDir.create_standalone_workingtree('.') |
1185.78.1
by John Arbash Meinel
Updating bzr re-sign to allow multiple arguments, and updating tests |
43 |
wt.commit("base A", allow_pointless=True, rev_id='A') |
44 |
wt.commit("base B", allow_pointless=True, rev_id='B') |
|
45 |
wt.commit("base C", allow_pointless=True, rev_id='C') |
|
46 |
||
47 |
return wt |
|
48 |
||
1563.2.31
by Robert Collins
Convert Knit repositories to use knits. |
49 |
def assertEqualSignature(self, repo, revision_id): |
50 |
"""Assert a signature is stored correctly in repository."""
|
|
51 |
self.assertEqual( |
|
1551.12.36
by Aaron Bentley
Fix failing tests |
52 |
'-----BEGIN PSEUDO-SIGNED CONTENT-----\n' + |
53 |
Testament.from_revision(repo, revision_id).as_short_text() + |
|
1551.12.52
by Aaron Bentley
speling fix |
54 |
'-----END PSEUDO-SIGNED CONTENT-----\n', |
1563.2.31
by Robert Collins
Convert Knit repositories to use knits. |
55 |
repo.get_signature_text(revision_id)) |
56 |
||
1185.78.1
by John Arbash Meinel
Updating bzr re-sign to allow multiple arguments, and updating tests |
57 |
def test_resign(self): |
58 |
#Test re signing of data.
|
|
59 |
wt = self.setup_tree() |
|
60 |
repo = wt.branch.repository |
|
61 |
||
62 |
self.monkey_patch_gpg() |
|
2552.2.3
by Vincent Ladeuil
Deprecate the varargs syntax and fix the tests. |
63 |
self.run_bzr('re-sign -r revid:A') |
1185.78.1
by John Arbash Meinel
Updating bzr re-sign to allow multiple arguments, and updating tests |
64 |
|
1563.2.31
by Robert Collins
Convert Knit repositories to use knits. |
65 |
self.assertEqualSignature(repo, 'A') |
1185.78.1
by John Arbash Meinel
Updating bzr re-sign to allow multiple arguments, and updating tests |
66 |
|
2552.2.3
by Vincent Ladeuil
Deprecate the varargs syntax and fix the tests. |
67 |
self.run_bzr('re-sign B') |
1563.2.31
by Robert Collins
Convert Knit repositories to use knits. |
68 |
self.assertEqualSignature(repo, 'B') |
3943.8.1
by Marius Kruger
remove all trailing whitespace from bzr source |
69 |
|
1185.78.1
by John Arbash Meinel
Updating bzr re-sign to allow multiple arguments, and updating tests |
70 |
def test_resign_range(self): |
71 |
wt = self.setup_tree() |
|
72 |
repo = wt.branch.repository |
|
73 |
||
74 |
self.monkey_patch_gpg() |
|
2552.2.3
by Vincent Ladeuil
Deprecate the varargs syntax and fix the tests. |
75 |
self.run_bzr('re-sign -r 1..') |
1563.2.31
by Robert Collins
Convert Knit repositories to use knits. |
76 |
self.assertEqualSignature(repo, 'A') |
77 |
self.assertEqualSignature(repo, 'B') |
|
78 |
self.assertEqualSignature(repo, 'C') |
|
1185.78.1
by John Arbash Meinel
Updating bzr re-sign to allow multiple arguments, and updating tests |
79 |
|
80 |
def test_resign_multiple(self): |
|
81 |
wt = self.setup_tree() |
|
82 |
repo = wt.branch.repository |
|
83 |
||
84 |
self.monkey_patch_gpg() |
|
2552.2.3
by Vincent Ladeuil
Deprecate the varargs syntax and fix the tests. |
85 |
self.run_bzr('re-sign A B C') |
1563.2.31
by Robert Collins
Convert Knit repositories to use knits. |
86 |
self.assertEqualSignature(repo, 'A') |
87 |
self.assertEqualSignature(repo, 'B') |
|
88 |
self.assertEqualSignature(repo, 'C') |
|
5171.3.7
by Martin von Gagern
Added blackbox tests for --directory option. |
89 |
|
90 |
def test_resign_directory(self): |
|
91 |
"""Test --directory option"""
|
|
6472.2.2
by Jelmer Vernooij
Use controldir rather than bzrdir in a couple more places. |
92 |
wt = ControlDir.create_standalone_workingtree('a') |
5171.3.7
by Martin von Gagern
Added blackbox tests for --directory option. |
93 |
wt.commit("base A", allow_pointless=True, rev_id='A') |
94 |
wt.commit("base B", allow_pointless=True, rev_id='B') |
|
95 |
wt.commit("base C", allow_pointless=True, rev_id='C') |
|
96 |
repo = wt.branch.repository |
|
97 |
self.monkey_patch_gpg() |
|
98 |
self.run_bzr('re-sign --directory=a -r revid:A') |
|
99 |
self.assertEqualSignature(repo, 'A') |
|
100 |
self.run_bzr('re-sign -d a B') |
|
101 |
self.assertEqualSignature(repo, 'B') |