示例#1
0
    def test_invalid_signature(self):
        data = {'ext_url': 'https://https.cio.gov',
                'signature': 'obviouslywrong'}

        form = ExternalURLForm(data)

        self.assertFalse(form.is_valid())
示例#2
0
    def test_unicode_url(self):
        url = 'https://cfpb.gov/protecci\xf3n'
        _, signature = sign_url(url)
        data = {'ext_url': url, 'signature': signature}

        with override_settings(EXTERNAL_URL_WHITELIST=(url, )):
            form = ExternalURLForm(data)
            self.assertTrue(form.is_valid())
示例#3
0
    def test_invalid_signature(self):

        data = {'ext_url': 'https://https.cio.gov',
                'signature': 'obviouslywrong'}

        form = ExternalURLForm(data)

        self.assertFalse(form.is_valid())
示例#4
0
    def test_unicode_url(self):
        url = 'https://cfpb.gov/protecci\xf3n'
        _, signature = sign_url(url)
        data = {'ext_url': url, 'signature': signature}

        with override_settings(EXTERNAL_URL_WHITELIST=(url,)):
            form = ExternalURLForm(data)
            self.assertTrue(form.is_valid())
示例#5
0
    def test_valid_signature(self):
        url = 'https://https.cio.gov/'
        _, signature = sign_url(url)

        data = {'ext_url': url, 'signature': signature}

        form = ExternalURLForm(data)

        self.assertTrue(form.is_valid())
示例#6
0
    def test_valid_signature(self):
        url = 'https://https.cio.gov/'
        _, signature = sign_url(url)

        data = {'ext_url': url,
                'signature': signature}

        form = ExternalURLForm(data)

        self.assertTrue(form.is_valid())
示例#7
0
 def test_no_signature_fails_validation(self):
     data = {'ext_url': 'https://not.whitelisted.gov'}
     form = ExternalURLForm(data)
     self.assertFalse(form.is_valid())
示例#8
0
 def test_invalid_url_fails_validation(self):
     data = {'ext_url': 'foo'}
     form = ExternalURLForm(data)
     self.assertFalse(form.is_valid())
示例#9
0
    def test_url_not_in_whitelist(self):
        data = {'ext_url': 'https://google.com'}
        form = ExternalURLForm(data)

        self.assertFalse(form.is_valid())
示例#10
0
    def test_whitelisted_url(self):
        data = {'ext_url': 'https://facebook.com/cfpb'}
        form = ExternalURLForm(data)

        self.assertTrue(form.is_valid())
示例#11
0
    def test_url_not_in_whitelist(self):
        data = {'ext_url': 'http://google.com'}
        form = ExternalURLForm(data)

        self.assertFalse(form.is_valid())
示例#12
0
    def test_whitelisted_url(self):
        data = {'ext_url': 'https://facebook.com/cfpb'}
        form = ExternalURLForm(data)

        self.assertTrue(form.is_valid())
示例#13
0
 def test_no_signature_fails_validation(self):
     data = {'ext_url': 'https://not.whitelisted.gov'}
     form = ExternalURLForm(data)
     self.assertFalse(form.is_valid())
示例#14
0
 def test_invalid_url_fails_validation(self):
     data = {'ext_url': 'foo'}
     form = ExternalURLForm(data)
     self.assertFalse(form.is_valid())