def testGenerateAndValidateToken(self):
        token = xsrfutil.generate_token(TEST_KEY,
                                        TEST_USER_ID_1,
                                        action_id=TEST_ACTION_ID_1,
                                        when=TEST_TIME)

        # Check that the token is considered valid when it should be.
        self.assertTrue(xsrfutil.validate_token(TEST_KEY,
                                                token,
                                                TEST_USER_ID_1,
                                                action_id=TEST_ACTION_ID_1,
                                                current_time=TEST_TIME))

        # Should still be valid 15 minutes later.
        later15mins = TEST_TIME + 15 * 60
        self.assertTrue(xsrfutil.validate_token(TEST_KEY,
                                                token,
                                                TEST_USER_ID_1,
                                                action_id=TEST_ACTION_ID_1,
                                                current_time=later15mins))

        # But not if beyond the timeout.
        later2hours = TEST_TIME + 2 * 60 * 60
        self.assertFalse(xsrfutil.validate_token(TEST_KEY,
                                                 token,
                                                 TEST_USER_ID_1,
                                                 action_id=TEST_ACTION_ID_1,
                                                 current_time=later2hours))

        # Or if the key is different.
        self.assertFalse(xsrfutil.validate_token('another key',
                                                 token,
                                                 TEST_USER_ID_1,
                                                 action_id=TEST_ACTION_ID_1,
                                                 current_time=later15mins))

        # Or the user ID....
        self.assertFalse(xsrfutil.validate_token(TEST_KEY,
                                                 token,
                                                 TEST_USER_ID_2,
                                                 action_id=TEST_ACTION_ID_1,
                                                 current_time=later15mins))

        # Or the action ID...
        self.assertFalse(xsrfutil.validate_token(TEST_KEY,
                                                 token,
                                                 TEST_USER_ID_1,
                                                 action_id=TEST_ACTION_ID_2,
                                                 current_time=later15mins))

        # Invalid when truncated
        self.assertFalse(xsrfutil.validate_token(TEST_KEY,
                                                 token[:-1],
                                                 TEST_USER_ID_1,
                                                 action_id=TEST_ACTION_ID_1,
                                                 current_time=later15mins))

        # Invalid with extra garbage
        self.assertFalse(xsrfutil.validate_token(TEST_KEY,
                                                 token + b'x',
                                                 TEST_USER_ID_1,
                                                 action_id=TEST_ACTION_ID_1,
                                                 current_time=later15mins))

        # Invalid with token of None
        self.assertFalse(xsrfutil.validate_token(TEST_KEY,
                                                 None,
                                                 TEST_USER_ID_1,
                                                 action_id=TEST_ACTION_ID_1))
Remove this Node:  no-op by default.
dataset/ETHPy150Open google/oauth2client/tests/contrib/test_xsrfutil.py/XsrfUtilTests.testGenerateAndValidateToken--crossover with--dataset/ETHPy150Open kayhayen/Nuitka/nuitka/build/inline_copy/lib/scons-2.3.2/SCons/Node/__init__.py/Node.remove