Checked in dev. Tests amended.
Details
Details
Diff Detail
Diff Detail
- Repository
- rLTRN libtaskotron
- Lint
Automatic diff as part of commit; lint not applicable. - Unit
Automatic diff as part of commit; unit tests not applicable.
Checked in dev. Tests amended.
Automatic diff as part of commit; lint not applicable. |
Automatic diff as part of commit; unit tests not applicable. |
Path | Packages | |||
---|---|---|---|---|
M | libtaskotron/directives/resultsdb_directive.py (10 lines) | |||
M | testing/test_resultsdb_directive.py (2 lines) |
Commit | Tree | Parents | Author | Summary | Date |
---|---|---|---|---|---|
e0e8db4695e6 | cd6a2d3c1976 | e72031d0b802 | Martin Krizek | namespaces: fix checking task repo url for prefix (Show More…) | Apr 20 2016, 1:12 PM |
Show First 20 Lines • Show All 180 Lines • ▼ Show 20 Line(s) | 180 | elif not artifact_path.startswith(artifactsdir): | |||
---|---|---|---|---|---|
181 | log.warn('Artifact %r is placed outside of artifacts directory %r, ignoring', | 181 | log.warn('Artifact %r is placed outside of artifacts directory %r, ignoring', | ||
182 | artifact_path, artifactsdir) | 182 | artifact_path, artifactsdir) | ||
183 | return None | 183 | return None | ||
184 | 184 | | |||
185 | return os.path.relpath(artifact_path, start=artifactsdir) | 185 | return os.path.relpath(artifact_path, start=artifactsdir) | ||
186 | 186 | | |||
187 | def check_namespace(self, checkname, arg_data): | 187 | def check_namespace(self, checkname, arg_data): | ||
188 | conf_ns = config.load_namespaces_config() | 188 | conf_ns = config.load_namespaces_config() | ||
189 | repos = None | 189 | ns_repos = None | ||
190 | 190 | | |||
191 | # check if the namespace exists | 191 | # check if the namespace exists | ||
192 | for ns in conf_ns['namespaces_safe']: | 192 | for ns in conf_ns['namespaces_safe']: | ||
193 | if checkname.startswith(ns+'.'): | 193 | if checkname.startswith(ns+'.'): | ||
194 | log.debug('Namespace %s found in the safe namespaces.', ns) | 194 | log.debug('Namespace %s found in the safe namespaces.', ns) | ||
195 | return | 195 | return | ||
196 | else: | 196 | else: | ||
197 | for ns, rs in conf_ns['namespaces_whitelist'].iteritems(): | 197 | for ns, rs in conf_ns['namespaces_whitelist'].iteritems(): | ||
198 | if checkname.startswith(ns+'.'): | 198 | if checkname.startswith(ns+'.'): | ||
199 | log.debug('Namespace %s found in the namespace whitelist.', ns) | 199 | log.debug('Namespace %s found in the namespace whitelist.', ns) | ||
200 | repos = rs | 200 | ns_repos = rs | ||
201 | break | 201 | break | ||
202 | else: | 202 | else: | ||
203 | raise TaskotronDirectiveError('Namespace %s does not exist.') | 203 | raise TaskotronDirectiveError('Namespace %s does not exist.') | ||
204 | 204 | | |||
205 | try: | 205 | try: | ||
206 | taskdir = os.path.dirname(os.path.abspath(arg_data['task'])) | 206 | taskdir = os.path.dirname(os.path.abspath(arg_data['task'])) | ||
207 | gitconfig_filename = os.path.join(taskdir, '.git/config') | 207 | gitconfig_filename = os.path.join(taskdir, '.git/config') | ||
208 | 208 | | |||
209 | gitconfig = configparser.ConfigParser() | 209 | gitconfig = configparser.ConfigParser() | ||
210 | gitconfig.read(gitconfig_filename) | 210 | gitconfig.read(gitconfig_filename) | ||
211 | repo_url = gitconfig['remote "origin"']['url'] | 211 | task_repo_url = gitconfig['remote "origin"']['url'] | ||
212 | except TypeError, e: | 212 | except TypeError, e: | ||
213 | log.exception(e) | 213 | log.exception(e) | ||
214 | raise TaskotronDirectiveError("Could not find task's git remote 'origin' url" | 214 | raise TaskotronDirectiveError("Could not find task's git remote 'origin' url" | ||
215 | "in %s" % gitconfig_filename) | 215 | "in %s" % gitconfig_filename) | ||
216 | 216 | | |||
217 | try: | 217 | try: | ||
218 | if not [repo for repo in repos if repo.startswith(repo_url.strip())]: | 218 | if not [ns_repo for ns_repo in ns_repos if task_repo_url.strip().startswith(ns_repo)]: | ||
219 | raise TaskotronDirectiveError | 219 | raise TaskotronDirectiveError | ||
220 | 220 | | |||
221 | log.debug('Repo %s found in the whitelist', repo_url) | 221 | log.debug('Repo %s found in the whitelist', task_repo_url) | ||
222 | # dist-git style tasks | 222 | # dist-git style tasks | ||
223 | # here we need to not only check the root namespace but also second level ns, | 223 | # here we need to not only check the root namespace but also second level ns, | ||
224 | # e.g. a firefox check can post results into pkg.firefox | 224 | # e.g. a firefox check can post results into pkg.firefox | ||
225 | if checkname.startswith('pkg.'): | 225 | if checkname.startswith('pkg.'): | ||
226 | pkg_name = rpm_utils.rpmformat(arg_data['item'], fmt='n') | 226 | pkg_name = rpm_utils.rpmformat(arg_data['item'], fmt='n') | ||
227 | pkg_ns = 'pkg.%s.' % pkg_name | 227 | pkg_ns = 'pkg.%s.' % pkg_name | ||
228 | if not checkname.startswith(pkg_ns): | 228 | if not checkname.startswith(pkg_ns): | ||
229 | raise TaskotronDirectiveError | 229 | raise TaskotronDirectiveError | ||
▲ Show 20 Lines • Show All 79 Lines • Show Last 20 Lines |
Show All 19 Lines | |||||
20 | from resultsdb_api import ResultsDBapiException | 20 | from resultsdb_api import ResultsDBapiException | ||
21 | 21 | | |||
22 | 22 | | |||
23 | class StubConfigParser(object): | 23 | class StubConfigParser(object): | ||
24 | def read(self, *args): | 24 | def read(self, *args): | ||
25 | pass | 25 | pass | ||
26 | 26 | | |||
27 | def __getitem__(self, key): | 27 | def __getitem__(self, key): | ||
28 | return {'url': 'giturl'} | 28 | return {'url': 'giturl/testname'} | ||
29 | 29 | | |||
30 | 30 | | |||
31 | @pytest.mark.usefixtures('setup') | 31 | @pytest.mark.usefixtures('setup') | ||
32 | class TestResultsdbReport(): | 32 | class TestResultsdbReport(): | ||
33 | 33 | | |||
34 | @pytest.fixture | 34 | @pytest.fixture | ||
35 | def setup(self, monkeypatch): | 35 | def setup(self, monkeypatch): | ||
36 | '''Run this before every test invocation''' | 36 | '''Run this before every test invocation''' | ||
▲ Show 20 Lines • Show All 343 Lines • Show Last 20 Lines |