Skip to content

Commit 90b3875

Browse files
committed
Merge branch 'delete-graffiti' into graffiti-management
# Conflicts: # validator/client/src/main/java/tech/pegasys/teku/validator/client/restapi/ValidatorRestApi.java # validator/client/src/test/resources/tech/pegasys/teku/validator/client/restapi/paths/_eth_v1_validator_{pubkey}_graffiti.json
2 parents 6cfc626 + 697b471 commit 90b3875

File tree

4 files changed

+197
-0
lines changed

4 files changed

+197
-0
lines changed

validator/client/src/main/java/tech/pegasys/teku/validator/client/restapi/ValidatorRestApi.java

+2
Original file line numberDiff line numberDiff line change
@@ -38,6 +38,7 @@
3838
import tech.pegasys.teku.validator.client.doppelganger.DoppelgangerDetector;
3939
import tech.pegasys.teku.validator.client.restapi.apis.DeleteFeeRecipient;
4040
import tech.pegasys.teku.validator.client.restapi.apis.DeleteGasLimit;
41+
import tech.pegasys.teku.validator.client.restapi.apis.DeleteGraffiti;
4142
import tech.pegasys.teku.validator.client.restapi.apis.DeleteKeys;
4243
import tech.pegasys.teku.validator.client.restapi.apis.DeleteRemoteKeys;
4344
import tech.pegasys.teku.validator.client.restapi.apis.GetFeeRecipient;
@@ -133,6 +134,7 @@ public static RestApi create(
133134
.endpoint(new PostVoluntaryExit(voluntaryExitDataProvider))
134135
.endpoint(new GetGraffiti())
135136
.endpoint(new SetGraffiti())
137+
.endpoint(new DeleteGraffiti())
136138
.sslCertificate(config.getRestApiKeystoreFile(), config.getRestApiKeystorePasswordFile())
137139
.passwordFilePath(validatorApiBearerFile)
138140
.build();
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,50 @@
1+
/*
2+
* Copyright Consensys Software Inc., 2024
3+
*
4+
* Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with
5+
* the License. You may obtain a copy of the License at
6+
*
7+
* http://www.apache.org/licenses/LICENSE-2.0
8+
*
9+
* Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on
10+
* an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the
11+
* specific language governing permissions and limitations under the License.
12+
*/
13+
14+
package tech.pegasys.teku.validator.client.restapi.apis;
15+
16+
import static tech.pegasys.teku.infrastructure.http.HttpStatusCodes.SC_NO_CONTENT;
17+
import static tech.pegasys.teku.validator.client.restapi.ValidatorRestApi.TAG_GRAFFITI;
18+
import static tech.pegasys.teku.validator.client.restapi.ValidatorTypes.PARAM_PUBKEY_TYPE;
19+
20+
import com.fasterxml.jackson.core.JsonProcessingException;
21+
import org.apache.commons.lang3.NotImplementedException;
22+
import tech.pegasys.teku.infrastructure.restapi.endpoints.EndpointMetadata;
23+
import tech.pegasys.teku.infrastructure.restapi.endpoints.RestApiEndpoint;
24+
import tech.pegasys.teku.infrastructure.restapi.endpoints.RestApiRequest;
25+
26+
public class DeleteGraffiti extends RestApiEndpoint {
27+
28+
public DeleteGraffiti() {
29+
super(
30+
EndpointMetadata.delete(GetGraffiti.ROUTE)
31+
.operationId("deleteGraffiti")
32+
.summary("Delete Configured Graffiti")
33+
.description("Delete the configured graffiti for the specified public key.")
34+
.tags(TAG_GRAFFITI)
35+
.withBearerAuthSecurity()
36+
.pathParam(PARAM_PUBKEY_TYPE)
37+
.response(
38+
SC_NO_CONTENT,
39+
"Successfully removed the graffiti, or there was no graffiti set for the requested public key.")
40+
.withAuthenticationResponses()
41+
.withNotFoundResponse()
42+
.withNotImplementedResponse()
43+
.build());
44+
}
45+
46+
@Override
47+
public void handleRequest(final RestApiRequest request) throws JsonProcessingException {
48+
throw new NotImplementedException("Not Implemented");
49+
}
50+
}
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,60 @@
1+
/*
2+
* Copyright Consensys Software Inc., 2024
3+
*
4+
* Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with
5+
* the License. You may obtain a copy of the License at
6+
*
7+
* http://www.apache.org/licenses/LICENSE-2.0
8+
*
9+
* Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on
10+
* an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the
11+
* specific language governing permissions and limitations under the License.
12+
*/
13+
14+
package tech.pegasys.teku.validator.client.restapi.apis;
15+
16+
import static tech.pegasys.teku.infrastructure.http.HttpStatusCodes.SC_BAD_REQUEST;
17+
import static tech.pegasys.teku.infrastructure.http.HttpStatusCodes.SC_FORBIDDEN;
18+
import static tech.pegasys.teku.infrastructure.http.HttpStatusCodes.SC_INTERNAL_SERVER_ERROR;
19+
import static tech.pegasys.teku.infrastructure.http.HttpStatusCodes.SC_NOT_IMPLEMENTED;
20+
import static tech.pegasys.teku.infrastructure.http.HttpStatusCodes.SC_NO_CONTENT;
21+
import static tech.pegasys.teku.infrastructure.http.HttpStatusCodes.SC_UNAUTHORIZED;
22+
import static tech.pegasys.teku.infrastructure.restapi.MetadataTestUtil.verifyMetadataEmptyResponse;
23+
import static tech.pegasys.teku.infrastructure.restapi.MetadataTestUtil.verifyMetadataErrorResponse;
24+
25+
import com.fasterxml.jackson.core.JsonProcessingException;
26+
import org.junit.jupiter.api.Test;
27+
28+
class DeleteGraffitiTest {
29+
private final DeleteGraffiti handler = new DeleteGraffiti();
30+
31+
@Test
32+
void metadata_shouldHandle204() {
33+
verifyMetadataEmptyResponse(handler, SC_NO_CONTENT);
34+
}
35+
36+
@Test
37+
void metadata_shouldHandle400() throws JsonProcessingException {
38+
verifyMetadataErrorResponse(handler, SC_BAD_REQUEST);
39+
}
40+
41+
@Test
42+
void metadata_shouldHandle401() throws JsonProcessingException {
43+
verifyMetadataErrorResponse(handler, SC_UNAUTHORIZED);
44+
}
45+
46+
@Test
47+
void metadata_shouldHandle403() throws JsonProcessingException {
48+
verifyMetadataErrorResponse(handler, SC_FORBIDDEN);
49+
}
50+
51+
@Test
52+
void metadata_shouldHandle500() throws JsonProcessingException {
53+
verifyMetadataErrorResponse(handler, SC_INTERNAL_SERVER_ERROR);
54+
}
55+
56+
@Test
57+
void metadata_shouldHandle501() throws JsonProcessingException {
58+
verifyMetadataErrorResponse(handler, SC_NOT_IMPLEMENTED);
59+
}
60+
}

validator/client/src/test/resources/tech/pegasys/teku/validator/client/restapi/paths/_eth_v1_validator_{pubkey}_graffiti.json

+85
Original file line numberDiff line numberDiff line change
@@ -184,5 +184,90 @@
184184
}
185185
}
186186
}
187+
},
188+
"delete" : {
189+
"tags" : [ "Graffiti" ],
190+
"operationId" : "deleteGraffiti",
191+
"summary" : "Delete Configured Graffiti",
192+
"description" : "Delete the configured graffiti for the specified public key.",
193+
"parameters" : [ {
194+
"name" : "pubkey",
195+
"required" : true,
196+
"in" : "path",
197+
"schema" : {
198+
"type" : "string",
199+
"pattern" : "^0x[a-fA-F0-9]{96}$",
200+
"example" : "0x93247f2209abcacf57b75a51dafae777f9dd38bc7053d1af526f220a7489a6d3a2753e5f3e8b1cfe39b56f43611df74a"
201+
}
202+
} ],
203+
"security" : [ {
204+
"bearerAuth" : [ ]
205+
} ],
206+
"responses" : {
207+
"204" : {
208+
"description" : "Successfully removed the graffiti, or there was no graffiti set for the requested public key.",
209+
"content" : { }
210+
},
211+
"401" : {
212+
"description" : "Unauthorized, no token is found",
213+
"content" : {
214+
"application/json" : {
215+
"schema" : {
216+
"$ref" : "#/components/schemas/HttpErrorResponse"
217+
}
218+
}
219+
}
220+
},
221+
"403" : {
222+
"description" : "Forbidden, a token is found but is invalid",
223+
"content" : {
224+
"application/json" : {
225+
"schema" : {
226+
"$ref" : "#/components/schemas/HttpErrorResponse"
227+
}
228+
}
229+
}
230+
},
231+
"404" : {
232+
"description" : "Not found",
233+
"content" : {
234+
"application/json" : {
235+
"schema" : {
236+
"$ref" : "#/components/schemas/HttpErrorResponse"
237+
}
238+
}
239+
}
240+
},
241+
"501" : {
242+
"description" : "Not implemented",
243+
"content" : {
244+
"application/json" : {
245+
"schema" : {
246+
"$ref" : "#/components/schemas/HttpErrorResponse"
247+
}
248+
}
249+
}
250+
},
251+
"400" : {
252+
"description" : "The request could not be processed, check the response for more information.",
253+
"content" : {
254+
"application/json" : {
255+
"schema" : {
256+
"$ref" : "#/components/schemas/HttpErrorResponse"
257+
}
258+
}
259+
}
260+
},
261+
"500" : {
262+
"description" : "Internal server error",
263+
"content" : {
264+
"application/json" : {
265+
"schema" : {
266+
"$ref" : "#/components/schemas/HttpErrorResponse"
267+
}
268+
}
269+
}
270+
}
271+
}
187272
}
188273
}

0 commit comments

Comments
 (0)