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
9a961f60
Commit
9a961f60
authored
Oct 07, 2014
by
godog
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
add ca.verify tests
parent
d439174a
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
34 additions
and
6 deletions
+34
-6
cam/tests/test_ca.py
cam/tests/test_ca.py
+34
-6
No files found.
cam/tests/test_ca.py
View file @
9a961f60
...
...
@@ -29,18 +29,27 @@ class CertStub(object):
return
os
.
path
.
exists
(
self
.
public_key_file
)
class
CAStub
(
object
):
def
__init__
(
self
,
*
args
,
**
kwargs
):
self
.
tmpdir
=
tempfile
.
mkdtemp
()
self
.
ca
=
ca
.
CA
(
self
.
tmpdir
,
*
args
,
**
kwargs
)
def
destroy
(
self
):
self
.
ca
.
close
()
shutil
.
rmtree
(
self
.
tmpdir
)
class
CATest
(
unittest
.
TestCase
):
def
setUp
(
self
):
self
.
tmpdir
=
tempfile
.
mkdtemp
()
self
.
ca
=
ca
.
CA
(
self
.
tmpdir
,
{
'cn'
:
'test ca'
,
'org'
:
'test'
,
self
.
ca_stub
=
CAStub
({
'cn'
:
'test ca'
,
'org'
:
'test'
,
'bits'
:
'1024'
,
'email'
:
'test@test.com'
},
password
=
'testpw'
)
password
=
'testpw'
)
self
.
ca
=
self
.
ca_stub
.
ca
self
.
tmpdir
=
self
.
ca_stub
.
tmpdir
def
tearDown
(
self
):
self
.
ca
.
close
()
shutil
.
rmtree
(
self
.
tmpdir
)
self
.
ca_stub
.
destroy
()
def
test_create
(
self
):
self
.
ca
.
create
()
...
...
@@ -70,3 +79,22 @@ class CATest(unittest.TestCase):
self
.
ca
.
generate
(
cert
)
self
.
ca
.
revoke
(
cert
)
self
.
assertTrue
(
os
.
path
.
exists
(
os
.
path
.
join
(
self
.
tmpdir
,
'public/ca.crl'
)))
def
test_verify
(
self
):
orig_cert
=
CertStub
(
'test'
,
'www.test.com'
,
self
.
tmpdir
)
self
.
ca
.
create
()
self
.
ca
.
generate
(
orig_cert
)
alt_ca
=
CAStub
({
'cn'
:
'test ca'
,
'org'
:
'test'
,
'bits'
:
'1024'
,
'email'
:
'test@test.com'
},
password
=
'testpw'
)
alt_ca
.
ca
.
create
()
alt_cert
=
CertStub
(
'test'
,
'www.test.com'
,
alt_ca
.
tmpdir
)
alt_ca
.
ca
.
generate
(
alt_cert
)
self
.
assertTrue
(
self
.
ca
.
verify
(
orig_cert
.
public_key_file
))
self
.
assertTrue
(
alt_ca
.
ca
.
verify
(
alt_cert
.
public_key_file
))
self
.
assertFalse
(
self
.
ca
.
verify
(
alt_cert
.
public_key_file
))
self
.
assertFalse
(
alt_ca
.
ca
.
verify
(
orig_cert
.
public_key_file
))
alt_ca
.
destroy
()
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