Lines Matching refs:self
64 def __init__(self, env: Env, proxy_auth: bool = False): argument
65 self.env = env
66 self._cmd = env.apachectl
67 self._apache_dir = os.path.join(env.gen_dir, 'apache')
68 self._run_dir = os.path.join(self._apache_dir, 'run')
69 self._lock_dir = os.path.join(self._apache_dir, 'locks')
70 self._docs_dir = os.path.join(self._apache_dir, 'docs')
71 self._conf_dir = os.path.join(self._apache_dir, 'conf')
72 self._conf_file = os.path.join(self._conf_dir, 'test.conf')
73 self._logs_dir = os.path.join(self._apache_dir, 'logs')
74 self._error_log = os.path.join(self._logs_dir, 'error_log')
75 self._tmp_dir = os.path.join(self._apache_dir, 'tmp')
76 self._basic_passwords = os.path.join(self._conf_dir, 'basic.passwords')
77 self._digest_passwords = os.path.join(self._conf_dir, 'digest.passwords')
78 self._mods_dir = None
79 self._auth_digest = True
80 self._proxy_auth_basic = proxy_auth
81 self._extra_configs = {}
82 self._loaded_extra_configs = None
88 self._mods_dir = p.stdout.strip()
89 if self._mods_dir is None:
91 if not os.path.exists(self._mods_dir):
93 self._process = None
94 self._rmf(self._error_log)
95 self._init_curltest()
98 def docs_dir(self): argument
99 return self._docs_dir
101 def clear_logs(self): argument
102 self._rmf(self._error_log)
104 def exists(self): argument
105 return os.path.exists(self._cmd)
107 def set_extra_config(self, domain: str, lines: Optional[Union[str, List[str]]]): argument
109 self._extra_configs.pop(domain, None)
111 self._extra_configs[domain] = lines
113 def clear_extra_configs(self): argument
114 self._extra_configs = {}
116 def set_proxy_auth(self, active: bool): argument
117 self._proxy_auth_basic = active
119 def _run(self, args, intext=''): argument
121 env['APACHE_RUN_DIR'] = self._run_dir
123 env['APACHE_LOCK_DIR'] = self._lock_dir
124 env['APACHE_CONFDIR'] = self._apache_dir
126 cwd=self.env.gen_dir,
135 def _apachectl(self, cmd: str): argument
136 args = [self.env.apachectl,
137 "-d", self._apache_dir,
138 "-f", self._conf_file,
140 return self._run(args=args)
142 def start(self): argument
143 if self._process:
144 self.stop()
145 self._write_config()
146 with open(self._error_log, 'a') as fd:
148 with open(os.path.join(self._apache_dir, 'xxx'), 'a') as fd:
150 r = self._apachectl('start')
154 self._loaded_extra_configs = copy.deepcopy(self._extra_configs)
155 return self.wait_live(timeout=timedelta(seconds=5))
157 def stop(self): argument
158 r = self._apachectl('stop')
159 self._loaded_extra_configs = None
161 return self.wait_dead(timeout=timedelta(seconds=5))
165 def restart(self): argument
166 self.stop()
167 return self.start()
169 def reload(self): argument
170 self._write_config()
171 r = self._apachectl("graceful")
172 self._loaded_extra_configs = None
175 self._loaded_extra_configs = copy.deepcopy(self._extra_configs)
176 return self.wait_live(timeout=timedelta(seconds=5))
178 def reload_if_config_changed(self): argument
179 if self._loaded_extra_configs == self._extra_configs:
181 return self.reload()
183 def wait_dead(self, timeout: timedelta): argument
184 curl = CurlClient(env=self.env, run_dir=self._tmp_dir)
194 def wait_live(self, timeout: timedelta): argument
195 curl = CurlClient(env=self.env, run_dir=self._tmp_dir,
206 def _rmf(self, path): argument
210 def _mkpath(self, path): argument
214 def _write_config(self): argument
215 domain1 = self.env.domain1
216 domain1brotli = self.env.domain1brotli
217 creds1 = self.env.get_credentials(domain1)
219 domain2 = self.env.domain2
220 creds2 = self.env.get_credentials(domain2)
222 proxy_domain = self.env.proxy_domain
223 proxy_creds = self.env.get_credentials(proxy_domain)
225 self._mkpath(self._conf_dir)
226 self._mkpath(self._logs_dir)
227 self._mkpath(self._tmp_dir)
228 self._mkpath(os.path.join(self._docs_dir, 'two'))
229 with open(os.path.join(self._docs_dir, 'data.json'), 'w') as fd:
234 with open(os.path.join(self._docs_dir, 'two/data.json'), 'w') as fd:
239 if self._proxy_auth_basic:
240 with open(self._basic_passwords, 'w') as fd:
242 if self._auth_digest:
243 with open(self._digest_passwords, 'w') as fd:
245 self._mkpath(os.path.join(self.docs_dir, 'restricted/digest'))
246 with open(os.path.join(self.docs_dir, 'restricted/digest/data.json'), 'w') as fd:
248 with open(self._conf_file, 'w') as fd:
249 for m in self.MODULES:
250 if os.path.exists(os.path.join(self._mods_dir, f'mod_{m}.so')):
271 if 'base' in self._extra_configs:
272 conf.extend(self._extra_configs['base'])
281 conf.extend(self._curltest_conf(domain1))
296 conf.extend(self._curltest_conf(domain1))
297 if domain1 in self._extra_configs:
298 conf.extend(self._extra_configs[domain1])
314 conf.extend(self._curltest_conf(domain1))
315 if domain1 in self._extra_configs:
316 conf.extend(self._extra_configs[domain1])
328 conf.extend(self._curltest_conf(domain2))
342 conf.extend(self._curltest_conf(domain2))
343 if domain2 in self._extra_configs:
344 conf.extend(self._extra_configs[domain2])
358 conf.extend(self._get_proxy_conf())
375 conf.extend(self._get_proxy_conf())
382 with open(os.path.join(self._conf_dir, 'mime.types'), 'w') as fd:
389 def _get_proxy_conf(self): argument
390 if self._proxy_auth_basic:
407 def _get_log_level(self): argument
408 if self.env.verbose > 3:
410 if self.env.verbose > 2:
412 if self.env.verbose > 1:
416 def _curltest_conf(self, servername) -> List[str]: argument
448 if self._auth_digest:
462 def _init_curltest(self): argument
466 p = subprocess.run([self.env.apxs, '-c', 'mod_curltest.c'],