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
Hardik Juneja
slapos.core
Commits
3b6cead7
Commit
3b6cead7
authored
Aug 08, 2011
by
Łukasz Nowak
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Rename variable.
parent
196b6d83
Changes
1
Show whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
27 additions
and
27 deletions
+27
-27
slapos/tests/slapformat.py
slapos/tests/slapformat.py
+27
-27
No files found.
slapos/tests/slapformat.py
View file @
3b6cead7
...
...
@@ -8,7 +8,7 @@ import os
import
pwd
USER_LIST
=
[]
CALL_AND_REA
D_LIST
=
[]
EXTERNAL_COMMAN
D_LIST
=
[]
class
FakeConfig
:
pass
...
...
@@ -25,8 +25,8 @@ def fakeCallAndRead(argument_list, raise_on_error=True):
if
'useradd'
in
argument_list
:
global
USER_LIST
USER_LIST
.
append
(
argument_list
[
-
1
])
global
CALL_AND_REA
D_LIST
CALL_AND_REA
D_LIST
.
append
(
argument_list
)
global
EXTERNAL_COMMAN
D_LIST
EXTERNAL_COMMAN
D_LIST
.
append
(
argument_list
)
return
0
,
'UP'
class
LoggableWrapper
:
...
...
@@ -108,9 +108,9 @@ class SlapformatMixin(unittest.TestCase):
config
.
logger
=
logger
self
.
partition
=
slapos
.
format
.
Partition
(
'partition'
,
'/part_path'
,
slapos
.
format
.
User
(
'testuser'
),
[],
None
)
global
CALL_AND_REA
D_LIST
global
EXTERNAL_COMMAN
D_LIST
global
USER_LIST
CALL_AND_REA
D_LIST
=
[]
EXTERNAL_COMMAN
D_LIST
=
[]
USER_LIST
=
[
'testuser'
]
self
.
real_callAndRead
=
slapos
.
format
.
callAndRead
...
...
@@ -123,9 +123,9 @@ class SlapformatMixin(unittest.TestCase):
self
.
restoreOs
()
self
.
restoreGrp
()
self
.
restorePwd
()
global
CALL_AND_REA
D_LIST
global
EXTERNAL_COMMAN
D_LIST
global
USER_LIST
CALL_AND_REA
D_LIST
=
[]
EXTERNAL_COMMAN
D_LIST
=
[]
USER_LIST
=
[
'testuser'
]
slapos
.
format
.
callAndRead
=
self
.
real_callAndRead
...
...
@@ -151,13 +151,13 @@ class TestComputer(SlapformatMixin):
"chown('/software_root', 0, 0)"
,
"chmod('/software_root', 493)"
],
self
.
test_result
.
bucket
)
global
CALL_AND_REA
D_LIST
global
EXTERNAL_COMMAN
D_LIST
self
.
assertEqual
([
[
'ip'
,
'addr'
,
'list'
,
'bridge'
],
[
'groupadd'
,
'slapsoft'
],
[
'useradd'
,
'-d'
,
'/software_root'
,
'-g'
,
'slapsoft'
,
'-s'
,
'/bin/false'
,
'slapsoft'
]],
CALL_AND_REA
D_LIST
)
EXTERNAL_COMMAN
D_LIST
)
def
test_construct_empty_prepared_no_alter_user
(
self
):
computer
=
slapos
.
format
.
Computer
(
'computer'
,
...
...
@@ -170,10 +170,10 @@ class TestComputer(SlapformatMixin):
"makedirs('/software_root', 493)"
,
"chmod('/software_root', 493)"
],
self
.
test_result
.
bucket
)
global
CALL_AND_REA
D_LIST
global
EXTERNAL_COMMAN
D_LIST
self
.
assertEqual
([
[
'ip'
,
'addr'
,
'list'
,
'bridge'
],],
CALL_AND_REA
D_LIST
)
EXTERNAL_COMMAN
D_LIST
)
def
test_construct_empty_prepared_no_alter_network
(
self
):
computer
=
slapos
.
format
.
Computer
(
'computer'
,
...
...
@@ -187,13 +187,13 @@ class TestComputer(SlapformatMixin):
"chown('/software_root', 0, 0)"
,
"chmod('/software_root', 493)"
],
self
.
test_result
.
bucket
)
global
CALL_AND_REA
D_LIST
global
EXTERNAL_COMMAN
D_LIST
self
.
assertEqual
([
[
'ip'
,
'addr'
,
'list'
,
'bridge'
],
[
'groupadd'
,
'slapsoft'
],
[
'useradd'
,
'-d'
,
'/software_root'
,
'-g'
,
'slapsoft'
,
'-s'
,
'/bin/false'
,
'slapsoft'
]],
CALL_AND_REA
D_LIST
)
EXTERNAL_COMMAN
D_LIST
)
def
test_construct_empty_prepared_no_alter_network_user
(
self
):
computer
=
slapos
.
format
.
Computer
(
'computer'
,
...
...
@@ -206,11 +206,11 @@ class TestComputer(SlapformatMixin):
"makedirs('/software_root', 493)"
,
"chmod('/software_root', 493)"
],
self
.
test_result
.
bucket
)
global
CALL_AND_REA
D_LIST
global
EXTERNAL_COMMAN
D_LIST
self
.
assertEqual
([
[
'ip'
,
'addr'
,
'list'
,
'bridge'
],
],
CALL_AND_REA
D_LIST
)
EXTERNAL_COMMAN
D_LIST
)
class
TestPartition
(
SlapformatMixin
):
...
...
@@ -237,7 +237,7 @@ class TestPartition(SlapformatMixin):
class
TestUser
(
SlapformatMixin
):
def
test_create
(
self
):
global
CALL_AND_REA
D_LIST
global
EXTERNAL_COMMAN
D_LIST
user
=
slapos
.
format
.
User
(
'doesnotexistsyet'
)
user
.
setPath
(
'/doesnotexistsyet'
)
user
.
create
()
...
...
@@ -248,10 +248,10 @@ class TestUser(SlapformatMixin):
[
'useradd'
,
'-d'
,
'/doesnotexistsyet'
,
'-g'
,
'doesnotexistsyet'
,
'-s'
,
'/bin/false'
,
'doesnotexistsyet'
]
],
CALL_AND_REA
D_LIST
)
EXTERNAL_COMMAN
D_LIST
)
def
test_create_additional_groups
(
self
):
global
CALL_AND_REA
D_LIST
global
EXTERNAL_COMMAN
D_LIST
user
=
slapos
.
format
.
User
(
'doesnotexistsyet'
,
[
'additionalgroup1'
,
'additionalgroup2'
])
user
.
setPath
(
'/doesnotexistsyet'
)
...
...
@@ -264,11 +264,11 @@ class TestUser(SlapformatMixin):
'/bin/false'
,
'-G'
,
'additionalgroup1,additionalgroup2'
,
'doesnotexistsyet'
]
],
CALL_AND_REA
D_LIST
)
EXTERNAL_COMMAN
D_LIST
)
def
test_create_group_exists
(
self
):
pwd
.
getpwnam
=
self
.
raisingKeyError
global
CALL_AND_REA
D_LIST
global
EXTERNAL_COMMAN
D_LIST
user
=
slapos
.
format
.
User
(
'testuser'
)
user
.
setPath
(
'/testuser'
)
...
...
@@ -279,11 +279,11 @@ class TestUser(SlapformatMixin):
[
'useradd'
,
'-d'
,
'/testuser'
,
'-g'
,
'testuser'
,
'-s'
,
'/bin/false'
,
'testuser'
]
],
CALL_AND_REA
D_LIST
)
EXTERNAL_COMMAN
D_LIST
)
def
test_create_user_exists_additional_groups
(
self
):
grp
.
getgrnam
=
self
.
raisingKeyError
global
CALL_AND_REA
D_LIST
global
EXTERNAL_COMMAN
D_LIST
user
=
slapos
.
format
.
User
(
'testuser'
,
[
'additionalgroup1'
,
'additionalgroup2'
])
user
.
setPath
(
'/testuser'
)
...
...
@@ -295,11 +295,11 @@ class TestUser(SlapformatMixin):
[
'usermod'
,
'-d'
,
'/testuser'
,
'-g'
,
'testuser'
,
'-s'
,
'/bin/false'
,
'-G'
,
'additionalgroup1,additionalgroup2'
,
'testuser'
]
],
CALL_AND_REA
D_LIST
)
EXTERNAL_COMMAN
D_LIST
)
def
test_create_user_exists
(
self
):
grp
.
getgrnam
=
self
.
raisingKeyError
global
CALL_AND_REA
D_LIST
global
EXTERNAL_COMMAN
D_LIST
user
=
slapos
.
format
.
User
(
'testuser'
)
user
.
setPath
(
'/testuser'
)
user
.
create
()
...
...
@@ -310,10 +310,10 @@ class TestUser(SlapformatMixin):
[
'usermod'
,
'-d'
,
'/testuser'
,
'-g'
,
'testuser'
,
'-s'
,
'/bin/false'
,
'testuser'
]
],
CALL_AND_REA
D_LIST
)
EXTERNAL_COMMAN
D_LIST
)
def
test_create_user_group_exists
(
self
):
global
CALL_AND_REA
D_LIST
global
EXTERNAL_COMMAN
D_LIST
user
=
slapos
.
format
.
User
(
'testuser'
)
user
.
setPath
(
'/testuser'
)
user
.
create
()
...
...
@@ -323,7 +323,7 @@ class TestUser(SlapformatMixin):
[
'usermod'
,
'-d'
,
'/testuser'
,
'-g'
,
'testuser'
,
'-s'
,
'/bin/false'
,
'testuser'
]
],
CALL_AND_REA
D_LIST
)
EXTERNAL_COMMAN
D_LIST
)
def
test_isAvailable
(
self
):
user
=
slapos
.
format
.
User
(
'testuser'
)
...
...
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