Restores sushy session functionality.
This patch restores sushy session functionality to the SessionOrBasicAuth by moving can_refresh_session to its parent SessionAuth. Also fixed verify being ignored. Closes-Bug: 1744378 Change-Id: Ia9ce0fe965f13e2d7f7634957306fa4ce6746b39
This commit is contained in:
parent
a31d7a40c3
commit
d03a70f700
|
@ -156,7 +156,8 @@ class SessionAuth(AuthBase):
|
|||
|
||||
def can_refresh_session(self):
|
||||
"""Method to assert if session based refresh can be done."""
|
||||
return True
|
||||
return (self._session_key is not None and
|
||||
self._session_resource_id is not None)
|
||||
|
||||
def refresh_session(self):
|
||||
"""Method to refresh a session to a Redfish controller.
|
||||
|
@ -223,11 +224,6 @@ class SessionOrBasicAuth(SessionAuth):
|
|||
self.basic_auth.set_context(self._root_resource, self._connector)
|
||||
self.basic_auth.authenticate()
|
||||
|
||||
def can_refresh_session(self):
|
||||
"""Method to assert if session based refresh can be done."""
|
||||
return (self._session_key is not None and
|
||||
self._session_resource_id is not None)
|
||||
|
||||
def refresh_session(self):
|
||||
"""Method to refresh a session to a Redfish controller.
|
||||
|
||||
|
|
|
@ -74,12 +74,12 @@ class Sushy(base.ResourceBase):
|
|||
msg = ('Username or Password were provided to Sushy '
|
||||
'when an authentication mechanism was specified.')
|
||||
raise ValueError(msg)
|
||||
else:
|
||||
if auth is None:
|
||||
auth = sushy_auth.SessionOrBasicAuth(username=username,
|
||||
password=password)
|
||||
|
||||
super(Sushy, self).__init__(
|
||||
connector or sushy_connector.Connector(base_url, verify),
|
||||
connector or sushy_connector.Connector(base_url, verify=verify),
|
||||
path=self._root_prefix)
|
||||
self._auth = auth
|
||||
self._auth.set_context(self, self._conn)
|
||||
|
|
|
@ -138,6 +138,14 @@ class SessionAuthTestCase(base.TestCase):
|
|||
self.conn.set_http_session_auth.assert_called_once_with(self.sess_key)
|
||||
|
||||
def test_can_refresh_session(self):
|
||||
mock_sess_serv = mock.Mock()
|
||||
mock_sess_serv.create_session.return_value = (self.sess_key,
|
||||
self.sess_uri)
|
||||
self.root.get_session_service.return_value = mock_sess_serv
|
||||
|
||||
self.sess_auth.set_context(self.root, self.conn)
|
||||
self.sess_auth.authenticate()
|
||||
|
||||
self.assertTrue(self.sess_auth.can_refresh_session())
|
||||
|
||||
def test_refresh(self):
|
||||
|
|
|
@ -44,7 +44,7 @@ class MainTestCase(base.TestCase):
|
|||
self.root = main.Sushy('http://foo.bar:1234',
|
||||
verify=True, auth=mock_auth)
|
||||
mock_connector.assert_called_once_with(
|
||||
'http://foo.bar:1234', True)
|
||||
'http://foo.bar:1234', verify=True)
|
||||
|
||||
def test__parse_attributes(self):
|
||||
self.root._parse_attributes()
|
||||
|
|
Loading…
Reference in New Issue