Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
S
slapos.core
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
Léo-Paul Géneau
slapos.core
Commits
8505ee49
Commit
8505ee49
authored
Aug 09, 2011
by
Łukasz Nowak
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Simplify assertions.
parent
7a339758
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
71 additions
and
83 deletions
+71
-83
slapos/tests/slapformat.py
slapos/tests/slapformat.py
+71
-83
No files found.
slapos/tests/slapformat.py
View file @
8505ee49
...
@@ -55,7 +55,7 @@ class FakeCallAndRead:
...
@@ -55,7 +55,7 @@ class FakeCallAndRead:
argument_list
[
3
]
=
'ip/%s'
%
netmask
argument_list
[
3
]
=
'ip/%s'
%
netmask
elif
argument_list
[:
3
]
==
[
'ip'
,
'addr'
,
'list'
]:
elif
argument_list
[:
3
]
==
[
'ip'
,
'addr'
,
'list'
]:
retval
=
0
,
str
(
INTERFACE_DICT
)
retval
=
0
,
str
(
INTERFACE_DICT
)
self
.
external_command_list
.
append
(
argument_list
)
self
.
external_command_list
.
append
(
' '
.
join
(
argument_list
)
)
return
retval
return
retval
class
LoggableWrapper
:
class
LoggableWrapper
:
...
@@ -221,10 +221,10 @@ class TestComputer(SlapformatMixin):
...
@@ -221,10 +221,10 @@ class TestComputer(SlapformatMixin):
"chmod('/software_root', 493)"
],
"chmod('/software_root', 493)"
],
self
.
test_result
.
bucket
)
self
.
test_result
.
bucket
)
self
.
assertEqual
([
self
.
assertEqual
([
[
'ip'
,
'addr'
,
'list'
,
'bridge'
]
,
'ip addr list bridge'
,
[
'groupadd'
,
'slapsoft'
]
,
'groupadd slapsoft'
,
[
'useradd'
,
'-d'
,
'/software_root'
,
'-g'
,
'slapsoft'
,
'-s'
,
'useradd -d /software_root -g slapsoft -s /bin/false slapsoft'
'/bin/false'
,
'slapsoft'
]
],
],
self
.
fakeCallAndRead
.
external_command_list
)
self
.
fakeCallAndRead
.
external_command_list
)
def
test_construct_empty_prepared_no_alter_user
(
self
):
def
test_construct_empty_prepared_no_alter_user
(
self
):
...
@@ -239,7 +239,7 @@ class TestComputer(SlapformatMixin):
...
@@ -239,7 +239,7 @@ class TestComputer(SlapformatMixin):
"chmod('/software_root', 493)"
],
"chmod('/software_root', 493)"
],
self
.
test_result
.
bucket
)
self
.
test_result
.
bucket
)
self
.
assertEqual
([
self
.
assertEqual
([
[
'ip'
,
'addr'
,
'list'
,
'bridge'
]
,],
'ip addr list bridge'
,],
self
.
fakeCallAndRead
.
external_command_list
)
self
.
fakeCallAndRead
.
external_command_list
)
def
test_construct_empty_prepared_no_alter_network
(
self
):
def
test_construct_empty_prepared_no_alter_network
(
self
):
...
@@ -255,10 +255,10 @@ class TestComputer(SlapformatMixin):
...
@@ -255,10 +255,10 @@ class TestComputer(SlapformatMixin):
"chmod('/software_root', 493)"
],
"chmod('/software_root', 493)"
],
self
.
test_result
.
bucket
)
self
.
test_result
.
bucket
)
self
.
assertEqual
([
self
.
assertEqual
([
[
'ip'
,
'addr'
,
'list'
,
'bridge'
]
,
'ip addr list bridge'
,
[
'groupadd'
,
'slapsoft'
]
,
'groupadd slapsoft'
,
[
'useradd'
,
'-d'
,
'/software_root'
,
'-g'
,
'slapsoft'
,
'-s'
,
'useradd -d /software_root -g slapsoft -s /bin/false slapsoft'
'/bin/false'
,
'slapsoft'
]
],
],
self
.
fakeCallAndRead
.
external_command_list
)
self
.
fakeCallAndRead
.
external_command_list
)
def
test_construct_empty_prepared_no_alter_network_user
(
self
):
def
test_construct_empty_prepared_no_alter_network_user
(
self
):
...
@@ -273,7 +273,7 @@ class TestComputer(SlapformatMixin):
...
@@ -273,7 +273,7 @@ class TestComputer(SlapformatMixin):
"chmod('/software_root', 493)"
],
"chmod('/software_root', 493)"
],
self
.
test_result
.
bucket
)
self
.
test_result
.
bucket
)
self
.
assertEqual
([
self
.
assertEqual
([
[
'ip'
,
'addr'
,
'list'
,
'bridge'
]
,
'ip addr list bridge'
,
],
],
self
.
fakeCallAndRead
.
external_command_list
)
self
.
fakeCallAndRead
.
external_command_list
)
...
@@ -305,20 +305,19 @@ class TestComputer(SlapformatMixin):
...
@@ -305,20 +305,19 @@ class TestComputer(SlapformatMixin):
],
],
self
.
test_result
.
bucket
)
self
.
test_result
.
bucket
)
self
.
assertEqual
([
self
.
assertEqual
([
[
'ip'
,
'addr'
,
'list'
,
'bridge'
],
'ip addr list bridge'
,
[
'groupadd'
,
'slapsoft'
],
'groupadd slapsoft'
,
[
'useradd'
,
'-d'
,
'/software_root'
,
'-g'
,
'slapsoft'
,
'-s'
,
'useradd -d /software_root -g slapsoft -s /bin/false slapsoft'
,
'/bin/false'
,
'slapsoft'
],
[
'groupadd'
,
'testuser'
],
'groupadd testuser'
,
[
'useradd'
,
'-d'
,
'/instance_root/partition'
,
'-g'
,
'testuser'
,
'-s'
,
'useradd -d /instance_root/partition -g testuser -s /bin/false -G slapsoft testuser'
,
'/bin/false'
,
'-G'
,
'slapsoft'
,
'testuser'
],
'tunctl -t tap -u testuser'
,
[
'tunctl'
,
'-t'
,
'tap'
,
'-u'
,
'testuser'
],
'ip link set tap up'
,
[
'ip'
,
'link'
,
'set'
,
'tap'
,
'up'
],
'brctl show'
,
[
'brctl'
,
'show'
],
'brctl addif bridge tap'
,
[
'brctl'
,
'addif'
,
'bridge'
,
'tap'
],
'ip addr add ip/255.255.255.255 dev bridge'
,
[
'ip'
,
'addr'
,
'add'
,
'ip/255.255.255.255'
,
'dev'
,
'bridge'
],
'ip addr list bridge'
,
[
'ip'
,
'addr'
,
'list'
,
'bridge'
],
'ip addr add ip/ffff:ffff:ffff:ffff:: dev bridge'
,
[
'ip'
,
'addr'
,
'add'
,
'ip/ffff:ffff:ffff:ffff::'
,
'dev'
,
'bridge'
],
'ip addr list bridge'
,
[
'ip'
,
'addr'
,
'list'
,
'bridge'
],
],
],
self
.
fakeCallAndRead
.
external_command_list
)
self
.
fakeCallAndRead
.
external_command_list
)
...
@@ -348,15 +347,15 @@ class TestComputer(SlapformatMixin):
...
@@ -348,15 +347,15 @@ class TestComputer(SlapformatMixin):
],
],
self
.
test_result
.
bucket
)
self
.
test_result
.
bucket
)
self
.
assertEqual
([
self
.
assertEqual
([
[
'ip'
,
'addr'
,
'list'
,
'bridge'
]
,
'ip addr list bridge'
,
[
'tunctl'
,
'-t'
,
'tap'
,
'-u'
,
'root'
]
,
'tunctl -t tap -u root'
,
[
'ip'
,
'link'
,
'set'
,
'tap'
,
'up'
]
,
'ip link set tap up'
,
[
'brctl'
,
'show'
]
,
'brctl show'
,
[
'brctl'
,
'addif'
,
'bridge'
,
'tap'
]
,
'brctl addif bridge tap'
,
[
'ip'
,
'addr'
,
'add'
,
'ip/255.255.255.255'
,
'dev'
,
'bridge'
]
,
'ip addr add ip/255.255.255.255 dev bridge'
,
[
'ip'
,
'addr'
,
'list'
,
'bridge'
]
,
'ip addr list bridge'
,
[
'ip'
,
'addr'
,
'add'
,
'ip/ffff:ffff:ffff:ffff::'
,
'dev'
,
'bridge'
]
,
'ip addr add ip/ffff:ffff:ffff:ffff:: dev bridge'
,
[
'ip'
,
'addr'
,
'list'
,
'bridge'
]
,
'ip addr list bridge'
,
],
],
self
.
fakeCallAndRead
.
external_command_list
)
self
.
fakeCallAndRead
.
external_command_list
)
...
@@ -388,16 +387,15 @@ class TestComputer(SlapformatMixin):
...
@@ -388,16 +387,15 @@ class TestComputer(SlapformatMixin):
],
],
self
.
test_result
.
bucket
)
self
.
test_result
.
bucket
)
self
.
assertEqual
([
self
.
assertEqual
([
[
'ip'
,
'addr'
,
'list'
,
'bridge'
],
'ip addr list bridge'
,
[
'groupadd'
,
'slapsoft'
],
'groupadd slapsoft'
,
[
'useradd'
,
'-d'
,
'/software_root'
,
'-g'
,
'slapsoft'
,
'-s'
,
'useradd -d /software_root -g slapsoft -s /bin/false slapsoft'
,
'/bin/false'
,
'slapsoft'
],
[
'groupadd'
,
'testuser'
],
'groupadd testuser'
,
[
'useradd'
,
'-d'
,
'/instance_root/partition'
,
'-g'
,
'testuser'
,
'-s'
,
'useradd -d /instance_root/partition -g testuser -s /bin/false -G slapsoft testuser'
,
'/bin/false'
,
'-G'
,
'slapsoft'
,
'testuser'
],
'ip addr add ip/255.255.255.255 dev bridge'
,
[
'ip'
,
'addr'
,
'add'
,
'ip/255.255.255.255'
,
'dev'
,
'bridge'
],
'ip addr list bridge'
,
[
'ip'
,
'addr'
,
'list'
,
'bridge'
],
'ip addr add ip/ffff:ffff:ffff:ffff:: dev bridge'
,
[
'ip'
,
'addr'
,
'add'
,
'ip/ffff:ffff:ffff:ffff::'
,
'dev'
,
'bridge'
],
'ip addr list bridge'
,
[
'ip'
,
'addr'
,
'list'
,
'bridge'
],
],
],
self
.
fakeCallAndRead
.
external_command_list
)
self
.
fakeCallAndRead
.
external_command_list
)
...
@@ -427,11 +425,11 @@ class TestComputer(SlapformatMixin):
...
@@ -427,11 +425,11 @@ class TestComputer(SlapformatMixin):
],
],
self
.
test_result
.
bucket
)
self
.
test_result
.
bucket
)
self
.
assertEqual
([
self
.
assertEqual
([
[
'ip'
,
'addr'
,
'list'
,
'bridge'
]
,
'ip addr list bridge'
,
[
'ip'
,
'addr'
,
'add'
,
'ip/255.255.255.255'
,
'dev'
,
'bridge'
]
,
'ip addr add ip/255.255.255.255 dev bridge'
,
[
'ip'
,
'addr'
,
'list'
,
'bridge'
]
,
'ip addr list bridge'
,
[
'ip'
,
'addr'
,
'add'
,
'ip/ffff:ffff:ffff:ffff::'
,
'dev'
,
'bridge'
]
,
'ip addr add ip/ffff:ffff:ffff:ffff:: dev bridge'
,
[
'ip'
,
'addr'
,
'list'
,
'bridge'
]
,
'ip addr list bridge'
,
],
],
self
.
fakeCallAndRead
.
external_command_list
)
self
.
fakeCallAndRead
.
external_command_list
)
...
@@ -466,12 +464,11 @@ class TestUser(SlapformatMixin):
...
@@ -466,12 +464,11 @@ class TestUser(SlapformatMixin):
user
.
setPath
(
'/doesnotexistsyet'
)
user
.
setPath
(
'/doesnotexistsyet'
)
user
.
create
()
user
.
create
()
self
.
assertEqual
(
self
.
assertEqual
([
[
'groupadd doesnotexistsyet'
,
[
'groupadd'
,
'doesnotexistsyet'
],
'useradd -d /doesnotexistsyet -g doesnotexistsyet -s /bin/false '
\
[
'useradd'
,
'-d'
,
'/doesnotexistsyet'
,
'-g'
,
'doesnotexistsyet'
,
'-s'
,
'doesnotexistsyet'
'/bin/false'
,
'doesnotexistsyet'
]
],
],
self
.
fakeCallAndRead
.
external_command_list
)
self
.
fakeCallAndRead
.
external_command_list
)
def
test_create_additional_groups
(
self
):
def
test_create_additional_groups
(
self
):
...
@@ -480,12 +477,10 @@ class TestUser(SlapformatMixin):
...
@@ -480,12 +477,10 @@ class TestUser(SlapformatMixin):
user
.
setPath
(
'/doesnotexistsyet'
)
user
.
setPath
(
'/doesnotexistsyet'
)
user
.
create
()
user
.
create
()
self
.
assertEqual
(
self
.
assertEqual
([
[
'groupadd doesnotexistsyet'
,
[
'groupadd'
,
'doesnotexistsyet'
],
'useradd -d /doesnotexistsyet -g doesnotexistsyet -s /bin/false -G '
\
[
'useradd'
,
'-d'
,
'/doesnotexistsyet'
,
'-g'
,
'doesnotexistsyet'
,
'-s'
,
'additionalgroup1,additionalgroup2 doesnotexistsyet'
'/bin/false'
,
'-G'
,
'additionalgroup1,additionalgroup2'
,
'doesnotexistsyet'
]
],
],
self
.
fakeCallAndRead
.
external_command_list
)
self
.
fakeCallAndRead
.
external_command_list
)
...
@@ -496,11 +491,9 @@ class TestUser(SlapformatMixin):
...
@@ -496,11 +491,9 @@ class TestUser(SlapformatMixin):
user
.
setPath
(
'/testuser'
)
user
.
setPath
(
'/testuser'
)
user
.
create
()
user
.
create
()
self
.
assertEqual
(
self
.
assertEqual
([
[
'useradd -d /testuser -g testuser -s /bin/false testuser'
[
'useradd'
,
'-d'
,
'/testuser'
,
'-g'
,
'testuser'
,
'-s'
,
'/bin/false'
,
],
'testuser'
]
],
self
.
fakeCallAndRead
.
external_command_list
)
self
.
fakeCallAndRead
.
external_command_list
)
def
test_create_user_exists_additional_groups
(
self
):
def
test_create_user_exists_additional_groups
(
self
):
...
@@ -511,12 +504,11 @@ class TestUser(SlapformatMixin):
...
@@ -511,12 +504,11 @@ class TestUser(SlapformatMixin):
user
.
setPath
(
'/testuser'
)
user
.
setPath
(
'/testuser'
)
user
.
create
()
user
.
create
()
self
.
assertEqual
(
self
.
assertEqual
([
[
'groupadd testuser'
,
[
'groupadd'
,
'testuser'
],
'usermod -d /testuser -g testuser -s /bin/false -G '
\
[
'usermod'
,
'-d'
,
'/testuser'
,
'-g'
,
'testuser'
,
'-s'
,
'/bin/false'
,
'additionalgroup1,additionalgroup2 testuser'
'-G'
,
'additionalgroup1,additionalgroup2'
,
'testuser'
]
],
],
self
.
fakeCallAndRead
.
external_command_list
)
self
.
fakeCallAndRead
.
external_command_list
)
def
test_create_user_exists
(
self
):
def
test_create_user_exists
(
self
):
...
@@ -526,12 +518,10 @@ class TestUser(SlapformatMixin):
...
@@ -526,12 +518,10 @@ class TestUser(SlapformatMixin):
user
.
setPath
(
'/testuser'
)
user
.
setPath
(
'/testuser'
)
user
.
create
()
user
.
create
()
self
.
assertEqual
(
self
.
assertEqual
([
[
'groupadd testuser'
,
[
'groupadd'
,
'testuser'
],
'usermod -d /testuser -g testuser -s /bin/false testuser'
[
'usermod'
,
'-d'
,
'/testuser'
,
'-g'
,
'testuser'
,
'-s'
,
'/bin/false'
,
],
'testuser'
]
],
self
.
fakeCallAndRead
.
external_command_list
)
self
.
fakeCallAndRead
.
external_command_list
)
def
test_create_user_group_exists
(
self
):
def
test_create_user_group_exists
(
self
):
...
@@ -543,11 +533,9 @@ class TestUser(SlapformatMixin):
...
@@ -543,11 +533,9 @@ class TestUser(SlapformatMixin):
user
.
setPath
(
'/testuser'
)
user
.
setPath
(
'/testuser'
)
user
.
create
()
user
.
create
()
self
.
assertEqual
(
self
.
assertEqual
([
[
'usermod -d /testuser -g testuser -s /bin/false testuser'
[
'usermod'
,
'-d'
,
'/testuser'
,
'-g'
,
'testuser'
,
'-s'
,
'/bin/false'
,
],
'testuser'
]
],
self
.
fakeCallAndRead
.
external_command_list
)
self
.
fakeCallAndRead
.
external_command_list
)
def
test_isAvailable
(
self
):
def
test_isAvailable
(
self
):
...
...
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