forked from CTFd/CTFd
-
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
* fix: cast registration_code to string during register * test: add test to confirm numeric registration codes
- Loading branch information
1 parent
514ab2c
commit 3e6f635
Showing
2 changed files
with
32 additions
and
2 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
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -464,3 +464,33 @@ def test_registration_code_required(): | |
assert r.status_code == 302 | ||
assert r.location.startswith("http://localhost/challenges") | ||
destroy_ctfd(app) | ||
|
||
|
||
def test_registration_code_allows_numeric(): | ||
""" | ||
Test that registration code is allowed to be all numeric | ||
""" | ||
app = create_ctfd() | ||
with app.app_context(): | ||
# Set a registration code | ||
set_config("registration_code", "1234567890") | ||
|
||
with app.test_client() as client: | ||
# Load CSRF nonce | ||
r = client.get("/register") | ||
resp = r.get_data(as_text=True) | ||
assert "Registration Code" in resp | ||
with client.session_transaction() as sess: | ||
data = { | ||
"name": "user", | ||
"email": "[email protected]", | ||
"password": "password", | ||
"nonce": sess.get("nonce"), | ||
} | ||
|
||
# Attempt registration with numeric registration code | ||
data["registration_code"] = "1234567890" | ||
r = client.post("/register", data=data) | ||
assert r.status_code == 302 | ||
assert r.location.startswith("http://localhost/challenges") | ||
destroy_ctfd(app) |