Skip to content

Commit

Permalink
formatting feedback, java7 (bunq#93)
Browse files Browse the repository at this point in the history
  • Loading branch information
tubbynl committed Jun 19, 2018
1 parent 30d43ee commit abb8cb6
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 15 deletions.
6 changes: 3 additions & 3 deletions src/main/java/com/bunq/sdk/security/SecurityUtils.java
Original file line number Diff line number Diff line change
Expand Up @@ -284,7 +284,7 @@ private static void addHeaderClientEncryptionKey(ApiContext apiContext, SecretKe
cipher.init(Cipher.ENCRYPT_MODE, apiContext.getInstallationContext().getPublicKeyServer());
byte[] keyEncrypted = cipher.doFinal(key.getEncoded());
String keyEncryptedEncoded = Base64.getEncoder().encodeToString(keyEncrypted);
BunqHeader.clientEncryptionKey.addTo(customHeaders,keyEncryptedEncoded);
BunqHeader.clientEncryptionKey.addTo(customHeaders, keyEncryptedEncoded);
} catch (GeneralSecurityException exception) {
throw new BunqException(exception.getMessage());
}
Expand All @@ -293,7 +293,7 @@ private static void addHeaderClientEncryptionKey(ApiContext apiContext, SecretKe
private static void addHeaderClientEncryptionIv(byte[] initializationVector, Map<String,
String> customHeaders) {
String initializationVectorEncoded = Base64.getEncoder().encodeToString(initializationVector);
BunqHeader.clientEncryptionIV.addTo(customHeaders,initializationVectorEncoded);
BunqHeader.clientEncryptionIV.addTo(customHeaders, initializationVectorEncoded);
}

private static byte[] encryptRequestBytes(byte[] requestBytes, SecretKey key,
Expand Down Expand Up @@ -326,7 +326,7 @@ private static void addHeaderClientEncryptionHmac(byte[] requestBytes,
bufferedSink.close();
byte[] hmac = mac.doFinal();
String hmacEncoded = Base64.getEncoder().encodeToString(hmac);
BunqHeader.clientEncryptionHMAC.addTo(customHeaders,hmacEncoded);
BunqHeader.clientEncryptionHMAC.addTo(customHeaders, hmacEncoded);
} catch (GeneralSecurityException | IOException exception) {
throw new BunqException(exception.getMessage());
}
Expand Down
24 changes: 12 additions & 12 deletions src/test/java/com/bunq/sdk/http/BunqHeaderTest.java
Original file line number Diff line number Diff line change
Expand Up @@ -10,8 +10,8 @@ public class BunqHeaderTest {
@Test
public void parse() {
// parse works case-insensitive
assertEquals(BunqHeader.clientResponseId,BunqHeader.parse("X-Bunq-Client-Response-Id"));
assertEquals(BunqHeader.clientResponseId,BunqHeader.parse("x-bunq-client-response-id"));
assertEquals(BunqHeader.clientResponseId, BunqHeader.parse("X-Bunq-Client-Response-Id"));
assertEquals(BunqHeader.clientResponseId, BunqHeader.parse("x-bunq-client-response-id"));
}

@Test
Expand Down Expand Up @@ -40,23 +40,23 @@ public void isBunq() {
public void getOrDefault() {
BunqHeader h = BunqHeader.clientResponseId;

assertEquals("test-id",h.getOrDefault(Collections.singletonMap("x-bunq-client-response-id","test-id")));
assertEquals("Could not determine response id.",h.getOrDefault(Collections.singletonMap("x-bunq-some-other-header","test-id")));
assertEquals("Could not determine response id.",h.getOrDefault(Collections.emptyMap()));
assertEquals("test-id", h.getOrDefault(Collections.singletonMap("x-bunq-client-response-id", "test-id")));
assertEquals("Could not determine response id.", h.getOrDefault(Collections.singletonMap("x-bunq-some-other-header", "test-id")));
assertEquals("Could not determine response id.", h.getOrDefault(Collections.<String,String>emptyMap()));
}

@Test
public void addToMap() {
Map<String,String> headers = new HashMap<>();
Map<String, String> headers = new HashMap<>();

//sut
BunqHeader.language.addTo(headers,null);
BunqHeader.geolocation.addTo(headers,null);
BunqHeader.userAgent.addTo(headers,"test-agent");
BunqHeader.language.addTo(headers, null);
BunqHeader.geolocation.addTo(headers, null);
BunqHeader.userAgent.addTo(headers, "test-agent");

// verify
assertEquals("en_US",headers.get("X-Bunq-Language"));
assertEquals("0 0 0 0 000",headers.get("X-Bunq-Geolocation"));
assertEquals("test-agent",headers.get("User-Agent"));
assertEquals("en_US", headers.get("X-Bunq-Language"));
assertEquals("0 0 0 0 000", headers.get("X-Bunq-Geolocation"));
assertEquals("test-agent", headers.get("User-Agent"));
}
}

0 comments on commit abb8cb6

Please sign in to comment.