Skip to content

Commit

Permalink
Merge pull request #1021 from steve-community/1020-steve-returns-http…
Browse files Browse the repository at this point in the history
…statusunauthorized-when-chargeboxid-is-not-allowed-to-connect

set the correct http status if chargeboxid is not recognized (#1020)
  • Loading branch information
goekay authored Jan 8, 2023
2 parents 94efd15 + ef5245f commit 782f80a
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 782f80a

Please sign in to comment.