Skip to content

Commit

Permalink
Update tests related to refactoring of short urls
Browse files Browse the repository at this point in the history
  • Loading branch information
evilaliv3 committed May 27, 2019
1 parent 638c499 commit a46ae18
Showing 1 changed file with 9 additions and 9 deletions.
18 changes: 9 additions & 9 deletions backend/globaleaks/tests/handlers/admin/test_api_token.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
from twisted.internet.defer import inlineCallbacks

from globaleaks import db
from globaleaks.handlers.admin import shorturl
from globaleaks.handlers.admin import redirect
from globaleaks.models.config import db_set_config_variable
from globaleaks.orm import tw
from globaleaks.rest import errors
Expand All @@ -11,7 +11,7 @@


class TestAPITokenEnabled(helpers.TestHandlerWithPopulatedDB):
_handler = shorturl.ShortURLCollection
_handler = redirect.RedirectCollection

@inlineCallbacks
def setUp(self):
Expand All @@ -22,14 +22,14 @@ def setUp(self):

@inlineCallbacks
def test_accept_token(self):
shorturl_desc = self.get_dummy_shorturl()
handler = self.request(shorturl_desc, headers={'x-api-token': self.api_tok})
desc = self.get_dummy_redirect()
handler = self.request(desc, headers={'x-api-token': self.api_tok})
yield handler.post()

@inlineCallbacks
def test_deny_token(self):
shorturl_desc = self.get_dummy_shorturl()
handler = self.request(shorturl_desc, headers={'x-api-token': 'a'*32})
desc = self.get_dummy_redirect()
handler = self.request(desc, headers={'x-api-token': 'a'*32})
yield self.assertRaises(errors.NotAuthenticated, handler.post)

@inlineCallbacks
Expand All @@ -39,7 +39,7 @@ def tearDown(self):


class TestAPITokenDisabled(helpers.TestHandlerWithPopulatedDB):
_handler = shorturl.ShortURLCollection
_handler = redirect.RedirectCollection

@inlineCallbacks
def test_deny_token(self):
Expand All @@ -48,8 +48,8 @@ def test_deny_token(self):
self.api_tok, digest = generateApiToken()
yield tw(db_set_config_variable, 1, 'admin_api_token_digest', '')

shorturl_desc = self.get_dummy_shorturl()
handler = self.request(shorturl_desc, headers={'x-api-token': self.api_tok})
desc = self.get_dummy_redirect()
handler = self.request(desc, headers={'x-api-token': self.api_tok})
yield self.assertRaises(errors.NotAuthenticated, handler.post)

@inlineCallbacks
Expand Down

0 comments on commit a46ae18

Please sign in to comment.