Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
C
cam
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Build
Pipelines
Jobs
Pipeline schedules
Artifacts
Deploy
Releases
Model registry
Operate
Environments
Monitor
Incidents
Service Desk
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
This is an archived project. Repository and other project resources are read-only.
Show more breadcrumbs
ai
cam
Commits
a3143f42
Commit
a3143f42
authored
13 years ago
by
ale
Browse files
Options
Downloads
Patches
Plain Diff
add a full integration test via main()
parent
1c063489
Branches
Branches containing commit
Tags
Tags containing commit
No related merge requests found
Changes
1
Show whitespace changes
Inline
Side-by-side
Showing
1 changed file
cam/tests/test_main.py
+61
-0
61 additions, 0 deletions
cam/tests/test_main.py
with
61 additions
and
0 deletions
cam/tests/test_main.py
0 → 100644
+
61
−
0
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
)
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment