# retoor <retoor@molodetz.nl>

import requests
from tests.conftest import BASE_URL


def _bob(seeded_db):
    s = requests.Session()
    s.post(
        f"{BASE_URL}/auth/login",
        data={
            "email": seeded_db["bob"]["email"],
            "password": seeded_db["bob"]["password"],
        },
    )
    return s


def test_create_requires_admin(app_server, seeded_db):
    s = _bob(seeded_db)
    r = s.post(
        f"{BASE_URL}/admin/containers/create",
        data={"project_slug": "x", "name": "x"},
        allow_redirects=False,
    )
    assert r.status_code in (302, 303, 403)


def test_create_requires_login(app_server):
    r = requests.post(
        f"{BASE_URL}/admin/containers/create",
        data={"project_slug": "x", "name": "x"},
        allow_redirects=False,
    )
    assert r.status_code in (302, 303)
