Example #1
0
    def test_delete_user_who_is_not_in_the_db(self):
        records = list(self.backend.get_user_records(SERVICE, EMAIL))
        self.assertEquals(len(records), 0)

        process_account_event(self.config,
                              message_body(event="delete", uid=UID, iss=ISS))

        records = list(self.backend.get_user_records(SERVICE, EMAIL))
        self.assertEquals(len(records), 0)
    def test_reset_user_by_legacy_uid_format(self):
        self.backend.allocate_user(SERVICE, EMAIL, generation=12)

        process_account_event(self.config, message_body(
            event="reset",
            uid=EMAIL,
            generation=43,
        ))

        user = self.backend.get_user(SERVICE, EMAIL)
        self.assertEquals(user["generation"], 42)
    def test_password_change(self):
        self.backend.allocate_user(SERVICE, EMAIL, generation=12)

        process_account_event(self.config, message_body(
            event="passwordChange",
            uid=UID,
            iss=ISS,
            generation=43,
        ))

        user = self.backend.get_user(SERVICE, EMAIL)
        self.assertEquals(user["generation"], 42)
Example #4
0
    def test_reset_user_by_legacy_uid_format(self):
        self.backend.allocate_user(SERVICE, EMAIL, generation=12)

        process_account_event(
            self.config, message_body(
                event="reset",
                uid=EMAIL,
                generation=43,
            ))

        user = self.backend.get_user(SERVICE, EMAIL)
        self.assertEquals(user["generation"], 42)
    def test_reset_user(self):
        EMAIL = "*****@*****.**"
        self.backend.allocate_user(SERVICE, EMAIL, generation=12)

        process_account_event(self.config, message_body(
            event="reset",
            uid=EMAIL,
            generation=43,
        ))

        user = self.backend.get_user(SERVICE, EMAIL)
        self.assertEquals(user["generation"], 42)
    def test_delete_user_who_is_not_in_the_db(self):
        records = list(self.backend.get_user_records(SERVICE, EMAIL))
        self.assertEquals(len(records), 0)

        process_account_event(self.config, message_body(
            event="delete",
            uid=UID,
            iss=ISS
        ))

        records = list(self.backend.get_user_records(SERVICE, EMAIL))
        self.assertEquals(len(records), 0)
Example #7
0
    def test_reset_user(self):
        EMAIL = "*****@*****.**"
        self.backend.allocate_user(SERVICE, EMAIL, generation=12)

        process_account_event(
            self.config, message_body(
                event="reset",
                uid=EMAIL,
                generation=43,
            ))

        user = self.backend.get_user(SERVICE, EMAIL)
        self.assertEquals(user["generation"], 42)
    def test_password_change_user_not_in_db(self):
        records = list(self.backend.get_user_records(SERVICE, EMAIL))
        self.assertEquals(len(records), 0)

        process_account_event(self.config, message_body(
            event="passwordChange",
            uid=UID,
            iss=ISS,
            generation=43,
        ))

        records = list(self.backend.get_user_records(SERVICE, EMAIL))
        self.assertEquals(len(records), 0)
    def test_reset_user_who_is_not_in_the_db(self):
        EMAIL = "*****@*****.**"
        records = list(self.backend.get_user_records(SERVICE, EMAIL))
        self.assertEquals(len(records), 0)

        process_account_event(self.config, message_body(
            event="reset",
            uid=EMAIL,
            generation=43,
        ))

        records = list(self.backend.get_user_records(SERVICE, EMAIL))
        self.assertEquals(len(records), 0)
Example #10
0
    def test_password_change(self):
        self.backend.allocate_user(SERVICE, EMAIL, generation=12)

        process_account_event(
            self.config,
            message_body(
                event="passwordChange",
                uid=UID,
                iss=ISS,
                generation=43,
            ))

        user = self.backend.get_user(SERVICE, EMAIL)
        self.assertEquals(user["generation"], 42)
Example #11
0
    def test_reset_user_who_is_not_in_the_db(self):
        EMAIL = "*****@*****.**"
        records = list(self.backend.get_user_records(SERVICE, EMAIL))
        self.assertEquals(len(records), 0)

        process_account_event(
            self.config, message_body(
                event="reset",
                uid=EMAIL,
                generation=43,
            ))

        records = list(self.backend.get_user_records(SERVICE, EMAIL))
        self.assertEquals(len(records), 0)
