1
1
import os
2
+ import sys
2
3
import pytest
3
4
4
5
from ansible_sign .cli import main
5
6
6
7
__author__ = "Rick Elrod"
7
8
__copyright__ = "(c) 2022 Red Hat, Inc."
8
9
__license__ = "MIT"
10
+ IS_GITHUB_ACTION_MACOS = sys .platform == "darwin" and os .environ .get ("CI" , "false" ) == "true"
9
11
10
12
11
13
@pytest .mark .parametrize (
12
14
"args, exp_stdout_substr, exp_stderr_substr, exp_rc" ,
13
15
[
14
16
(
15
17
[
18
+ "--debug" ,
19
+ "--nocolor" ,
16
20
"project" ,
17
21
"gpg-sign" ,
18
22
"tests/fixtures/checksum/missing-manifest" ,
23
27
),
24
28
(
25
29
[
30
+ "--debug" ,
31
+ "--nocolor" ,
26
32
"project" ,
27
33
"gpg-sign" ,
28
34
"tests/fixtures/checksum/manifest-syntax-error" ,
33
39
),
34
40
(
35
41
[
42
+ "--debug" ,
43
+ "--nocolor" ,
36
44
"project" ,
37
45
"gpg-verify" ,
38
46
"tests/fixtures/checksum/manifest-success" ,
43
51
),
44
52
(
45
53
[
54
+ "--debug" ,
55
+ "--nocolor" ,
46
56
"project" ,
47
57
"gpg-verify" ,
48
58
"--gnupg-home=/dir/that/does/not/exist/321" ,
@@ -75,6 +85,8 @@ def test_main(capsys, args, exp_stdout_substr, exp_stderr_substr, exp_rc):
75
85
[
76
86
(
77
87
[
88
+ "--debug" ,
89
+ "--nocolor" ,
78
90
"project" ,
79
91
"gpg-verify" ,
80
92
"--keyring={gpghome}/pubring.kbx" ,
@@ -86,6 +98,8 @@ def test_main(capsys, args, exp_stdout_substr, exp_stderr_substr, exp_rc):
86
98
),
87
99
(
88
100
[
101
+ "--debug" ,
102
+ "--nocolor" ,
89
103
"project" ,
90
104
"gpg-verify" ,
91
105
"--gnupg-home={gpghome}" ,
@@ -97,6 +111,8 @@ def test_main(capsys, args, exp_stdout_substr, exp_stderr_substr, exp_rc):
97
111
),
98
112
(
99
113
[
114
+ "--debug" ,
115
+ "--nocolor" ,
100
116
"project" ,
101
117
"gpg-verify" ,
102
118
"--gnupg-home={gpghome}" ,
@@ -129,20 +145,40 @@ def test_main_with_pubkey_in_keyring(capsys, gpg_home_with_hao_pubkey, args, exp
129
145
@pytest .mark .parametrize (
130
146
"project_fixture, exp_stdout_substr, exp_stderr_substr, exp_rc" ,
131
147
[
132
- ("signed_project_and_gpg" , "GPG signature verification succeeded" , "" , 0 ),
133
- ("signed_project_broken_manifest" , "Invalid line encountered in checksum manifest" , "" , 1 ),
134
- ("signed_project_missing_manifest" , "Checksum manifest file does not exist:" , "" , 1 ),
135
- ("signed_project_modified_manifest" , "Checksum validation failed." , "" , 2 ),
136
- ("signed_project_with_different_gpg_home" , "Re-run with the global --debug flag" , "" , 3 ),
137
- ("signed_project_broken_manifest_in" , "An error was encountered while parsing MANIFEST.in: unknown action 'invalid-directive'" , "" , 1 ),
138
- ],
139
- ids = [
140
- "valid checksum file and signature" ,
141
- "valid signature but broken checksum file" ,
142
- "missing checksum file entirely" ,
143
- "checksum file with wrong hashes" ,
144
- "matching pubkey does not exist in gpg home" ,
145
- "broken MANIFEST.in after signing" ,
148
+ pytest .param (
149
+ "signed_project_and_gpg" ,
150
+ "GPG signature verification succeeded" ,
151
+ "" ,
152
+ 0 ,
153
+ id = "valid checksum file and signature" ,
154
+ marks = pytest .mark .xfail (IS_GITHUB_ACTION_MACOS , reason = "https://github.com/ansible/ansible-sign/issues/51" ),
155
+ ),
156
+ pytest .param (
157
+ "signed_project_broken_manifest" ,
158
+ "Invalid line encountered in checksum manifest" ,
159
+ "" ,
160
+ 1 ,
161
+ id = "valid signature but broken checksum file" ,
162
+ marks = pytest .mark .xfail (IS_GITHUB_ACTION_MACOS , reason = "https://github.com/ansible/ansible-sign/issues/51" ),
163
+ ),
164
+ pytest .param ("signed_project_missing_manifest" , "Checksum manifest file does not exist:" , "" , 1 , id = "missing checksum file entirely" ),
165
+ pytest .param (
166
+ "signed_project_modified_manifest" ,
167
+ "Checksum validation failed." ,
168
+ "" ,
169
+ 2 ,
170
+ id = "checksum file with wrong hashes" ,
171
+ marks = pytest .mark .xfail (IS_GITHUB_ACTION_MACOS , reason = "https://github.com/ansible/ansible-sign/issues/51" ),
172
+ ),
173
+ pytest .param ("signed_project_with_different_gpg_home" , "Re-run with the global --debug flag" , "" , 3 , id = "matching pubkey does not exist in gpg home" ),
174
+ pytest .param (
175
+ "signed_project_broken_manifest_in" ,
176
+ "An error was encountered while parsing MANIFEST.in: unknown action 'invalid-directive'" ,
177
+ "" ,
178
+ 1 ,
179
+ id = "broken MANIFEST.in after signing" ,
180
+ marks = pytest .mark .xfail (IS_GITHUB_ACTION_MACOS , reason = "https://github.com/ansible/ansible-sign/issues/51" ),
181
+ ),
146
182
],
147
183
)
148
184
def test_gpg_verify_manifest_scenario (capsys , request , project_fixture , exp_stdout_substr , exp_stderr_substr , exp_rc ):
@@ -153,6 +189,8 @@ def test_gpg_verify_manifest_scenario(capsys, request, project_fixture, exp_stdo
153
189
(project_root , gpg_home ) = request .getfixturevalue (project_fixture )
154
190
keyring = os .path .join (gpg_home , "pubring.kbx" )
155
191
args = [
192
+ "--debug" ,
193
+ "--nocolor" ,
156
194
"project" ,
157
195
"gpg-verify" ,
158
196
f"--keyring={ keyring } " ,
0 commit comments