Ejemplo n.º 1
0
    def test_bad_password(self):
        authenticator = LegacyCHSAuthentication()

        # bad pass
        mock_request = MagicMock(
            DATA={
                "CHSOrganisationID": self.staff.chs_organisation,
                "CHSPassword": "******",
                "CHSUserName": self.staff.chs_user,
            })

        with self.assertRaises(AuthenticationFailed):
            user, _ = authenticator.authenticate(mock_request)

        # test bad org
        mock_request = MagicMock(
            DATA={
                "CHSOrganisationID": self.staff.chs_organisation + "111",
                "CHSPassword": "******",
                "CHSUserName": self.staff.chs_user,
            })

        with self.assertRaises(AuthenticationFailed):
            user, _ = authenticator.authenticate(mock_request)

        # test bad user
        mock_request = MagicMock(
            DATA={
                "CHSOrganisationID": self.staff.chs_organisation,
                "CHSPassword": "******",
                "CHSUserName": self.staff.chs_user + "qq",
            })

        with self.assertRaises(AuthenticationFailed):
            user, _ = authenticator.authenticate(mock_request)
Ejemplo n.º 2
0
    def test_valid_login(self):
        authenticator = LegacyCHSAuthentication()
        mock_request = MagicMock(
            DATA={
                "CHSOrganisationID": self.staff.chs_organisation,
                "CHSPassword": "******",
                "CHSUserName": self.staff.chs_user,
            })

        user, _ = authenticator.authenticate(mock_request)
        self.assertIsNotNone(user)
Ejemplo n.º 3
0
    def test_valid_login(self):
        authenticator = LegacyCHSAuthentication()
        mockRequest = MagicMock(
            DATA={
                'CHSOrganisationID': self.staff.chs_organisation,
                'CHSPassword': '******',
                'CHSUserName': self.staff.chs_user
            })

        user, _ = authenticator.authenticate(mockRequest)
        self.assertIsNotNone(user)
Ejemplo n.º 4
0
    def test_malformed_login(self):
        self.user.is_active = False
        self.user.save()

        authenticator = LegacyCHSAuthentication()
        mock_request = MagicMock(
            DATA={
                "CCHSOrganisationID": self.staff.chs_organisation,
                "CCHSPassword": "******",
                "CCHSUserName": self.staff.chs_user,
            })

        self.assertIsNone(authenticator.authenticate(mock_request))
Ejemplo n.º 5
0
    def test_malformed_login(self):
        self.user.is_active = False
        self.user.save()

        authenticator = LegacyCHSAuthentication()
        mockRequest = MagicMock(
            DATA={
                'CCHSOrganisationID': self.staff.chs_organisation,
                'CCHSPassword': '******',
                'CCHSUserName': self.staff.chs_user
            })

        self.assertIsNone(authenticator.authenticate(mockRequest))
Ejemplo n.º 6
0
    def test_valid_login_but_is_active_false(self):
        self.user.is_active = False
        self.user.save()

        authenticator = LegacyCHSAuthentication()
        mock_request = MagicMock(
            DATA={
                "CHSOrganisationID": self.staff.chs_organisation,
                "CHSPassword": "******",
                "CHSUserName": self.staff.chs_user,
            })

        with self.assertRaises(AuthenticationFailed):
            user, _ = authenticator.authenticate(mock_request)
Ejemplo n.º 7
0
    def test_bad_password(self):

        authenticator = LegacyCHSAuthentication()

        # bad pass
        mockRequest = MagicMock(
            DATA={
                'CHSOrganisationID': self.staff.chs_organisation,
                'CHSPassword': '******',
                'CHSUserName': self.staff.chs_user
            })

        with self.assertRaises(AuthenticationFailed):
            user, _ = authenticator.authenticate(mockRequest)

        # test bad org
        mockRequest = MagicMock(
            DATA={
                'CHSOrganisationID': self.staff.chs_organisation + '111',
                'CHSPassword': '******',
                'CHSUserName': self.staff.chs_user
            })

        with self.assertRaises(AuthenticationFailed):
            user, _ = authenticator.authenticate(mockRequest)

        # test bad user
        mockRequest = MagicMock(
            DATA={
                'CHSOrganisationID': self.staff.chs_organisation,
                'CHSPassword': '******',
                'CHSUserName': self.staff.chs_user + 'qq'
            })

        with self.assertRaises(AuthenticationFailed):
            user, _ = authenticator.authenticate(mockRequest)