Merge branch 'master' into revert-user-deletion
This commit is contained in:
@@ -1,18 +0,0 @@
|
||||
BROWSERSTACK_CONFIG = {
|
||||
"win7_ie10": {
|
||||
"browser": "IE",
|
||||
"browser_version": "10.0",
|
||||
"os": "Windows",
|
||||
"os_version": "7",
|
||||
"resolution": "1024x768",
|
||||
"browserstack.local": True,
|
||||
},
|
||||
"win10_chrome62": {
|
||||
"browser": "Chrome",
|
||||
"browser_version": "62.0",
|
||||
"os": "Windows",
|
||||
"os_version": "10",
|
||||
"resolution": "1024x768",
|
||||
"browserstack.local": True,
|
||||
},
|
||||
}
|
@@ -1,65 +0,0 @@
|
||||
import os
|
||||
import pytest
|
||||
import logging
|
||||
from collections import Mapping
|
||||
from selenium import webdriver
|
||||
from selenium.webdriver.common.keys import Keys
|
||||
from selenium.webdriver.common.desired_capabilities import DesiredCapabilities
|
||||
|
||||
from .browsers import BROWSERSTACK_CONFIG
|
||||
|
||||
|
||||
@pytest.fixture(scope="function", autouse=True)
|
||||
def session(db, request):
|
||||
"""
|
||||
Override base test session
|
||||
"""
|
||||
pass
|
||||
|
||||
|
||||
class DriverCollection(Mapping):
|
||||
"""
|
||||
Allows access to drivers with dictionary syntax. Keeps track of which ones
|
||||
have already been initialized. Allows teardown of all existing drivers.
|
||||
"""
|
||||
|
||||
def __init__(self):
|
||||
self._drivers = {}
|
||||
|
||||
def __iter__(self):
|
||||
return iter(self._drivers)
|
||||
|
||||
def __len__(self):
|
||||
return len(self._drivers)
|
||||
|
||||
def __getitem__(self, name):
|
||||
if name in self._drivers:
|
||||
return self._drivers[name]
|
||||
|
||||
elif name in BROWSERSTACK_CONFIG:
|
||||
self._drivers[name] = self._build_driver(name)
|
||||
return self._drivers[name]
|
||||
|
||||
else:
|
||||
raise AttributeError("Driver {} not found".format(name))
|
||||
|
||||
def _build_driver(self, config_key):
|
||||
return webdriver.Remote(
|
||||
command_executor="http://{}:{}@hub.browserstack.com:80/wd/hub".format(
|
||||
os.getenv("BROWSERSTACK_EMAIL"), os.getenv("BROWSERSTACK_TOKEN")
|
||||
),
|
||||
desired_capabilities=BROWSERSTACK_CONFIG.get(config_key),
|
||||
)
|
||||
|
||||
def teardown(self):
|
||||
for driver in self._drivers.values():
|
||||
driver.quit()
|
||||
|
||||
|
||||
@pytest.fixture(scope="session")
|
||||
def drivers():
|
||||
driver_collection = DriverCollection()
|
||||
|
||||
yield driver_collection
|
||||
|
||||
driver_collection.teardown()
|
@@ -1,50 +0,0 @@
|
||||
import pytest
|
||||
import requests
|
||||
from flask import url_for
|
||||
from urllib.parse import urljoin
|
||||
from .browsers import BROWSERSTACK_CONFIG
|
||||
from atst.domain.users import Users
|
||||
import atst.domain.exceptions as exceptions
|
||||
from atst.routes.dev import _DEV_USERS as DEV_USERS
|
||||
from tests.test_auth import _login
|
||||
|
||||
import cryptography.x509 as x509
|
||||
from cryptography.hazmat.backends import default_backend
|
||||
|
||||
|
||||
USER_CERT = "ssl/client-certs/atat.mil.crt"
|
||||
|
||||
|
||||
@pytest.mark.parametrize("browser_type", BROWSERSTACK_CONFIG.keys())
|
||||
@pytest.mark.usefixtures("live_server")
|
||||
def test_can_get_title(browser_type, app, drivers):
|
||||
driver = drivers[browser_type]
|
||||
driver.get(url_for("atst.root", _external=True))
|
||||
assert "JEDI" in driver.title
|
||||
|
||||
|
||||
def _get_common_name(cert_path):
|
||||
with open(USER_CERT, "rb") as cert_file:
|
||||
cert = x509.load_pem_x509_certificate(cert_file.read(), default_backend())
|
||||
common_names = cert.subject.get_attributes_for_oid(x509.NameOID.COMMON_NAME)
|
||||
return common_names[0].value
|
||||
|
||||
|
||||
@pytest.fixture(scope="module")
|
||||
def valid_user_from_cert():
|
||||
cn = _get_common_name(USER_CERT)
|
||||
cn_parts = cn.split(".")
|
||||
user_info = {
|
||||
"last_name": cn_parts[0],
|
||||
"first_name": cn_parts[1],
|
||||
"dod_id": cn_parts[-1],
|
||||
"atat_role_name": "developer",
|
||||
}
|
||||
return Users.get_or_create_by_dod_id(**user_info)
|
||||
|
||||
|
||||
@pytest.mark.usefixtures("live_server")
|
||||
def test_login(drivers, client, app, valid_user_from_cert):
|
||||
driver = drivers["win7_ie10"]
|
||||
driver.get(url_for("dev.login_dev", _external=True))
|
||||
assert "Sign in" not in driver.title
|
@@ -1,3 +1,5 @@
|
||||
from atst.domain.application_roles import ApplicationRoles
|
||||
from atst.models import ApplicationRoleStatus
|
||||
from atst.models import AuditEvent
|
||||
|
||||
from tests.factories import (
|
||||
@@ -16,6 +18,22 @@ def test_application_environments_excludes_deleted():
|
||||
assert app.environments[0].id == env.id
|
||||
|
||||
|
||||
def test_application_members_excludes_deleted(session):
|
||||
app = ApplicationFactory.create()
|
||||
member_role = ApplicationRoleFactory.create(
|
||||
application=app, status=ApplicationRoleStatus.ACTIVE
|
||||
)
|
||||
disabled_role = ApplicationRoleFactory.create(
|
||||
application=app, status=ApplicationRoleStatus.DISABLED
|
||||
)
|
||||
disabled_role.deleted = True
|
||||
session.add(disabled_role)
|
||||
session.commit()
|
||||
|
||||
assert len(app.members) == 1
|
||||
assert app.members[0].id == member_role.id
|
||||
|
||||
|
||||
def test_audit_event_for_application_deletion(session):
|
||||
app = ApplicationFactory.create()
|
||||
app.deleted = True
|
||||
|
@@ -10,6 +10,7 @@ from atst.domain.application_roles import ApplicationRoles
|
||||
from atst.domain.environment_roles import EnvironmentRoles
|
||||
from atst.domain.common import Paginator
|
||||
from atst.domain.permission_sets import PermissionSets
|
||||
from atst.models.application_role import Status as ApplicationRoleStatus
|
||||
from atst.models.environment_role import CSPRole
|
||||
from atst.models.permissions import Permissions
|
||||
from atst.forms.application import EditEnvironmentForm
|
||||
@@ -560,6 +561,8 @@ def test_revoke_invite(client, user_session):
|
||||
)
|
||||
|
||||
assert invite.is_revoked
|
||||
assert app_role.status == ApplicationRoleStatus.DISABLED
|
||||
assert app_role.deleted
|
||||
|
||||
|
||||
def test_filter_environment_roles():
|
||||
|
Reference in New Issue
Block a user