예제 #1
0
    def test_clean_input(self):
        # Test Bad Data
        with snappass.app.test_request_context("/",
                                               data={
                                                   'password': '******',
                                                   'ttl': 'bar'
                                               },
                                               method='POST'):
            self.assertRaises(BadRequest, snappass.clean_input)

        # No Password
        with snappass.app.test_request_context("/", method='POST'):
            self.assertRaises(BadRequest, snappass.clean_input)

        # No TTL
        with snappass.app.test_request_context("/",
                                               data={'password': '******'},
                                               method='POST'):
            self.assertRaises(BadRequest, snappass.clean_input)

        with snappass.app.test_request_context("/",
                                               data={
                                                   'password': '******',
                                                   'ttl': 'hour'
                                               },
                                               method='POST'):
            self.assertEqual((3600, 'foo'), snappass.clean_input())
예제 #2
0
    def test_clean_input(self):
        # Test Bad Data
        with snappass.app.test_request_context(
                "/", data={'password': '******', 'ttl': 'bar'}, method='POST'):
            self.assertRaises(ClientDisconnected, snappass.clean_input)

        # No Password
        with snappass.app.test_request_context(
                "/", method='POST'):
            self.assertRaises(ClientDisconnected, snappass.clean_input)

        # No TTL
        with snappass.app.test_request_context(
                "/", data={'password': '******'}, method='POST'):
            self.assertRaises(ClientDisconnected, snappass.clean_input)

        with snappass.app.test_request_context(
                "/", data={'password': '******', 'ttl': 'hour'}, method='POST'):
            self.assertEqual((3600, 'foo'), snappass.clean_input())