diff --git a/cvprac/cvp_api.py b/cvprac/cvp_api.py index 6cdea11..27abf4c 100644 --- a/cvprac/cvp_api.py +++ b/cvprac/cvp_api.py @@ -201,8 +201,13 @@ def get_cert_login_info(self): CvpApiError: A CvpApiError is raised if the request is made without a valid certificate based authentication session. ''' - return self.clnt.get('/aaa/v1/certLoginInfo', - timeout=self.request_timeout) + if self.clnt.cert_login: + return self.clnt.get('/aaa/v1/certLoginInfo', + timeout=self.request_timeout) + else: + self.log.warning( + "get_cert_login_info is only available when using certificate authentication" + ) # pylint: disable=too-many-arguments def add_user(self, username, password, role, status, first_name, diff --git a/test/unit/test_api.py b/test/unit/test_api.py index 915aba3..0e51502 100644 --- a/test/unit/test_api.py +++ b/test/unit/test_api.py @@ -134,7 +134,9 @@ def test_get_cert_login_info(self): """Test cert login info request.""" self.clnt.get = Mock(return_value={'username': 'certuser'}) + self.clnt.cert_login = True result = self.api.get_cert_login_info() + self.clnt.cert_login = False self.clnt.get.assert_called_once_with('/aaa/v1/certLoginInfo', timeout=30)