forked from getsentry/self-hosted
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Browse files
Browse the repository at this point in the history
This reverts commit 77f75c4.
- Loading branch information
Showing
48 changed files
with
1,119 additions
and
406 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,82 @@ | ||
import os | ||
import subprocess | ||
import time | ||
|
||
import httpx | ||
import pytest | ||
|
||
SENTRY_CONFIG_PY = "sentry/sentry.conf.py" | ||
SENTRY_TEST_HOST = os.getenv("SENTRY_TEST_HOST", "http://localhost:9000") | ||
TEST_USER = "[email protected]" | ||
TEST_PASS = "test123TEST" | ||
TIMEOUT_SECONDS = 60 | ||
|
||
|
||
def pytest_addoption(parser): | ||
parser.addoption("--customizations", default="disabled") | ||
|
||
|
||
@pytest.fixture(scope="session", autouse=True) | ||
def configure_self_hosted_environment(request): | ||
subprocess.run( | ||
["docker", "compose", "--ansi", "never", "up", "-d"], | ||
check=True, | ||
capture_output=True, | ||
) | ||
for i in range(TIMEOUT_SECONDS): | ||
try: | ||
response = httpx.get(SENTRY_TEST_HOST, follow_redirects=True) | ||
except httpx.RequestError: | ||
time.sleep(1) | ||
else: | ||
if response.status_code == 200: | ||
break | ||
else: | ||
raise AssertionError("timeout waiting for self-hosted to come up") | ||
|
||
if request.config.getoption("--customizations") == "enabled": | ||
os.environ["TEST_CUSTOMIZATIONS"] = "enabled" | ||
script_content = """\ | ||
#!/bin/bash | ||
touch /created-by-enhance-image | ||
apt-get update | ||
apt-get install -y gcc libsasl2-dev python-dev libldap2-dev libssl-dev | ||
""" | ||
|
||
with open("sentry/enhance-image.sh", "w") as script_file: | ||
script_file.write(script_content) | ||
# Set executable permissions for the shell script | ||
os.chmod("sentry/enhance-image.sh", 0o755) | ||
|
||
# Write content to the requirements.txt file | ||
with open("sentry/requirements.txt", "w") as req_file: | ||
req_file.write("python-ldap\n") | ||
os.environ["MINIMIZE_DOWNTIME"] = "1" | ||
subprocess.run(["./install.sh"], check=True) | ||
# Create test user | ||
subprocess.run( | ||
[ | ||
"docker", | ||
"compose", | ||
"exec", | ||
"-T", | ||
"web", | ||
"sentry", | ||
"createuser", | ||
"--force-update", | ||
"--superuser", | ||
"--email", | ||
TEST_USER, | ||
"--password", | ||
TEST_PASS, | ||
"--no-input", | ||
], | ||
check=True, | ||
text=True, | ||
) | ||
|
||
|
||
@pytest.fixture() | ||
def setup_backup_restore_env_variables(): | ||
os.environ["SENTRY_DOCKER_IO_DIR"] = os.path.join(os.getcwd(), "sentry") | ||
os.environ["SKIP_USER_CREATION"] = "1" |
This file was deleted.
Oops, something went wrong.
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,15 +1,16 @@ | ||
import unittest | ||
|
||
import requests | ||
|
||
|
||
class CustomCATests(unittest.TestCase): | ||
def test_valid_self_signed(self): | ||
self.assertEqual(requests.get("https://self.test").text, 'ok') | ||
self.assertEqual(requests.get("https://self.test").text, "ok") | ||
|
||
def test_invalid_self_signed(self): | ||
with self.assertRaises(requests.exceptions.SSLError): | ||
requests.get("https://fail.test") | ||
|
||
|
||
if __name__ == '__main__': | ||
if __name__ == "__main__": | ||
unittest.main() |
This file was deleted.
Oops, something went wrong.
This file was deleted.
Oops, something went wrong.
Oops, something went wrong.