• Home
  • Features
  • Pricing
  • Docs
  • Announcements
  • Sign In

mozilla / mozregression / 10832265171

12 Sep 2024 01:52PM CUT coverage: 89.37%. First build
10832265171

Pull #1813

github

web-flow
Merge 113a4c43b into c39e24675
Pull Request #1813: pyproject: fully migrate to pyproject.toml from setup.py (bug 1917431)

2497 of 2794 relevant lines covered (89.37%)

0.89 hits per line

Source File
Press 'n' to go to next uncovered line, 'b' for previous

23.81
/mozregression/tc_authenticate.py
1
from __future__ import absolute_import
1✔
2

3
import json
1✔
4

5
from taskcluster import utils as tc_utils
1✔
6

7
from mozregression.config import DEFAULT_CONF_FNAME, TC_CREDENTIALS_FNAME, get_config
1✔
8

9

10
def tc_authenticate(logger):
1✔
11
    """
12
    Returns valid credentials for use with Taskcluster private builds.
13
    """
14
    # first, try to load credentials from mozregression config file
15
    defaults = get_config(DEFAULT_CONF_FNAME)
×
16
    client_id = defaults.get("taskcluster-clientid")
×
17
    access_token = defaults.get("taskcluster-accesstoken")
×
18
    if client_id and access_token:
×
19
        return dict(clientId=client_id, accessToken=access_token)
×
20

21
    try:
×
22
        # else, try to load a valid certificate locally
23
        with open(TC_CREDENTIALS_FNAME) as f:
×
24
            creds = json.load(f)
×
25
        if not tc_utils.isExpired(creds["certificate"]):
×
26
            return creds
×
27
    except Exception:
×
28
        pass
29

30
    # here we need to ask for a certificate, this require web browser
31
    # authentication
32
    logger.info(
×
33
        "Authentication required from taskcluster. We are going to ask for a"
34
        " certificate.\nNote that if you have long term access you can instead"
35
        " set your taskcluster-clientid and taskcluster-accesstoken in the"
36
        " configuration file (%s)." % DEFAULT_CONF_FNAME
37
    )
38
    creds = tc_utils.authenticate("mozregression private build access")
×
39

40
    # save the credentials and the certificate for later use
41
    with open(TC_CREDENTIALS_FNAME, "w") as f:
×
42
        json.dump(creds, f)
×
43
    return creds
×
STATUS · Troubleshooting · Open an Issue · Sales · Support · CAREERS · ENTERPRISE · START FREE · SCHEDULE DEMO
ANNOUNCEMENTS · TWITTER · TOS & SLA · Supported CI Services · What's a CI service? · Automated Testing

© 2025 Coveralls, Inc