Skip to content
Snippets Groups Projects
Commit 628de872 authored by Martin Vogel's avatar Martin Vogel
Browse files

#414 Finalize vars and reformat

parent a542c828
No related branches found
No related tags found
2 merge requests!2#414 Remaining changes from MR,!1planning#414 Methoden Signaturen (Zwischenstand)
package fitconnect.impl.auth;
package de.fitko.fitconnect.core.auth;
import de.fitko.fitconnect.api.domain.auth.OAuthToken;
import de.fitko.fitconnect.api.services.Sender;
......@@ -17,17 +17,17 @@ class OAuthTokenIntegrationTest {
void retrieveAuthenticationToken() {
// Given
var tokenUrl = "https://auth-testing.fit-connect.fitko.dev/token";
var clientId = "781f6213-0f0f-4a79-9372-e7187ffda98b";
var secret = "PnzR8Vbmhpv_VwTkT34wponqXWK8WBm-LADlryYdV4o";
var scope1 = "send:region:DE";
var scope2 = "send:region:EN";
final var tokenUrl = "https://auth-testing.fit-connect.fitko.dev/token";
final var clientId = "781f6213-0f0f-4a79-9372-e7187ffda98b";
final var secret = "PnzR8Vbmhpv_VwTkT34wponqXWK8WBm-LADlryYdV4o";
final var scope1 = "send:region:DE";
final var scope2 = "send:region:EN";
var authService = new DefaultOAuthService( new RestTemplate(), tokenUrl);
final var authService = new DefaultOAuthService(new RestTemplate(), tokenUrl);
final Sender sender = new SubmissionSender(authService, null, null, null);
// When
OAuthToken token = sender.retrieveOAuthToken(clientId, secret, scope1,scope2);
final OAuthToken token = sender.retrieveOAuthToken(clientId, secret, scope1, scope2);
// Then
assertNotNull(token);
......
package fitconnect.impl.crypto;
package de.fitko.fitconnect.core.crypto;
import de.fitko.fitconnect.core.crypto.HashUtil;
import org.junit.jupiter.api.Test;
......@@ -14,13 +14,13 @@ class HashUtilTest {
@Test
public void testMessageDigestForDataAndAttachments() throws IOException {
// Given (sender creates hash of (Fachdaten) or attachments (Anhänge))
byte[] exampleFileContent = getExampleFileContent("/example.pdf");
byte[] hashFromSender = underTest.createHash(exampleFileContent);
// Given (sender creates hash of (Fachdaten) or attachments (Anhänge))
final byte[] exampleFileContent = getExampleFileContent("/example.pdf");
final byte[] hashFromSender = underTest.createHash(exampleFileContent);
// When (subscriber verifies hash of data or attachments)
boolean verificationResult = underTest.verify(hashFromSender, exampleFileContent);
assertTrue(verificationResult);
// When (subscriber verifies hash of data or attachments)
final boolean verificationResult = underTest.verify(hashFromSender, exampleFileContent);
assertTrue(verificationResult);
}
private byte[] getExampleFileContent(final String path) throws IOException {
......
package fitconnect.impl.crypto;
package de.fitko.fitconnect.core.crypto;
import com.nimbusds.jose.JOSEException;
import com.nimbusds.jose.jwk.KeyUse;
......@@ -24,7 +24,7 @@ class JWECryptoServiceTest {
final RSAKey publicKey = privateKey.toPublicJWK();
// When
String encryptedData = underTest.encryptString(publicKey, "some foo");
final String encryptedData = underTest.encryptString(publicKey, "some foo");
// Then
assertNotNull(encryptedData);
......@@ -37,17 +37,17 @@ class JWECryptoServiceTest {
// Given
final RSAKey privateKey = generateRsaKey(4096);
final RSAKey publicKey = privateKey.toPublicJWK();
String encryptedData = underTest.encryptString(publicKey, "some foo");
final String encryptedData = underTest.encryptString(publicKey, "some foo");
// When
String decrypted = underTest.decryptString(privateKey, encryptedData);
final String decrypted = underTest.decryptString(privateKey, encryptedData);
// Then
assertNotNull(decrypted);
assertEquals("some foo", decrypted);
}
public static RSAKey generateRsaKey(int size) throws JOSEException {
public static RSAKey generateRsaKey(final int size) throws JOSEException {
return new RSAKeyGenerator(size)
.keyUse(KeyUse.ENCRYPTION)
.keyID(UUID.randomUUID().toString())
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment