Skip to content

Commit

Permalink
pre-commit fixes
Browse files Browse the repository at this point in the history
  • Loading branch information
waynew committed May 11, 2022
1 parent 42bbee0 commit 08acb9b
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 14 deletions.
18 changes: 5 additions & 13 deletions salt/auth/pam.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@
# -*- coding: utf-8 -*-
# The pam components have been modified to be salty and have been taken from
# the pam module under this licence:
# (c) 2007 Chris AtLee <[email protected]>
Expand Down Expand Up @@ -35,8 +34,6 @@
"""

# Import Python Libs
from __future__ import absolute_import, print_function, unicode_literals

import logging
from ctypes import (
Expand All @@ -55,13 +52,8 @@
)
from ctypes.util import find_library

# Import Salt libs
import salt.utils.user

# Import 3rd-party libs
from salt.ext import six
from salt.ext.six.moves import range # pylint: disable=import-error,redefined-builtin

log = logging.getLogger(__name__)

try:
Expand Down Expand Up @@ -110,7 +102,7 @@ class PamMessage(Structure):
]

def __repr__(self):
return "<PamMessage {0} '{1}'>".format(self.msg_style, self.msg)
return "<PamMessage {} '{}'>".format(self.msg_style, self.msg)


class PamResponse(Structure):
Expand All @@ -124,7 +116,7 @@ class PamResponse(Structure):
]

def __repr__(self):
return "<PamResponse {0} '{1}'>".format(self.resp_retcode, self.resp)
return "<PamResponse {} '{}'>".format(self.resp_retcode, self.resp)


CONV_FUNC = CFUNCTYPE(
Expand Down Expand Up @@ -182,11 +174,11 @@ def authenticate(username, password):
"""
service = __opts__.get("auth.pam.service", "login")

if isinstance(username, six.text_type):
if isinstance(username, str):
username = username.encode(__salt_system_encoding__)
if isinstance(password, six.text_type):
if isinstance(password, str):
password = password.encode(__salt_system_encoding__)
if isinstance(service, six.text_type):
if isinstance(service, str):
service = service.encode(__salt_system_encoding__)

@CONV_FUNC
Expand Down
2 changes: 1 addition & 1 deletion tests/pytests/unit/auth/test_pam.py
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ def configure_loader_modules():
@pytest.fixture
def mock_pam():
with patch("salt.auth.pam.CALLOC", autospec=True), patch(
"salt.auth.pam.pointer", autospec=True,
"salt.auth.pam.pointer", autospec=True,
), patch("salt.auth.pam.PamHandle", autospec=True), patch(
"salt.auth.pam.PAM_START", autospec=True, return_value=0
), patch(
Expand Down

0 comments on commit 08acb9b

Please sign in to comment.