Skip to content
GitLab
Projects
Groups
Snippets
Help
Loading...
Help
What's new
10
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
Open sidebar
ai
cam
Commits
a3143f42
Commit
a3143f42
authored
Feb 08, 2012
by
ale
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
add a full integration test via main()
parent
1c063489
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
61 additions
and
0 deletions
+61
-0
cam/tests/test_main.py
cam/tests/test_main.py
+61
-0
No files found.
cam/tests/test_main.py
0 → 100644
View file @
a3143f42
import
getpass
import
os
import
shutil
import
subprocess
import
sys
import
tempfile
import
unittest
from
cam
import
main
class
MainTest
(
unittest
.
TestCase
):
def
setUp
(
self
):
self
.
tmpdir
=
tempfile
.
mkdtemp
()
self
.
cfgfile
=
os
.
path
.
join
(
self
.
tmpdir
,
'test.conf'
)
with
open
(
self
.
cfgfile
,
'w'
)
as
fd
:
fd
.
write
(
"""
[ca]
cn = Test Ca
org = Test
country = IE
email = ca@test.org
bits = 1024
[web]
cn = www.test.org
"""
)
def
_fake_getpass
(
prompt
):
return
'testpass'
getpass
.
getpass
=
_fake_getpass
def
tearDown
(
self
):
shutil
.
rmtree
(
self
.
tmpdir
)
def
_run
(
self
,
*
args
):
sys
.
argv
=
[
'cam'
,
'--config=%s'
%
self
.
cfgfile
]
+
list
(
args
)
try
:
return
main
.
main
()
except
SystemExit
,
e
:
return
e
.
code
def
test_init_and_sanity_check
(
self
):
self
.
assertEquals
(
None
,
self
.
_run
(
'init'
))
self
.
assertEquals
(
None
,
self
.
_run
(
'gen'
,
'web'
))
ca_file
=
os
.
path
.
join
(
self
.
tmpdir
,
'public/ca.pem'
)
crt_file
=
os
.
path
.
join
(
self
.
tmpdir
,
'public/certs/web.pem'
)
self
.
assertTrue
(
os
.
path
.
exists
(
ca_file
))
self
.
assertTrue
(
os
.
path
.
exists
(
crt_file
))
pipe
=
subprocess
.
Popen
(
[
'openssl'
,
'verify'
,
'-CAfile'
,
ca_file
,
'-verbose'
,
crt_file
],
stdout
=
subprocess
.
PIPE
,
stderr
=
subprocess
.
STDOUT
)
output
=
pipe
.
communicate
()[
0
]
result
=
pipe
.
returncode
self
.
assertEquals
(
0
,
result
)
print
output
self
.
assertTrue
(
'error '
not
in
output
)
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
.
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment