@@ -32,7 +32,7 @@ For challenges with predetermined, unchanging answers:
3232public abstract class FixedAnswerChallenge implements Challenge {
3333 // Caches the answer for performance
3434 private Supplier<String > cachedAnswer = Suppliers . memoize(() - > getAnswer());
35-
35+
3636 protected abstract String getAnswer (); // Implement to return fixed answer
3737}
3838```
@@ -49,23 +49,23 @@ All challenges follow this structure:
4949``` java
5050@Component
5151public class Challenge [Number] extends FixedAnswerChallenge {
52-
52+
5353 private final RuntimeEnvironment runtimeEnvironment;
54-
54+
5555 public Challenge[Number](RuntimeEnvironment runtimeEnvironment) {
5656 this . runtimeEnvironment = runtimeEnvironment;
5757 }
58-
58+
5959 @Override
6060 public String getAnswer () {
6161 // Implementation specific to challenge
6262 }
63-
63+
6464 @Override
6565 public boolean canRunInCTFMode () {
6666 return true ; // or false based on challenge requirements
6767 }
68-
68+
6969 @Override
7070 public RuntimeEnvironment .Environment supportedRuntimeEnvironments () {
7171 return RuntimeEnvironment . Environment . DOCKER ; // or appropriate environment
@@ -102,7 +102,7 @@ public class RuntimeEnvironment {
102102 public enum Environment {
103103 DOCKER , AWS , GCP , AZURE , K8S
104104 }
105-
105+
106106 public Environment getCurrentEnvironment () {
107107 // Auto-detection logic based on environment variables
108108 }
@@ -114,12 +114,12 @@ public class RuntimeEnvironment {
114114``` java
115115@Component
116116public class ExampleChallenge extends FixedAnswerChallenge {
117-
117+
118118 @Value (" ${challenge.secret:default-value}" )
119119 private String secret;
120-
120+
121121 private final RuntimeEnvironment runtimeEnvironment;
122-
122+
123123 @Override
124124 public String getAnswer () {
125125 return switch (runtimeEnvironment. getCurrentEnvironment()) {
@@ -139,26 +139,26 @@ public class ExampleChallenge extends FixedAnswerChallenge {
139139``` java
140140@ExtendWith (MockitoExtension . class)
141141class Challenge [Number]Test {
142-
142+
143143 @Mock
144144 private RuntimeEnvironment runtimeEnvironment;
145-
145+
146146 private Challenge [Number ] challenge;
147-
147+
148148 @BeforeEach
149149 void setUp () {
150150 challenge = new Challenge [Number ](runtimeEnvironment);
151151 }
152-
152+
153153 @Test
154154 void shouldReturnCorrectAnswer () {
155155 // Given
156156 when(runtimeEnvironment. getCurrentEnvironment())
157157 .thenReturn(RuntimeEnvironment . Environment . DOCKER );
158-
158+
159159 // When
160160 String answer = challenge. spoiler(). solution();
161-
161+
162162 // Then
163163 assertThat(answer). isEqualTo(" expected-answer" );
164164 assertTrue(challenge. answerCorrect(" expected-answer" ));
@@ -171,15 +171,15 @@ class Challenge[Number]Test {
171171``` java
172172@SpringBootTest (webEnvironment = SpringBootTest . WebEnvironment . RANDOM_PORT )
173173class ChallengeControllerIntegrationTest {
174-
174+
175175 @Autowired
176176 private TestRestTemplate restTemplate;
177-
177+
178178 @Test
179179 void shouldReturnChallengeResponse () {
180180 ResponseEntity<String > response = restTemplate. getForEntity(
181181 " /challenge/1" , String . class);
182-
182+
183183 assertThat(response. getStatusCode()). isEqualTo(HttpStatus . OK );
184184 }
185185}
@@ -205,19 +205,19 @@ jobs:
205205 steps :
206206 - name : Checkout code
207207 uses : actions/checkout@v4
208-
208+
209209 - name : Setup Java
210210 uses : actions/setup-java@v4
211211 with :
212212 java-version : ' 21'
213213 distribution : ' temurin'
214-
214+
215215 - name : Cache Maven dependencies
216216 uses : actions/cache@v4
217217 with :
218218 path : ~/.m2
219219 key : ${{ runner.os }}-m2-${{ hashFiles('**/pom.xml') }}
220-
220+
221221 - name : [Specific Action]
222222 run : [commands]
223223` ` `
@@ -303,7 +303,7 @@ public String getAnswer() {
303303` ` ` java
304304@ControllerAdvice
305305public class AllControllerAdvice {
306-
306+
307307 @ExceptionHandler(ChallengeConfigurationException.class)
308308 public ResponseEntity<String> handleChallengeConfigError(
309309 ChallengeConfigurationException e) {
@@ -341,4 +341,4 @@ Each challenge should include:
341341- Public APIs require Javadoc
342342- Complex logic requires inline comments
343343- Configuration options documented in properties files
344- - README files for deployment-specific instructions
344+ - README files for deployment-specific instructions
0 commit comments