Skip to content
Permalink

Comparing changes

Choose two branches to see what’s changed or to start a new pull request. If you need to, you can also or learn more about diff comparisons.

Open a pull request

Create a new pull request by comparing changes across two branches. If you need to, you can also . Learn more about diff comparisons here.
base repository: CTFd/ctfcli
Failed to load repositories. Confirm that selected base ref is valid, then try again.
Loading
base: 0.1.4
Choose a base ref
...
head repository: CTFd/ctfcli
Failed to load repositories. Confirm that selected head ref is valid, then try again.
Loading
compare: master
Choose a head ref
  • 2 commits
  • 3 files changed
  • 1 contributor

Commits on May 4, 2025

  1. Support hint title (#184)

    * Add support for hint titles released in CTFd 3.7.7
    ColdHeat authored May 4, 2025
    Copy the full SHA
    850fcbe View commit details
  2. Copy the full SHA
    c5abdd4 View commit details
Showing with 11 additions and 6 deletions.
  1. +3 −1 ctfcli/core/challenge.py
  2. +3 −0 ctfcli/spec/challenge-example.yml
  3. +5 −5 tests/core/test_challenge.py
4 changes: 3 additions & 1 deletion ctfcli/core/challenge.py
Original file line number Diff line number Diff line change
@@ -398,13 +398,15 @@ def _create_hints(self):
if type(hint) == str:
hint_payload = {
"content": hint,
"title": "",
"cost": 0,
"challenge_id": self.challenge_id,
}
else:
hint_payload = {
"content": hint["content"],
"cost": hint["cost"],
"title": hint.get("title", ""),
"cost": hint.get("cost", 0),
"challenge_id": self.challenge_id,
}

3 changes: 3 additions & 0 deletions ctfcli/spec/challenge-example.yml
Original file line number Diff line number Diff line change
@@ -107,6 +107,9 @@ hints:
cost: 10
}
- This hint is free
- title: Titled Hint
content: This hint has a title and costs points
cost: 10

# Requirements are used to make a challenge require another challenge to be
# solved before being available.
10 changes: 5 additions & 5 deletions tests/core/test_challenge.py
Original file line number Diff line number Diff line change
@@ -699,9 +699,9 @@ def test_updates_hints(self, mock_api_constructor: MagicMock, *args, **kwargs):

mock_api.post.assert_has_calls(
[
call("/api/v1/hints", json={"content": "free hint", "cost": 0, "challenge_id": 1}),
call("/api/v1/hints", json={"content": "free hint", "title": "", "cost": 0, "challenge_id": 1}),
call().raise_for_status(),
call("/api/v1/hints", json={"content": "paid hint", "cost": 100, "challenge_id": 1}),
call("/api/v1/hints", json={"content": "paid hint", "title": "", "cost": 100, "challenge_id": 1}),
call().raise_for_status(),
]
)
@@ -1029,7 +1029,7 @@ def test_updates_multiple_attributes_at_once(self, mock_api_constructor: MagicMo
call().raise_for_status(),
call("/api/v1/files", files=ANY, data={"challenge_id": 1, "type": "challenge"}),
call().raise_for_status(),
call("/api/v1/hints", json={"content": "free hint", "cost": 0, "challenge_id": 1}),
call("/api/v1/hints", json={"title": "", "content": "free hint", "cost": 0, "challenge_id": 1}),
call().raise_for_status(),
]
)
@@ -1237,8 +1237,8 @@ def mock_post(*args, **kwargs):
# files
call("/api/v1/files", files=ANY, data={"challenge_id": 3, "type": "challenge"}),
# hints
call("/api/v1/hints", json={"content": "free hint", "cost": 0, "challenge_id": 3}),
call("/api/v1/hints", json={"content": "paid hint", "cost": 100, "challenge_id": 3}),
call("/api/v1/hints", json={"title": "", "content": "free hint", "cost": 0, "challenge_id": 3}),
call("/api/v1/hints", json={"title": "", "content": "paid hint", "cost": 100, "challenge_id": 3}),
]
)