style: format code with spotless
All checks were successful
Build, test and publish the Quarkus libraries / build (push) Successful in 1m22s
All checks were successful
Build, test and publish the Quarkus libraries / build (push) Successful in 1m22s
This commit is contained in:
parent
e5e100076c
commit
40598dbe87
17 changed files with 88 additions and 155 deletions
|
@ -8,5 +8,4 @@ public interface MessageDigestConfiguration {
|
|||
|
||||
@WithDefault("SHA-256")
|
||||
String defaultAlgorithm();
|
||||
|
||||
}
|
||||
|
|
|
@ -2,7 +2,6 @@ package ch.phoenixtechnologies.quarkus.commons.digest;
|
|||
|
||||
import io.quarkus.arc.DefaultBean;
|
||||
import jakarta.enterprise.context.ApplicationScoped;
|
||||
|
||||
import java.nio.charset.Charset;
|
||||
import java.nio.charset.StandardCharsets;
|
||||
import java.security.MessageDigest;
|
||||
|
|
|
@ -1,37 +1,37 @@
|
|||
package ch.phoenixtechnologies.quarkus.commons.digest;
|
||||
|
||||
import io.quarkus.test.junit.QuarkusTest;
|
||||
import jakarta.inject.Inject;
|
||||
import org.junit.jupiter.api.Test;
|
||||
import org.junit.jupiter.params.ParameterizedTest;
|
||||
import org.junit.jupiter.params.provider.ValueSource;
|
||||
|
||||
import java.nio.charset.StandardCharsets;
|
||||
import java.security.MessageDigest;
|
||||
|
||||
import static org.assertj.core.api.Assertions.assertThat;
|
||||
import static org.assertj.core.api.AssertionsForClassTypes.assertThatThrownBy;
|
||||
|
||||
import io.quarkus.test.junit.QuarkusTest;
|
||||
import jakarta.inject.Inject;
|
||||
import java.nio.charset.StandardCharsets;
|
||||
import java.security.MessageDigest;
|
||||
import org.junit.jupiter.api.Test;
|
||||
import org.junit.jupiter.params.ParameterizedTest;
|
||||
import org.junit.jupiter.params.provider.ValueSource;
|
||||
|
||||
@QuarkusTest
|
||||
class MessageDigestServiceImplTest {
|
||||
|
||||
public static final String INPUT = "test";
|
||||
public static final byte[] EXPECTED_SHA256_DIGEST = {-97, -122, -48, -127, -120, 76, 125, 101, -102, 47, -22, -96, -59, 90, -48, 21, -93, -65, 79, 27, 43, 11, -126, 44, -47, 93, 108, 21, -80, -16, 10, 8};
|
||||
public static final byte[] EXPECTED_SHA256_DIGEST = {
|
||||
-97, -122, -48, -127, -120, 76, 125, 101, -102, 47, -22, -96, -59, 90, -48, 21, -93, -65, 79, 27, 43, 11, -126,
|
||||
44, -47, 93, 108, 21, -80, -16, 10, 8
|
||||
};
|
||||
|
||||
@Inject
|
||||
MessageDigestServiceImpl service;
|
||||
|
||||
@Test
|
||||
void getInstance() {
|
||||
assertThat(service.getInstance())
|
||||
.isInstanceOf(MessageDigest.class);
|
||||
assertThat(service.getInstance()).isInstanceOf(MessageDigest.class);
|
||||
}
|
||||
|
||||
@ParameterizedTest
|
||||
@ValueSource(strings = {"SHA-256", "SHA-512", "MD5"})
|
||||
void getInstanceWithAlgorithm(String algorithm) {
|
||||
assertThat(service.getInstance(algorithm))
|
||||
.isInstanceOf(MessageDigest.class);
|
||||
assertThat(service.getInstance(algorithm)).isInstanceOf(MessageDigest.class);
|
||||
}
|
||||
|
||||
@ParameterizedTest
|
||||
|
@ -61,7 +61,6 @@ class MessageDigestServiceImplTest {
|
|||
assertThat(service.digest(INPUT, StandardCharsets.UTF_8))
|
||||
.as("Digest should match expected value")
|
||||
.isEqualTo(EXPECTED_SHA256_DIGEST);
|
||||
|
||||
}
|
||||
|
||||
@Test
|
||||
|
@ -78,4 +77,4 @@ class MessageDigestServiceImplTest {
|
|||
.as("Digest should match expected value")
|
||||
.isEqualTo(EXPECTED_SHA256_DIGEST);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue