Skip to content

Commit

Permalink
Merge pull request #22 from PAYONE-GmbH/refactor/request-header-gener…
Browse files Browse the repository at this point in the history
…ator-consts

refactor: use static class members
  • Loading branch information
Blackfaded authored Aug 22, 2024
2 parents c9c7210 + 91688db commit 58a3abc
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 7 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -20,9 +20,9 @@ public class RequestHeaderGenerator {

public static final String SERVER_META_INFO_HEADER_NAME = "X-GCS-ServerMetaInfo";
public static final String CLIENT_META_INFO_HEADER_NAME = "X-GCS-ClientMetaInfo";
private static final String DATE_HEADER_NAME = "Date";
private static final String AUTHORIZATION_HEADER_NAME = "Authorization";
private static final String CONTENT_TYPE_HEADER_NAME = "Content-Type";
public static final String DATE_HEADER_NAME = "Date";
public static final String AUTHORIZATION_HEADER_NAME = "Authorization";
public static final String CONTENT_TYPE_HEADER_NAME = "Content-Type";

private static final String ALGORITHM = "HmacSHA256";
private static final String WHITESPACE_REGEX = "\\r?\\n[\\h]*";
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,7 @@ class RequestHeaderGeneratorTest {
@Test
void testSignatureGenerationForGet() {
Date date = new Date(1720520499000l);
Headers headers = new Headers.Builder().add("Date", date)
Headers headers = new Headers.Builder().add(RequestHeaderGenerator.DATE_HEADER_NAME, date)
// the meta info is normally generated internally, but fields and output may
// change overtime, so we pin it for the test
.add(RequestHeaderGenerator.SERVER_META_INFO_HEADER_NAME, "server fixed")
Expand All @@ -63,7 +63,7 @@ void testSignatureGenerationWithContentType() {
Date date = new Date(1720520499000l);
MediaType mediaType = MediaType.parse("application/json; charset=utf-8");
Headers headers = new Headers.Builder()
.add("Content-Type", mediaType.toString())
.add(RequestHeaderGenerator.CONTENT_TYPE_HEADER_NAME, mediaType.toString())
.add("Date", date)
// the meta info is normally generated internally, but fields and output may
// change overtime, so we pin it for the test
Expand Down Expand Up @@ -96,8 +96,8 @@ void addADateHeaderIfMissingTest() {
try {
Request updatedRequest = HEADER_GENERATOR.generateAdditionalRequestHeaders(request);

assertNotNull(updatedRequest.headers().get("Date"));
assertNotEquals("", updatedRequest.headers().get("Date"));
assertNotNull(updatedRequest.headers().get(RequestHeaderGenerator.DATE_HEADER_NAME));
assertNotEquals("", updatedRequest.headers().get(RequestHeaderGenerator.DATE_HEADER_NAME));
} catch (Exception e) {
fail(e);
}
Expand Down

0 comments on commit 58a3abc

Please sign in to comment.