1 # All rights reserved. This program and the accompanying materials
2 # are made available under the terms of the Apache License, Version 2.0
3 # which accompanies this distribution, and is available at
4 # http://www.apache.org/licenses/LICENSE-2.0
9 from tornado import web
11 from opnfv_testapi.common import message
12 from opnfv_testapi.tests.unit import executor
13 from opnfv_testapi.tests.unit import fake_pymongo
14 from opnfv_testapi.tests.unit.handlers import test_result
17 class TestTokenCreateResult(test_result.TestResultBase):
19 from opnfv_testapi.router import url_mappings
20 return web.Application(
21 url_mappings.mappings,
28 super(TestTokenCreateResult, self).setUp()
29 fake_pymongo.tokens.insert({"access_token": "12345"})
31 @executor.create(httplib.FORBIDDEN, message.invalid_token())
32 def test_resultCreateTokenInvalid(self):
33 self.headers['X-Auth-Token'] = '1234'
36 @executor.create(httplib.UNAUTHORIZED, message.unauthorized())
37 def test_resultCreateTokenUnauthorized(self):
38 if 'X-Auth-Token' in self.headers:
39 self.headers.pop('X-Auth-Token')
42 @executor.create(httplib.OK, '_create_success')
43 def test_resultCreateTokenSuccess(self):
44 self.headers['X-Auth-Token'] = '12345'
47 def _create_success(self, body):
48 self.assertIn('CreateResponse', str(type(body)))
51 if __name__ == '__main__':