Example #12
0
    def test_password_change_user_not_in_db(self):
        records = list(self.backend.get_user_records(SERVICE, EMAIL))
        self.assertEquals(len(records), 0)

        process_account_event(
            self.config,
            message_body(
                event="passwordChange",
                uid=UID,
                iss=ISS,
                generation=43,
            ))

        records = list(self.backend.get_user_records(SERVICE, EMAIL))
        self.assertEquals(len(records), 0)
    def test_delete_user_by_legacy_uid_format(self):
        self.backend.allocate_user(SERVICE, EMAIL)
        user = self.backend.get_user(SERVICE, EMAIL)
        self.backend.update_user(SERVICE, user, client_state="abcdef")
        records = list(self.backend.get_user_records(SERVICE, EMAIL))
        self.assertEquals(len(records), 2)
        self.assertTrue(records[0]["replaced_at"] is not None)

        process_account_event(self.config, message_body(
            event="delete",
            uid=EMAIL,
        ))

        records = list(self.backend.get_user_records(SERVICE, EMAIL))
        self.assertEquals(len(records), 2)
        for row in records:
            self.assertTrue(row["replaced_at"] is not None)
Example #14
0
    def test_delete_user_by_legacy_uid_format(self):
        self.backend.allocate_user(SERVICE, EMAIL)
        user = self.backend.get_user(SERVICE, EMAIL)
        self.backend.update_user(SERVICE, user, client_state="abcdef")
        records = list(self.backend.get_user_records(SERVICE, EMAIL))
        self.assertEquals(len(records), 2)
        self.assertTrue(records[0]["replaced_at"] is not None)

        process_account_event(self.config,
                              message_body(
                                  event="delete",
                                  uid=EMAIL,
                              ))

        records = list(self.backend.get_user_records(SERVICE, EMAIL))
        self.assertEquals(len(records), 2)
        for row in records:
            self.assertTrue(row["replaced_at"] is not None)
    def test_malformed_events(self):

        # Unknown event type.
        process_account_event(self.config, message_body(
            event="party",
            uid=UID,
            iss=ISS,
            generation=43,
        ))
        self.assertMessageWasLogged("Dropping unknown event type")
        self.clearLogs()

        # Missing event type.
        process_account_event(self.config, message_body(
            uid=UID,
            iss=ISS,
            generation=43,
        ))
        self.assertMessageWasLogged("Invalid account message")
        self.clearLogs()

        # Missing uid.
        process_account_event(self.config, message_body(
            event="delete",
            iss=ISS,
        ))
        self.assertMessageWasLogged("Invalid account message")
        self.clearLogs()

        # Missing generation for reset events.
        process_account_event(self.config, message_body(
            event="reset",
            uid=UID,
            iss=ISS,
        ))
        self.assertMessageWasLogged("Invalid account message")
        self.clearLogs()

        # Missing generation for passwordChange events.
        process_account_event(self.config, message_body(
            event="passwordChange",
            uid=UID,
            iss=ISS,
        ))
        self.assertMessageWasLogged("Invalid account message")
        self.clearLogs()

        # Missing issuer with nonemail uid
        process_account_event(self.config, message_body(
            event="delete",
            uid=UID,
        ))
        self.assertMessageWasLogged("Invalid account message")
        self.clearLogs()

        # Non-JSON garbage.
        process_account_event(self.config, "wat")
        self.assertMessageWasLogged("Invalid account message")
        self.clearLogs()

        # Non-JSON garbage in Message field.
        process_account_event(self.config, '{ "Message": "wat" }')
        self.assertMessageWasLogged("Invalid account message")
        self.clearLogs()

        # Badly-typed JSON value in Message field.
        process_account_event(self.config, '{ "Message": "[1, 2, 3"] }')
        self.assertMessageWasLogged("Invalid account message")
        self.clearLogs()
