Skip to content

Commit 8147b99

Browse files
Dan Lavujakub-vavra-cz
authored andcommitted
fixing tox formatting complaints
1 parent 1ece2f5 commit 8147b99

File tree

13 files changed

+43
-71
lines changed

13 files changed

+43
-71
lines changed

sssd_test_framework/hosts/base.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -162,7 +162,7 @@ def naming_context(self) -> str:
162162
if len(result) != 1:
163163
raise ValueError(f"Unexpected number of results for rootDSE query: {len(result)}")
164164

165-
(_, values) = result[0]
165+
_, values = result[0]
166166
if attr not in values:
167167
raise ValueError(f"Unable to find {attr}")
168168

sssd_test_framework/hosts/ipa.py

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -106,15 +106,13 @@ def setup(self) -> None:
106106
"""
107107
Truncate existing IPA logs before each test to avoid need for restart.
108108
"""
109-
self.conn.run(
110-
"""
109+
self.conn.run("""
111110
set -ex
112111
truncate --size 0 /var/log/dirsrv/*/*
113112
truncate --size 0 /var/log/httpd/*
114113
truncate --size 0 /var/log/ipa/*
115114
truncate --size 0 /var/log/krb5kdc.log
116-
"""
117-
)
115+
""")
118116

119117
def kinit(self) -> None:
120118
"""

sssd_test_framework/hosts/samba.py

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -73,12 +73,10 @@ def start(self) -> None:
7373
self.svc.start("samba.service")
7474

7575
# systemctl finishes before Samba is really listening, we need to wait
76-
self.conn.run(
77-
"""
76+
self.conn.run("""
7877
timeout 60s bash -c 'until netstat -ltp 2> /dev/null | grep :ldap &> /dev/null; do :; done'
7978
timeout 60s bash -c 'until netstat -ltp 2> /dev/null | grep :kerberos &> /dev/null; do :; done'
80-
"""
81-
)
79+
""")
8280

8381
def stop(self) -> None:
8482
self.svc.stop("samba.service")

sssd_test_framework/misc/__init__.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,7 @@ def attrs_parse(lines: list[str], attrs: list[str] | None = None) -> dict[str, l
2828
i += 1
2929
continue
3030

31-
(key, value) = map(lambda x: x.lstrip(), line.split(":", 1))
31+
key, value = map(lambda x: x.lstrip(), line.split(":", 1))
3232
key = key.strip()
3333
while i < len(lines) - 1:
3434
if lines[i + 1].startswith(" "):

sssd_test_framework/misc/ssh.py

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -61,13 +61,11 @@ def __init__(
6161
)
6262

6363
# Get pid
64-
result = self.client.run(
65-
f"""
64+
result = self.client.run(f"""
6665
until [ -f "{pidfile}" ]; do sleep 0.005; done
6766
cat "{pidfile}"
6867
rm -f "{pidfile}"
69-
"""
70-
)
68+
""")
7169

7270
self.pid = result.stdout.strip()
7371
"""Process id."""

sssd_test_framework/roles/ad.py

Lines changed: 16 additions & 32 deletions
Original file line numberDiff line numberDiff line change
@@ -1141,12 +1141,10 @@ def add_members(self, members: list[ADUser | ADGroup]) -> ADGroup:
11411141
:return: Self.
11421142
:rtype: ADGroup
11431143
"""
1144-
self.role.host.conn.run(
1145-
f"""
1144+
self.role.host.conn.run(f"""
11461145
Import-Module ActiveDirectory
11471146
Add-ADGroupMember -Identity '{self.dn}' -Members {self.__get_members(members)}
1148-
"""
1149-
)
1147+
""")
11501148
return self
11511149

11521150
def remove_member(self, member: ADUser | ADGroup) -> ADGroup:
@@ -1169,12 +1167,10 @@ def remove_members(self, members: list[ADUser | ADGroup]) -> ADGroup:
11691167
:return: Self.
11701168
:rtype: ADGroup
11711169
"""
1172-
self.role.host.conn.run(
1173-
f"""
1170+
self.role.host.conn.run(f"""
11741171
Import-Module ActiveDirectory
11751172
Remove-ADGroupMember -Confirm:$False -Identity '{self.dn}' -Members {self.__get_members(members)}
1176-
"""
1177-
)
1173+
""")
11781174
return self
11791175

11801176
def __get_members(self, members: list[ADUser | ADGroup]) -> str:
@@ -1835,12 +1831,10 @@ def get(self, key: str) -> str | None:
18351831
:return: Key value.
18361832
:rtype: str
18371833
"""
1838-
result = self.role.host.conn.run(
1839-
rf"""
1834+
result = self.role.host.conn.run(rf"""
18401835
$query = "(&(ObjectClass=groupPolicyContainer)(DisplayName={self.name}))"
18411836
Get-ADObject -SearchBase "{self.search_base}" -Properties "*" -LDAPFilter $query
1842-
"""
1843-
).stdout_lines
1837+
""").stdout_lines
18441838

18451839
i = 0
18461840
while i < len(result):
@@ -1881,8 +1875,7 @@ def add(self) -> GPO:
18811875
self.cn = self.get("CN")
18821876
self.dn = self.get("DistinguishedName")
18831877

1884-
self.role.host.conn.run(
1885-
rf"""
1878+
self.role.host.conn.run(rf"""
18861879
Import-Module GroupPolicy, PSIni
18871880
$path = "C:\\Windows\\SYSVOL\\domain\\Policies\\{self.cn}\\Machine\\Microsoft\\Windows NT\\SecEdit"
18881881
$file = Join-Path $path GptTmpl.inf
@@ -1892,8 +1885,7 @@ def add(self) -> GPO:
18921885
Out-IniFile -InputObject $content -FilePath $file
18931886
Test-Path -Path "$path"
18941887
Exit 0
1895-
"""
1896-
)
1888+
""")
18971889
return self
18981890

18991891
def link(
@@ -1970,8 +1962,7 @@ def permissions(self, target: str, permission_level: str, target_type: str | Non
19701962
:rtype: GPO
19711963
"""
19721964
if permission_level == "None" and target == "Authenticated Users":
1973-
self.role.host.conn.run(
1974-
rf"""
1965+
self.role.host.conn.run(rf"""
19751966
# Some test scenarios require making the GPO unreadable. Changing the 'Authenticated Users',
19761967
# 'S-1-5-11' SID permissions to 'None' accomplishes that. The confirm prompt cannot be skipped
19771968
# using Set-GPPermissions, for more information. https://support.microsoft.com/kb/3163622
@@ -1990,8 +1981,7 @@ def permissions(self, target: str, permission_level: str, target_type: str | Non
19901981
$authenticated_users, "ReadProperty", "Deny")
19911982
$gpo_adsi.psbase.get_objectSecurity().AddAccessRule($ace)
19921983
$gpo_adsi.psbase.CommitChanges()
1993-
"""
1994-
)
1984+
""")
19951985
else:
19961986
self.role.host.conn.run(
19971987
f'Set-GPPermission -Guid "{self.cn}" '
@@ -2056,37 +2046,31 @@ def policy(self, logon_rights: dict[str, list[ADObject]], cfg: dict[str, Any] |
20562046

20572047
ps_logon_rights = attrs_to_hash(_logon_rights)
20582048

2059-
self.host.conn.run(
2060-
rf"""
2049+
self.host.conn.run(rf"""
20612050
Import-Module PSIni
20622051
$path = "C:\\Windows\\SYSVOL\\domain\\Policies\\{self.cn}\\Machine\\Microsoft\\Windows NT\\SecEdit"
20632052
$file = Join-Path $path GptTmpl.inf
20642053
$policy = @{{"Privilege Rights"={ps_logon_rights}}}
20652054
Out-IniFile -InputObject $policy -FilePath "$file"
20662055
Exit 0
2067-
"""
2068-
)
2056+
""")
20692057

20702058
if cfg is not None:
20712059
ps_cfg = attrs_to_hash(cfg)
2072-
self.host.conn.run(
2073-
rf"""
2060+
self.host.conn.run(rf"""
20742061
Import-Module PSIni
20752062
$path = "C:\\Windows\\SYSVOL\\domain\\Policies\\{self.cn}\\Machine\\Microsoft\\Windows NT\\SecEdit"
20762063
$file = Join-Path $path GptTmpl.inf
20772064
$policy = {ps_cfg}
20782065
Out-IniFile -InputObject $policy -FilePath "$file"
20792066
Exit 0
2080-
"""
2081-
)
2067+
""")
20822068

2083-
self.host.conn.run(
2084-
rf"""
2069+
self.host.conn.run(rf"""
20852070
$gpc = "[{{827D319E-6EAC-11D2-A4EA-00C04F79F83A}}{{803E14A0-B4FB-11D0-A0D0-00A0C90F574B}}]"
20862071
Set-ADObject -Identity "{self.dn}" -Replace @{{gPCMachineExtensionNames=$gpc}}
20872072
Exit 0
2088-
"""
2089-
)
2073+
""")
20902074

20912075
return self
20922076

sssd_test_framework/roles/ipa.py

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -2035,12 +2035,12 @@ def add(
20352035
)
20362036

20372037
# Prepare data
2038-
(allow_commands, deny_commands, cmdcat) = self.__get_commands(command)
2039-
(hosts, hostcat) = self.__get_hosts(host)
2040-
(users, groups, usercat) = self.__get_users_and_groups(user)
2038+
allow_commands, deny_commands, cmdcat = self.__get_commands(command)
2039+
hosts, hostcat = self.__get_hosts(host)
2040+
users, groups, usercat = self.__get_users_and_groups(user)
20412041
options = to_list_of_strings(option)
2042-
(runasuser_users, runasuser_groups, runasusercat) = self.__get_run_as_user(runasuser)
2043-
(runasgroup_groups, runasgroupcat) = self.__get_run_as_group(runasgroup)
2042+
runasuser_users, runasuser_groups, runasusercat = self.__get_run_as_user(runasuser)
2043+
runasgroup_groups, runasgroupcat = self.__get_run_as_group(runasgroup)
20442044

20452045
if nopasswd is True:
20462046
options = attrs_include_value(options, "!authenticate")
@@ -2216,7 +2216,7 @@ def __get_users_and_groups(
22162216
def __get_run_as_user(
22172217
self, value: str | IPAUser | IPAGroup | list[str | IPAUser | IPAGroup] | None
22182218
) -> tuple[list[str], list[str], str]:
2219-
(users, groups, category) = self.__get_users_and_groups(value)
2219+
users, groups, category = self.__get_users_and_groups(value)
22202220
if category:
22212221
category = "--runasusercat=all"
22222222

sssd_test_framework/roles/kdc.py

Lines changed: 4 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -117,8 +117,7 @@ def config(self) -> str:
117117
:return: Kerberos configuration.
118118
:rtype: str
119119
"""
120-
return textwrap.dedent(
121-
f"""
120+
return textwrap.dedent(f"""
122121
[logging]
123122
default = FILE:/var/log/krb5libs.log
124123
kdc = FILE:/var/log/krb5kdc.log
@@ -144,8 +143,7 @@ def config(self) -> str:
144143
[domain_realm]
145144
.{self.host.domain} = {self.host.realm}
146145
{self.host.domain} = {self.host.realm}
147-
"""
148-
).lstrip()
146+
""").lstrip()
149147

150148

151149
class KDCPrincipal(BaseObject[KDCHost, KDC]):
@@ -193,7 +191,7 @@ def get(self) -> dict[str, str]:
193191
result = self.role.kadmin(f'getprinc "{self.name}"')
194192
out = {}
195193
for line in result.stdout_lines:
196-
(key, value) = line.split(":", maxsplit=1)
194+
key, value = line.split(":", maxsplit=1)
197195
out[key] = value.strip()
198196

199197
return out
@@ -228,7 +226,7 @@ def get_strings(self) -> dict[str, str]:
228226
result = self.role.kadmin(f'getstrs "{self.name}"')
229227
out = {}
230228
for line in result.stdout_lines:
231-
(key, value) = line.split(":", maxsplit=1)
229+
key, value = line.split(":", maxsplit=1)
232230
out[key] = value.strip()
233231

234232
return out

sssd_test_framework/roles/ldap.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -675,7 +675,7 @@ def get(self, attrs: list[str] | None = None, opattrs: bool = False) -> dict[str
675675
if len(result) != 1:
676676
raise ValueError(f"Multiple objects returned on base search for {self.dn}")
677677

678-
(_, result_attrs) = result[0]
678+
_, result_attrs = result[0]
679679
out: dict[str, list[str]] = {}
680680
for key, values in result_attrs.items():
681681
out[key] = []

sssd_test_framework/roles/samba.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -583,7 +583,7 @@ def get(self, attrs: list[str] | None = None) -> dict[str, list[str]]:
583583
attrlist=attrs,
584584
)
585585

586-
(_, result_attrs) = result[0]
586+
_, result_attrs = result[0]
587587
out: list[str] = []
588588
for key, values in result_attrs.items():
589589
for value in values:

0 commit comments

Comments
 (0)