mirror of
https://github.com/PaperMC/Velocity.git
synced 2026-04-20 19:38:15 +02:00
various things
This commit is contained in:
@@ -1,19 +1,20 @@
|
||||
package com.velocitypowered.proxy.util;
|
||||
|
||||
import org.junit.Assert;
|
||||
import org.junit.Test;
|
||||
import org.junit.jupiter.api.Test;
|
||||
|
||||
import java.nio.charset.StandardCharsets;
|
||||
import java.security.MessageDigest;
|
||||
|
||||
public class EncryptionUtilsTest {
|
||||
import static org.junit.jupiter.api.Assertions.assertEquals;
|
||||
|
||||
class EncryptionUtilsTest {
|
||||
@Test
|
||||
public void twoComplementsSha1Digest() throws Exception {
|
||||
void twoComplementsSha1Digest() throws Exception {
|
||||
String notchHash = hexDigest("Notch");
|
||||
Assert.assertEquals("4ed1f46bbe04bc756bcb17c0c7ce3e4632f06a48", notchHash);
|
||||
assertEquals("4ed1f46bbe04bc756bcb17c0c7ce3e4632f06a48", notchHash);
|
||||
|
||||
String jebHash = hexDigest("jeb_");
|
||||
Assert.assertEquals("-7c9d5b0044c130109a5d7b5fb5c317c02b4e28c1", jebHash);
|
||||
assertEquals("-7c9d5b0044c130109a5d7b5fb5c317c02b4e28c1", jebHash);
|
||||
}
|
||||
|
||||
private String hexDigest(String str) throws Exception {
|
||||
@@ -22,4 +23,4 @@ public class EncryptionUtilsTest {
|
||||
byte[] digested = digest.digest();
|
||||
return EncryptionUtils.twoComplementsSha1Digest(digested);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,26 +1,25 @@
|
||||
package com.velocitypowered.proxy.util;
|
||||
|
||||
import org.junit.Assert;
|
||||
import org.junit.Test;
|
||||
import org.junit.jupiter.api.Test;
|
||||
|
||||
import java.util.UUID;
|
||||
|
||||
import static org.junit.Assert.*;
|
||||
import static org.junit.jupiter.api.Assertions.assertEquals;
|
||||
|
||||
public class UuidUtilsTest {
|
||||
private static final UUID VALID_UUID = UUID.fromString("6b501978-d3be-4f33-bcf6-6e7808f37a0d");
|
||||
private static final String VALID_MOJANG_UUID = "6b501978d3be4f33bcf66e7808f37a0d";
|
||||
class UuidUtilsTest {
|
||||
private static final UUID EXPECTED_DASHED_UUID = UUID.fromString("6b501978-d3be-4f33-bcf6-6e7808f37a0d");
|
||||
private static final String ACTUAL_UNDASHED_UUID = EXPECTED_DASHED_UUID.toString().replace("-", "");
|
||||
|
||||
private static final UUID TEST_OFFLINE_PLAYER_UUID = UUID.fromString("708f6260-183d-3912-bbde-5e279a5e739a");
|
||||
private static final String TEST_OFFLINE_PLAYER = "tuxed";
|
||||
|
||||
@Test
|
||||
public void fromMojang() {
|
||||
Assert.assertEquals("UUIDs do not match", VALID_UUID, UuidUtils.fromMojang(VALID_MOJANG_UUID));
|
||||
void testFromUndashed() {
|
||||
assertEquals(EXPECTED_DASHED_UUID, UuidUtils.fromUndashed(ACTUAL_UNDASHED_UUID), "UUIDs do not match");
|
||||
}
|
||||
|
||||
@Test
|
||||
public void generateOfflinePlayerUuid() {
|
||||
Assert.assertEquals("UUIDs do not match", TEST_OFFLINE_PLAYER_UUID, UuidUtils.generateOfflinePlayerUuid(TEST_OFFLINE_PLAYER));
|
||||
void generateOfflinePlayerUuid() {
|
||||
assertEquals(TEST_OFFLINE_PLAYER_UUID, UuidUtils.generateOfflinePlayerUuid(TEST_OFFLINE_PLAYER), "UUIDs do not match");
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user