Example #16
0
    def test_malformed_events(self):
        EMAIL = "*****@*****.**"

        # Unknown event type.
        process_account_event(
            self.config, message_body(
                event="party",
                uid=EMAIL,
                generation=43,
            ))
        self.assertMessageWasLogged("Dropping unknown event type")
        self.clearLogs()

        # Missing event type.
        process_account_event(self.config,
                              message_body(
                                  uid=EMAIL,
                                  generation=43,
                              ))
        self.assertMessageWasLogged("Invalid account message")
        self.clearLogs()

        # Missing uid.
        process_account_event(self.config, message_body(event="delete", ))
        self.assertMessageWasLogged("Invalid account message")
        self.clearLogs()

        # Missing generation for reset events.
        process_account_event(self.config,
                              message_body(
                                  event="reset",
                                  uid=EMAIL,
                              ))
        self.assertMessageWasLogged("Invalid account message")
        self.clearLogs()

        # Non-JSON garbage.
        process_account_event(self.config, "wat")
        self.assertMessageWasLogged("Invalid account message")
        self.clearLogs()

        # Non-JSON garbage in Message field.
        process_account_event(self.config, '{ "Message": "wat" }')
        self.assertMessageWasLogged("Invalid account message")
        self.clearLogs()

        # Badly-typed JSON value in Message field.
        process_account_event(self.config, '{ "Message": "[1, 2, 3"] }')
        self.assertMessageWasLogged("Invalid account message")
        self.clearLogs()
    def test_malformed_events(self):
        EMAIL = "*****@*****.**"

        # Unknown event type.
        process_account_event(self.config, message_body(
            event="party",
            uid=EMAIL,
            generation=43,
        ))
        self.assertMessageWasLogged("Dropping unknown event type")
        self.clearLogs()

        # Missing event type.
        process_account_event(self.config, message_body(
            uid=EMAIL,
            generation=43,
        ))
        self.assertMessageWasLogged("Invalid account message")
        self.clearLogs()

        # Missing uid.
        process_account_event(self.config, message_body(
            event="delete",
        ))
        self.assertMessageWasLogged("Invalid account message")
        self.clearLogs()

        # Missing generation for reset events.
        process_account_event(self.config, message_body(
            event="reset",
            uid=EMAIL,
        ))
        self.assertMessageWasLogged("Invalid account message")
        self.clearLogs()

        # Non-JSON garbage.
        process_account_event(self.config, "wat")
        self.assertMessageWasLogged("Invalid account message")
        self.clearLogs()

        # Non-JSON garbage in Message field.
        process_account_event(self.config, '{ "Message": "wat" }')
        self.assertMessageWasLogged("Invalid account message")
        self.clearLogs()

        # Badly-typed JSON value in Message field.
        process_account_event(self.config, '{ "Message": "[1, 2, 3"] }')
        self.assertMessageWasLogged("Invalid account message")
        self.clearLogs()
Example #18
0
    def test_malformed_events(self):

        # Unknown event type.
        process_account_event(
            self.config,
            message_body(
                event="party",
                uid=UID,
                iss=ISS,
                generation=43,
            ))
        self.assertMessageWasLogged("Dropping unknown event type")
        self.clearLogs()

        # Missing event type.
        process_account_event(self.config,
                              message_body(
                                  uid=UID,
                                  iss=ISS,
                                  generation=43,
                              ))
        self.assertMessageWasLogged("Invalid account message")
        self.clearLogs()

        # Missing uid.
        process_account_event(self.config,
                              message_body(
                                  event="delete",
                                  iss=ISS,
                              ))
        self.assertMessageWasLogged("Invalid account message")
        self.clearLogs()

        # Missing generation for reset events.
        process_account_event(self.config,
                              message_body(
                                  event="reset",
                                  uid=UID,
                                  iss=ISS,
                              ))
        self.assertMessageWasLogged("Invalid account message")
        self.clearLogs()

        # Missing generation for passwordChange events.
        process_account_event(
            self.config,
            message_body(
                event="passwordChange",
                uid=UID,
                iss=ISS,
            ))
        self.assertMessageWasLogged("Invalid account message")
        self.clearLogs()

        # Missing issuer with nonemail uid
        process_account_event(self.config,
                              message_body(
                                  event="delete",
                                  uid=UID,
                              ))
        self.assertMessageWasLogged("Invalid account message")
        self.clearLogs()

        # Non-JSON garbage.
        process_account_event(self.config, "wat")
        self.assertMessageWasLogged("Invalid account message")
        self.clearLogs()

        # Non-JSON garbage in Message field.
        process_account_event(self.config, '{ "Message": "wat" }')
        self.assertMessageWasLogged("Invalid account message")
        self.clearLogs()

        # Badly-typed JSON value in Message field.
        process_account_event(self.config, '{ "Message": "[1, 2, 3"] }')
        self.assertMessageWasLogged("Invalid account message")
        self.clearLogs()