Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
K
kedifa
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
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Analytics
Analytics
CI / CD
Repository
Value Stream
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
Jérome Perrin
kedifa
Commits
1f273c26
Commit
1f273c26
authored
Mar 29, 2019
by
Łukasz Nowak
Committed by
Łukasz Nowak
Apr 02, 2019
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
test: Import once
It will make further testing much easier
parent
d48b47a4
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
21 additions
and
16 deletions
+21
-16
kedifa/test.py
kedifa/test.py
+21
-16
No files found.
kedifa/test.py
View file @
1f273c26
...
...
@@ -45,10 +45,8 @@ from cryptography.x509.oid import NameOID
import
caucase.cli
import
caucase.http
from
cli
import
getter
from
cli
import
http
from
cli
import
updater
from
updater
import
Updater
import
cli
import
updater
@
contextlib
.
contextmanager
...
...
@@ -216,7 +214,7 @@ class KedifaMixinCaucase(KedifaMixin):
self
.
pidfile
=
os
.
path
.
join
(
self
.
testdir
,
'kedifa.pid'
)
port
=
'16080'
self
.
kedifa_runtime
=
multiprocessing
.
Process
(
target
=
http
,
target
=
cli
.
http
,
args
=
(
'--ip'
,
ip
,
'--port'
,
port
,
...
...
@@ -288,7 +286,7 @@ class KedifaMixinCaucase(KedifaMixin):
class
KedifaIntegrationTest
(
KedifaMixinCaucase
,
unittest
.
TestCase
):
def
_getter_get
(
self
,
url
,
certificate
,
destination
):
getter
(
cli
.
getter
(
url
,
'--out'
,
destination
,
'--server-ca-certificate'
,
self
.
ca_crt_pem
,
...
...
@@ -311,7 +309,7 @@ class KedifaIntegrationTest(KedifaMixinCaucase, unittest.TestCase):
mapping
.
close
()
state
=
tempfile
.
NamedTemporaryFile
(
dir
=
self
.
testdir
,
delete
=
False
)
state
.
close
()
updater
(
cli
.
updater
(
'--once'
,
'--server-ca-certificate'
,
self
.
ca_crt_pem
,
'--identity'
,
certificate
,
...
...
@@ -1111,44 +1109,51 @@ class KedifaUpdaterMixin(KedifaMixin):
class KedifaUpdaterMappingTest(KedifaUpdaterMixin, unittest.TestCase):
def test_updateMapping_empty(self):
self.setupMapping()
u = Updater(1, self.mapping, self.state, None, None, None, None, True)
u = updater.Updater(1, self.mapping, self.state, None, None, None, None,
True)
u.updateMapping()
self.assertEqual(u.mapping, {})
def test_updateMapping_normal(self):
self.setupMapping('
url
file
')
u = Updater(1, self.mapping, self.state, None, None, None, None, True)
u = updater.Updater(1, self.mapping, self.state, None, None, None, None,
True)
u.updateMapping()
self.assertEqual(u.mapping, {'
file
': ('
url
', None)})
def test_updateMapping_morewhite(self):
self.setupMapping('
url
\
t
file
')
u = Updater(1, self.mapping, self.state, None, None, None, None, True)
u = updater.Updater(1, self.mapping, self.state, None, None, None, None,
True)
u.updateMapping()
self.assertEqual(u.mapping, {'
file
': ('
url
', None)})
def test_updateMapping_one_empty(self):
self.setupMapping('
url
file
\
n
\
n
')
u = Updater(1, self.mapping, self.state, None, None, None, None, True)
u = updater.Updater(1, self.mapping, self.state, None, None, None, None,
True)
u.updateMapping()
self.assertEqual(u.mapping, {'
file
': ('
url
', None)})
def test_updateMapping_one_not_enough(self):
self.setupMapping('
url
file
\
nbuzz
\
n
')
u = Updater(1, self.mapping, self.state, None, None, None, None, True)
u = updater.Updater(1, self.mapping, self.state, None, None, None, None,
True)
u.updateMapping()
self.assertEqual(u.mapping, {'
file
': ('
url
', None)})
def test_updateMapping_with_fallback(self):
self.setupMapping('
url
file
\
nbuzz
oink
fallback
\
n
')
u = Updater(1, self.mapping, self.state, None, None, None, None, True)
u = updater.Updater(1, self.mapping, self.state, None, None, None, None,
True)
u.updateMapping()
self.assertEqual(
u.mapping, {'
file
': ('
url
', None), '
oink
': ('
buzz
', '
fallback
')})
def test_updateMapping_one_comment(self):
self.setupMapping('
url
file
\
n
#buzz uff\n')
u
=
Updater
(
1
,
self
.
mapping
,
self
.
state
,
None
,
None
,
None
,
None
,
True
)
u
=
updater
.
Updater
(
1
,
self
.
mapping
,
self
.
state
,
None
,
None
,
None
,
None
,
True
)
u
.
updateMapping
()
self
.
assertEqual
(
u
.
mapping
,
{
'file'
:
(
'url'
,
None
)})
...
...
@@ -1175,13 +1180,13 @@ class KedifaUpdaterUpdateCertificateTest(
if
fallback_file
:
mapping
=
'%s %s'
%
(
mapping
,
fallback_file
.
name
)
self
.
setupMapping
(
mapping
)
u
=
Updater
(
u
=
updater
.
Updater
(
1
,
self
.
mapping
,
self
.
state
,
'/master/certificate/file'
,
None
,
None
,
None
,
True
)
u
.
updateMapping
()
u
.
readState
()
with
mock
.
patch
.
object
(
Updater
,
'fetchCertificate'
,
return_value
=
fetch
):
updater
.
Updater
,
'fetchCertificate'
,
return_value
=
fetch
):
result
=
u
.
updateCertificate
(
self
.
certificate_file_name
,
master_content
)
u
.
writeState
()
return
open
(
self
.
certificate_file_name
,
'r'
).
read
(),
result
...
...
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