Exemple #1
0
    def test_is_valid_timestamp_invalid(self):
        """Should consider timestamps invalid if they're before Discord epoch or can't be parsed."""
        timestamps = (
            ("B4Yffw", "DISCORD_EPOCH - TOKEN_EPOCH - 1"),
            ("ew", "123"),
            ("AoIKgA", "42076800"),
            ("{hello}[world]&(bye!)", "ASCII invalid Base64"),
            ("Þíß-ï§-ňøẗ-våłìÐ", "Unicode invalid Base64"),
        )

        for timestamp, msg in timestamps:
            with self.subTest(msg=msg):
                result = TokenRemover.is_valid_timestamp(timestamp)
                self.assertFalse(result)
Exemple #2
0
    def test_is_valid_timestamp_valid(self):
        """Should consider timestamps valid if they're greater than the Discord epoch."""
        timestamps = (
            "XsyRkw",
            "Xrim9Q",
            "XsyR-w",
            "XsySD_",
            "Dn9r_A",
        )

        for timestamp in timestamps:
            with self.subTest(timestamp=timestamp):
                result = TokenRemover.is_valid_timestamp(timestamp)
                self.assertTrue(result)
 def test_is_valid_timestamp_is_true_for_valid_timestamps(self):
     """A string decoding to a valid timestamp should be recognized as such."""
     self.assertTrue(TokenRemover.is_valid_timestamp('DN9r_A'))
 def test_is_valid_timestamp_is_false_for_invalid_values(self):
     """A string not decoding to a valid timestamp should not be recognized as such."""
     # MTIz = base64(123)
     self.assertFalse(TokenRemover.is_valid_timestamp('MTIz'))
Exemple #5
0
def test_is_valid_timestamp(content: str, expected: bool):
    assert TokenRemover.is_valid_timestamp(content) is expected