def setUp(self): super(TestNoAdminTokenAuth, self).setUp() self.load_backends() _generate_paste_config() self.admin_app = webtest.TestApp( self.loadapp(test.tmpdir('no_admin_token_auth'), name='admin'), extra_environ=dict(REMOTE_ADDR='127.0.0.1'))
def _generate_paste_config(): # Generate a file, based on keystone-paste.ini, that doesn't include # admin_token_auth in the pipeline with open(test.etcdir('keystone-paste.ini'), 'r') as f: contents = f.read() new_contents = contents.replace(' admin_token_auth ', ' ') with open(test.tmpdir('no_admin_token_auth-paste.ini'), 'w') as f: f.write(new_contents)
def setup_old_database(self, sql_dump): sql_path = test.testsdir(sql_dump) db_path = test.tmpdir("%s.db" % sql_dump) try: os.unlink(db_path) except OSError: pass script_str = open(sql_path).read().strip() conn = dbapi.connect(db_path) conn.executescript(script_str) conn.commit() return db_path
def setup_old_database(self, sql_dump): sql_path = test.testsdir(sql_dump) db_path = test.tmpdir('%s.db' % sql_dump) try: os.unlink(db_path) except OSError: pass script_str = open(sql_path).read().strip() conn = dbapi.connect(db_path) conn.executescript(script_str) conn.commit() return db_path
def tearDown(self): self.admin_app = None os.remove(test.tmpdir('no_admin_token_auth-paste.ini'))