def setUp(self): """Creates a new app instance for every test case.""" super(MainTest, self).setUp() self.testbed.init_user_stub() self.source_ip = '192.168.0.1' self.app = webtest.TestApp( handlers_frontend.create_application(debug=True), extra_environ={'REMOTE_ADDR': self.source_ip}) self.auth_app = webtest.TestApp( auth.create_wsgi_application(debug=True), extra_environ={ 'REMOTE_ADDR': self.source_ip, 'SERVER_SOFTWARE': os.environ['SERVER_SOFTWARE'], }) full_access_group = config.settings().auth.full_access_group readonly_access_group = config.settings().auth.readonly_access_group auth.bootstrap_group( auth.ADMIN_GROUP, [auth.Identity(auth.IDENTITY_USER, '*****@*****.**')]) auth.bootstrap_group( readonly_access_group, [auth.Identity(auth.IDENTITY_USER, '*****@*****.**')]) auth.bootstrap_group( full_access_group, [auth.Identity(auth.IDENTITY_USER, '*****@*****.**')]) self.set_as_anonymous()
def setUp(self): super(AppTestBase, self).setUp() self.bot_version = None self.source_ip = '192.168.2.2' self.testbed.init_user_stub() self.testbed.init_search_stub() # By default requests in tests are coming from bot with fake IP. # WSGI app that implements auth REST API. self.auth_app = webtest.TestApp( auth.create_wsgi_application(debug=True), extra_environ={ 'REMOTE_ADDR': self.source_ip, 'SERVER_SOFTWARE': os.environ['SERVER_SOFTWARE'], }) # Note that auth.ADMIN_GROUP != acl.ADMINS_GROUP. auth.bootstrap_group( auth.ADMIN_GROUP, [auth.Identity(auth.IDENTITY_USER, '*****@*****.**')]) auth.bootstrap_group( acl.ADMINS_GROUP, [auth.Identity(auth.IDENTITY_USER, '*****@*****.**')]) auth.bootstrap_group( acl.PRIVILEGED_USERS_GROUP, [auth.Identity(auth.IDENTITY_USER, '*****@*****.**')]) auth.bootstrap_group( acl.USERS_GROUP, [auth.Identity(auth.IDENTITY_USER, '*****@*****.**')]) auth.bootstrap_group( acl.BOTS_GROUP, [auth.Identity(auth.IDENTITY_BOT, self.source_ip)]) self.mock(stats_framework, 'add_entry', self._parse_line)
def setUp(self): """Creates a new app instance for every test case.""" super(MainTest, self).setUp() self.testbed.init_user_stub() # When called during a taskqueue, the call to get_app_version() may fail so # pre-fetch it. version = utils.get_app_version() self.mock(utils, 'get_task_queue_host', lambda: version) self.source_ip = '192.168.0.1' self.app_frontend = webtest.TestApp( handlers_frontend.create_application(debug=True), extra_environ={'REMOTE_ADDR': self.source_ip}) # This is awkward but both the frontend and backend applications uses the # same template variables. template.reset() self.app_backend = webtest.TestApp( handlers_backend.create_application(debug=True), extra_environ={'REMOTE_ADDR': self.source_ip}) # Tasks are enqueued on the backend. self.app = self.app_backend self.auth_app = webtest.TestApp( auth.create_wsgi_application(debug=True), extra_environ={ 'REMOTE_ADDR': self.source_ip, 'SERVER_SOFTWARE': os.environ['SERVER_SOFTWARE'], }) full_access_group = config.settings().auth.full_access_group readonly_access_group = config.settings().auth.readonly_access_group auth.bootstrap_group( auth.ADMIN_GROUP, [auth.Identity(auth.IDENTITY_USER, '*****@*****.**')]) auth.bootstrap_group( readonly_access_group, [auth.Identity(auth.IDENTITY_USER, '*****@*****.**')]) auth.bootstrap_group( full_access_group, [auth.Identity(auth.IDENTITY_USER, '*****@*****.**')]) # TODO(maruel): Create a BOTS_GROUP. self.set_as_anonymous()
def setUp(self): super(AppTestBase, self).setUp() self.bot_version = None self.source_ip = '192.168.2.2' self.testbed.init_user_stub() gae_ts_mon.reset_for_unittest(disable=True) event_mon_metrics.initialize() # By default requests in tests are coming from bot with fake IP. # WSGI app that implements auth REST API. self.auth_app = webtest.TestApp( auth.create_wsgi_application(debug=True), extra_environ={ 'REMOTE_ADDR': self.source_ip, 'SERVER_SOFTWARE': os.environ['SERVER_SOFTWARE'], }) admins_group = 'test_admins_group' priv_users_group = 'test_priv_users_group' users_group = 'test_users_group' cfg = config_pb2.SettingsCfg(auth=config_pb2.AuthSettings( admins_group=admins_group, privileged_users_group=priv_users_group, users_group=users_group, )) self.mock(config, '_get_settings', lambda: ('test_rev', cfg)) utils.clear_cache(config.settings) # Note that auth.ADMIN_GROUP != admins_group. auth.bootstrap_group( auth.ADMIN_GROUP, [auth.Identity(auth.IDENTITY_USER, '*****@*****.**')]) auth.bootstrap_group( admins_group, [auth.Identity(auth.IDENTITY_USER, '*****@*****.**')]) auth.bootstrap_group( priv_users_group, [auth.Identity(auth.IDENTITY_USER, '*****@*****.**')]) auth.bootstrap_group( users_group, [auth.Identity(auth.IDENTITY_USER, '*****@*****.**')])
def setUp(self): """Creates a new app instance for every test case.""" super(MainTest, self).setUp() self.testbed.init_user_stub() # When called during a taskqueue, the call to get_app_version() may fail so # pre-fetch it. version = utils.get_app_version() self.mock(utils, 'get_task_queue_host', lambda: version) self.source_ip = '192.168.0.1' self.app_frontend = webtest.TestApp( handlers_frontend.create_application(debug=True), extra_environ={'REMOTE_ADDR': self.source_ip}) # This is awkward but both the frontend and backend applications uses the # same template variables. template.reset() self.app_backend = webtest.TestApp( handlers_backend.create_application(debug=True), extra_environ={'REMOTE_ADDR': self.source_ip}) # Tasks are enqueued on the backend. self.app = self.app_backend self.auth_app = webtest.TestApp( auth.create_wsgi_application(debug=True), extra_environ={ 'REMOTE_ADDR': self.source_ip, 'SERVER_SOFTWARE': os.environ['SERVER_SOFTWARE'], }) auth.bootstrap_group( auth.ADMIN_GROUP, [auth.Identity(auth.IDENTITY_USER, '*****@*****.**')]) auth.bootstrap_group( acl.READONLY_ACCESS_GROUP, [auth.Identity(auth.IDENTITY_USER, '*****@*****.**')]) auth.bootstrap_group( acl.FULL_ACCESS_GROUP, [auth.Identity(auth.IDENTITY_USER, '*****@*****.**')]) # TODO(maruel): Create a BOTS_GROUP. self.set_as_anonymous()