Beispiel #1
0
 def test_exiting_user_duplicate_email(self):
     factories.UserF(email="*****@*****.**")
     factories.UserF(email="*****@*****.**")
     form = mock.Mock()
     form.cleaned_data = self.user_data
     result = self.view.form_valid(form)
     # Should return a 409 conflict statuscode
     self.assertEqual(409, result.status_code)
Beispiel #2
0
 def test_exiting_user_different_case(self):
     factories.UserF(email="*****@*****.**")
     form = mock.Mock()
     form.cleaned_data = self.user_data
     result = self.view.form_valid(form)
     # Should return a 409 conflict statucode
     self.assertEqual(409, result.status_code)
Beispiel #3
0
 def setUp(self):
     self.sso_key = "sso key"
     factories.PortalF.create(sso_key=self.sso_key)
     self.view = views_api_v2.CheckCredentialsView()
     self.request_factory = RequestFactory()
     self.some_request = self.request_factory.get("/some/url/")
     self.organisation = factories.OrganisationF()
     self.username = "******"
     self.password = "******"
     self.user = factories.UserF(username=self.username, password=self.password)
Beispiel #4
0
 def setUp(self):
     self.sso_key = "sso key"
     self.portal = factories.PortalF.create(sso_key=self.sso_key)
     self.view = views_api_v2.CognitoUserExistsView()
     self.username = "******"
     self.password = "******"
     self.email = "*****@*****.**"
     self.user = factories.UserF(
         username=self.username, password=self.password, email=self.email
     )
     self.url = reverse("lizard_auth_server.cognito.user_exists")
     self.client = Client()
Beispiel #5
0
    def setUp(self):
        self.factory = RequestFactory()
        self.user = factories.UserF()
        self.client = OIDC_Client.objects.create(client_id="id")
        expires_at = datetime(3022, 2, 17)
        date_given = datetime(3018, 4, 16)
        self.user_consent = UserConsent.objects.create(
            expires_at=expires_at,
            client=self.client,
            user=self.user,
            date_given=date_given,
        )

        self.userconsents_before_deletion = UserConsent.objects.count()
Beispiel #6
0
 def setUp(self):
     self.sso_key = "sso key"
     self.portal = factories.PortalF.create(
         sso_key=self.sso_key, allow_migrate_user=True
     )
     self.view = views_api_v2.CognitoUserMigrationView()
     self.username = "******"
     self.password = "******"
     self.user = factories.UserF(username=self.username, password=self.password)
     self.url = reverse("lizard_auth_server.cognito.migrate_user")
     self.client = Client()
     self.expected_profile = {
         "username": self.user.username,
         "email": self.user.email,
         "first_name": self.user.first_name,
         "last_name": self.user.last_name,
     }
Beispiel #7
0
    def test_duplicate_username_http_response(self):
        # Duplicate username (with different e-mail)
        # should return HTTP 409 (conflict)

        factories.UserF(username="******", email="*****@*****.**")
        client = Client()
        params = {
            "username": "******",
            "email": "*****@*****.**",
            "first_name": "pietje",
            "last_name": "pietje",
            "iss": self.sso_key,
        }

        # Encode data in JWT
        message = jwt.encode(params, self.portal.sso_secret, algorithm="HS256")

        # Send data both plain and in JWT.
        params.update({"key": self.sso_key, "message": message.decode("utf8")})

        response = client.post(reverse("lizard_auth_server.api_v2.new_user"), params)
        self.assertEqual(409, response.status_code)
Beispiel #8
0
 def test_duplicate_user(self):
     factories.UserF(username=self.username.upper())
     result = self.form_valid()
     self.assertEqual(409, result.status_code)
Beispiel #9
0
 def test_exiting_user(self):
     factories.UserF(email="*****@*****.**")
     form = mock.Mock()
     form.cleaned_data = self.user_data
     result = self.view.form_valid(form)
     self.assertEqual(200, result.status_code)
Beispiel #10
0
 def test_duplicate_username(self):
     factories.UserF(username="******", email="*****@*****.**")
     form = mock.Mock()
     form.cleaned_data = self.user_data
     response = self.view.form_valid(form)
     self.assertEqual(409, response.status_code)
Beispiel #11
0
 def test_token_for_inactive_user(self):
     user = factories.UserF(is_active=False)
     user.user_profile.portals.add(self.portal)
     JWTView.get_token(user, self.portal)
Beispiel #12
0
 def setUp(self):
     self.factory = RequestFactory()
     self.portal = factories.PortalF()
     self.user = factories.UserF()