Permalink
Browse files

Add alexa verification

  • Loading branch information...
nkuttler committed Mar 25, 2013
1 parent c1fa75f commit 0f9d1d95f1670356f13a4314eeb9661dddbbbe2a
View
@@ -79,13 +79,18 @@ def _get_wv_config(self, key='default'):
'f0f0f0f0f0f0f0f0',
'1919191919191919',
),
+ 'alexa': (
+ '1234567890abcdefABCDEF12345',
+ '12345abcdef1234567890ABCDEF',
+ ),
}
else:
conf = {
'bing': 'FFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFF',
'google': 'ffffffffffffffff',
'majestic': 'FFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFF',
'yandex': 'f0f0f0f0f0f0f0f0',
+ 'alexa': '12345abcdef1234567890ABCDEF',
}
return conf
@@ -0,0 +1,9 @@
+<html>
+ <head>
+ <meta name="alexaVerifyID" content="{{ alexa_verification }}" />
+ </head>
+ <body>
+ <p>Great! The file uploaded properly. Now click the 'Verify my file' button to
+ complete the process.</p>
+ </body>
+</html>
@@ -159,3 +159,43 @@ def test_yandex_file_404s(self):
# TODO look into refactoring this
def _get_yandex_url(self, code):
return '/yandex_%s.txt' % code
+
+ # TODO look into refactoring this
+ def test_alexa_file_acces(self):
+ if 'alexa' in settings.WEBMASTER_VERIFICATION:
+ codes = settings.WEBMASTER_VERIFICATION['alexa']
+ if type(codes) == tuple:
+ for code in codes:
+ self._test_alexa_file_access(code)
+ else:
+ self._test_alexa_file_access(codes)
+
+ # TODO look into refactoring this
+ def _test_alexa_file_access(self, code):
+ url = self._get_alexa_url(code)
+ r = self.client.get(url)
+ self.assertEqual(
+ r.status_code,
+ 200,
+ "Couldn't access %s, got %d" % (url, r.status_code)
+ )
+
+ # TODO look into refactoring this
+ def test_alexa_file_404s(self):
+ bad_codes = (
+ '',
+ '012345678',
+ '0123456789ABCDEF0123456789ABCDEF',
+ )
+ for code in bad_codes:
+ url = self._get_alexa_url(code)
+ r = self.client.get(url)
+ self.assertEqual(
+ r.status_code,
+ 404,
+ "Could access %s for inexistent code, got %d" % (url, r.status_code)
+ )
+
+ # TODO look into refactoring this
+ def _get_alexa_url(self, code):
+ return '/%s.html' % code
@@ -4,6 +4,7 @@
from .views import BingVerificationView
from .views import MajesticVerificationView
from .views import YandexVerificationView
+from .views import AlexaVerificationView
urlpatterns = patterns('',
@@ -27,4 +28,9 @@
YandexVerificationView.as_view(),
name = 'majestic_verify'
),
+ url(
+ r'^(?P<code>[0-9a-zA-Z]{27}).html$',
+ AlexaVerificationView.as_view(),
+ name = 'alexa_verify'
+ ),
)
@@ -86,3 +86,8 @@ class MajesticVerificationView(MimeTextMixin, FileAccessMixin, VerificationView)
class YandexVerificationView(MimeTextMixin, FileAccessMixin, VerificationView):
template_name = 'webmaster_verification/yandex_verify_template.txt'
provider = 'yandex'
+
+
+class AlexaVerificationView(FileAccessMixin, VerificationView):
+ template_name = 'webmaster_verification/alexa_verify_template.html'
+ provider = 'alexa'

0 comments on commit 0f9d1d9

Please sign in to comment.