-
Notifications
You must be signed in to change notification settings - Fork 47
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
PXP-5256 Fix broken authorization page login for users with many proj…
…ects (#785)
- Loading branch information
1 parent
708b6c1
commit bc081d8
Showing
3 changed files
with
53 additions
and
1 deletion.
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,3 +1,52 @@ | ||
import os | ||
|
||
from fence.resources.storage.cdis_jwt import create_session_token | ||
from fence.config import config | ||
from fence.sync.sync_users import UserSyncer | ||
|
||
|
||
def test_google_login_error_handling(client): | ||
r = client.get("/login/google/login?code=abc") | ||
assert r.status_code == 400 | ||
|
||
|
||
def test_google_login_http_headers_are_less_than_4k_for_user_with_many_projects( | ||
app, client, monkeypatch, db_session | ||
): | ||
""" | ||
Test that when the current user has access to a large number of projects, | ||
the http headers of the response from a GET to /login/google/login are less | ||
than 4k bytes in size. | ||
""" | ||
monkeypatch.setitem(config, "MOCK_GOOGLE_AUTH", True) | ||
test_session_jwt = create_session_token( | ||
app.keypairs[0], | ||
config.get("SESSION_TIMEOUT"), | ||
context={ | ||
"redirect": "https://localhost/user/oauth2/authorize?client_id=7f7kAS4MJraUuo77d7RWHr4mZ6bvGtuzup7hw46I&response_type=id_token&redirect_uri=https://webapp.example/fence&scope=openid+user+data+google_credentials&nonce=randomvalue" | ||
}, | ||
) | ||
client.set_cookie("localhost", config["SESSION_COOKIE_NAME"], test_session_jwt) | ||
|
||
user_projects = { | ||
"test": { | ||
f"project{x}": { | ||
"read", | ||
"read-storage", | ||
"update", | ||
"upload", | ||
"create", | ||
"write-storage", | ||
"delete", | ||
} | ||
for x in range(20) | ||
} | ||
} | ||
user_info = {"test": {"tags": {},}} | ||
dbGaP = os.environ.get("dbGaP") or config.get("dbGaP") | ||
syncer = UserSyncer(dbGaP, config["DB"], {}) | ||
syncer.sync_to_db_and_storage_backend(user_projects, user_info, db_session) | ||
|
||
resp = client.get("/login/google/login") | ||
assert len(str(resp.headers)) < 4096 | ||
assert resp.status_code == 302 |