Skip to content

Commit

Permalink
set the correct http status if chargeboxid is not recognized (#1020)
Browse files Browse the repository at this point in the history
  • Loading branch information
goekay committed Jan 8, 2023
1 parent 94efd15 commit ef5245f
Show file tree
Hide file tree
Showing 2 changed files with 3 additions and 2 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -75,9 +75,10 @@ public boolean doHandshake(ServerHttpRequest request, ServerHttpResponse respons
// Allow connections, if station is in db (registration_status field from db does not matter)
boolean allowConnection = status.isPresent();

// https://github.com/steve-community/steve/issues/1020
if (!allowConnection) {
log.error("ChargeBoxId '{}' is not recognized.", chargeBoxId);
response.setStatusCode(HttpStatus.UNAUTHORIZED);
response.setStatusCode(HttpStatus.NOT_FOUND);
return false;
}

Expand Down
2 changes: 1 addition & 1 deletion src/test/java/de/rwth/idsg/steve/ApplicationJsonTest.java
Original file line number Diff line number Diff line change
Expand Up @@ -179,7 +179,7 @@ public void tesWithUnauthorizedStation() {

UpgradeException actualCause = (UpgradeException) e.getCause().getCause();

Assertions.assertEquals(HttpStatus.UNAUTHORIZED.value(), actualCause.getResponseStatusCode());
Assertions.assertEquals(HttpStatus.NOT_FOUND.value(), actualCause.getResponseStatusCode());
}

}

0 comments on commit ef5245f

Please sign in to comment.