Beispiel #1
0
    def check_token(
        self,
        mock_base,
        mock_request,
        mock_response,
        mock_session,
        mock_check_policy_pre,
        mock_TokenIterator,
        with_json,
    ):
        """
        call admin/show with/without argument tokeninfo_format
        and return if parse_tokeninfo has been called
        """
        request_params = {
            "tokeninfo_format": with_json,
        }
        mock_check_policy_pre.return_value = {
            "active": False,
            "admin": "unittest",
        }
        tok = copy.deepcopy(self.token)
        mock_TokenIterator.return_value = [tok]

        flask.g.audit = {}
        admin = AdminController()
        admin.request_params = request_params
        admin.show()
Beispiel #2
0
    def test_parse_empty_tokeninfo(self):
        """
        verify that token info is valid even if it is initially empty
        """
        tok = copy.deepcopy(self.token2)
        AdminController.parse_tokeninfo(tok)

        self.assertTrue(tok['LinOtp.TokenInfo'] == {})

        return
Beispiel #3
0
    def test_parse_empty_tokeninfo(self):
        """
        verify that token info is valid even if it is initially empty
        """
        tok = copy.deepcopy(self.token2)
        AdminController.parse_tokeninfo(tok)

        assert tok['LinOtp.TokenInfo'] == {}

        return
Beispiel #4
0
    def test_parse_tokeninfo(self):
        """"
        check if admin.parse_tokeninfo works
        """
        tok = copy.deepcopy(self.token)

        AdminController.parse_tokeninfo(tok)

        assert isinstance(tok.get('LinOtp.TokenInfo'), dict), \
            'TokenInfo is not of type dict!'
        assert dict(tok.get('LinOtp.TokenInfo'), **self.expected_subset) == tok.get('LinOtp.TokenInfo'), \
            tok.get('LinOtp.TokenInfo')
Beispiel #5
0
    def test_parse_tokeninfo(self):
        """"
        check if admin.parse_tokeninfo works
        """
        tok = copy.deepcopy(self.token)

        AdminController.parse_tokeninfo(tok)

        self.assertIsInstance(tok.get('LinOtp.TokenInfo'), dict,
                              'TokenInfo is not of type dict!')
        self.assertDictContainsSubset(self.expected_subset,
                                      tok.get('LinOtp.TokenInfo'),
                                      tok.get('LinOtp.TokenInfo'))
Beispiel #6
0
    def test_parse_tokeninfo(self):
        """"
        check if admin.parse_tokeninfo works
        """
        tok = copy.deepcopy(self.token)

        AdminController.parse_tokeninfo(tok)

        self.assertIsInstance(tok.get('LinOtp.TokenInfo'),
                              dict,
                              'TokenInfo is not of type dict!')
        self.assertDictContainsSubset(self.expected_subset,
                                      tok.get('LinOtp.TokenInfo'),
                                      tok.get('LinOtp.TokenInfo'))
Beispiel #7
0
    def check_token(self, mock_base, mock_request, mock_response, mock_session,
                    mock_check_policy_pre, mock_c, mock_TokenIterator,
                    with_json):
        """
        call admin/show with/without argument tokeninfo_format
        and return if parse_tokeninfo has been called
        """
        request_params = {
            'tokeninfo_format': with_json,
        }
        mock_check_policy_pre.return_value = {'active': False,
                                              'admin': 'unittest'}
        mock_c.audit = {}
        tok = copy.deepcopy(self.token)
        mock_TokenIterator.return_value = [tok]

        admin = AdminController()
        admin.request_params = request_params
        admin.show()
Beispiel #8
0
    def check_token(self, mock_base, mock_request, mock_response, mock_session,
                    mock_check_policy_pre, mock_c, mock_TokenIterator,
                    with_json):
        """
        call admin/show with/without argument tokeninfo_format
        and return if parse_tokeninfo has been called
        """
        mock_request.params = {
            'tokeninfo_format': with_json,
        }
        mock_check_policy_pre.return_value = {
            'active': False,
            'admin': 'unittest'
        }
        mock_c.audit = {}
        tok = copy.deepcopy(self.token)
        mock_TokenIterator.return_value = [tok]

        admin = AdminController()
        admin.show()