Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
S
slapos.libnetworkcache
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Issues
0
Issues
0
List
Boards
Labels
Milestones
Merge Requests
0
Merge Requests
0
Analytics
Analytics
Repository
Value Stream
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Commits
Issue Boards
Open sidebar
Ophélie Gagnard
slapos.libnetworkcache
Commits
c6f62c94
Commit
c6f62c94
authored
Jul 20, 2011
by
Lucas Carvalho
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Added tests to signature.py.
parent
a4eed283
Changes
1
Show whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
66 additions
and
1 deletion
+66
-1
slapos/libnetworkcachetests.py
slapos/libnetworkcachetests.py
+66
-1
No files found.
slapos/libnetworkcachetests.py
View file @
c6f62c94
import
unittest
from
slapos.libnetworkcache
import
NetworkcacheClient
import
tempfile
import
os
from
slapos.libnetworkcache
import
NetworkcacheClient
from
slapos.signature
import
parseArgument
,
\
createPrivateKeyAndCertificateFile
class
OfflineTest
(
unittest
.
TestCase
):
def
test_download_offline
(
self
):
...
...
@@ -11,3 +14,65 @@ class OfflineTest(unittest.TestCase):
content
=
tempfile
.
TemporaryFile
()
nc
=
NetworkcacheClient
(
'http://127.0.0.1:0'
,
'http://127.0.0.1:0'
)
self
.
assertRaises
(
IOError
,
nc
.
upload
,
content
)
class
GenerateSignatureScriptTest
(
unittest
.
TestCase
):
''' Class which must test the signature.py script. '''
def
setUp
(
self
):
''' Setup the test. '''
self
.
pub_file_descriptor
=
tempfile
.
NamedTemporaryFile
()
self
.
priv_file_descritor
=
tempfile
.
NamedTemporaryFile
()
self
.
signature_certificate_file
=
self
.
pub_file_descriptor
.
name
self
.
signature_private_key_file
=
self
.
priv_file_descritor
.
name
self
.
arg_list
=
(
'--signature-public-file'
,
self
.
signature_certificate_file
,
'--signature-private-file'
,
self
.
signature_private_key_file
,
'--country'
,
'BR, aze, AEAZE, ZEAZE'
,
'--state-name'
,
'Campos'
,
'--locality-name'
,
'Rio de Janeiro'
,
'--organization-name'
,
'Nexedi'
,
'--organization-unit-name'
,
'Dev'
,
'--common-name'
,
'R500.com'
,
'--email'
,
'test@example.com'
)
def
tearDown
(
self
):
''' Remove the files which have been created during the test. '''
self
.
priv_file_descritor
.
close
()
self
.
pub_file_descriptor
.
close
()
def
test_parse_argument_with_empty_list
(
self
):
'''
If the argument list is empty, then the parseArgument method should
return a dictionary with default argument values.
'''
default_dict
=
{
'organization_name'
:
'Default Company Ltd'
,
'state_name'
:
'Default Province'
,
'organization_unit_name'
:
''
,
'common_name'
:
''
,
'country'
:
'XX'
,
'locality_name'
:
'Default City'
,
'signature_private_key_file'
:
'private.pem'
,
'signature_certificate_file'
:
'public.pem'
,
'email'
:
''
}
self
.
assertEquals
(
default_dict
,
parseArgument
())
def
test_parse_argument
(
self
):
'''
Check if the argument is properly set.
'''
option_dict
=
parseArgument
(
*
self
.
arg_list
)
self
.
assertEquals
(
len
(
self
.
arg_list
)
/
2
,
len
(
option_dict
))
for
value
in
option_dict
.
values
():
self
.
assertTrue
(
value
in
self
.
arg_list
,
'%s is not in %s.'
%
(
value
,
self
.
arg_list
))
def
test_key_and_certificate_file_creation
(
self
):
'''
Check if key file and the certificate file are being created correctly.
'''
option_dict
=
parseArgument
(
*
self
.
arg_list
)
cert_as_text
=
createPrivateKeyAndCertificateFile
(
**
option_dict
)
self
.
assertTrue
(
os
.
path
.
exists
(
self
.
signature_certificate_file
))
self
.
assertTrue
(
os
.
path
.
exists
(
self
.
signature_private_key_file
))
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