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

cisagov / gophish-tools / 4632624010

pending completion
4632624010

push

github

GitHub
Merge pull request #123 from cisagov/lineage/skeleton

141 of 473 branches covered (29.81%)

Branch coverage included in aggregate %.

9 of 24 new or added lines in 10 files covered. (37.5%)

223 existing lines in 5 files now uncovered.

298 of 1270 relevant lines covered (23.46%)

1.41 hits per line

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

17.39
/src/tools/connect.py
1
"""Module to create a Gophish API connection."""
2

3
# Third-Party Libraries
4
# No type stubs exist for gophish, so we add "type: ignore" to tell mypy to
5
# ignore this library
6
from gophish import Gophish  # type: ignore
6✔
7
from gophish.models import Error  # type: ignore
6✔
8
from requests.exceptions import ConnectionError, MissingSchema
6✔
9

10

11
def connect_api(api_key, server):
6✔
12
    """Create a Gophish API connection."""
UNCOV
13
    api = Gophish(api_key, host=server, verify=False)
×
14

15
    # Sets up connection and test that it works.
UNCOV
16
    try:
×
UNCOV
17
        api.campaigns.get()
×
18
        return api
×
19

20
    except Error as e:  # Bad API Key
×
UNCOV
21
        raise Exception(f"Error Connecting: {e.message}")
×
22
    except MissingSchema as e:
×
23
        message = e.args[0].split(" '")[0]
×
24
        raise Exception(f"Error Connecting: {message}")
×
25

26
    except ConnectionError:
×
UNCOV
27
        raise Exception("Networking Error, unable to reach Gophish.")
×
28

29
    except Exception:
×
UNCOV
30
        raise Exception("Cannot connect to Gophish.")
×
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