コード例 #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)
コード例 #2
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)
コード例 #3
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)
コード例 #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)
コード例 #5
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)
コード例 #6
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)
コード例 #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)
コード例 #8
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)
コード例 #9
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)
コード例 #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)
コード例 #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)
コード例 #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)
コード例 #13
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)
コード例 #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)
コード例 #15
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()
コード例 #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()
コード例 #17
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()
コード例 #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()