Exercise signed pack claims and revocation
This commit is contained in:
parent
f6b97434ee
commit
dfc181d7d8
2 changed files with 30 additions and 1 deletions
|
|
@ -104,7 +104,7 @@ final class MCGUIMenus implements AutoCloseable, Listener {
|
|||
Object vendorPack=verifiedPackAccess.invoke(framework);
|
||||
if(vendorPack==null)return;
|
||||
if(!loaded){verifiedPackForget.invoke(vendorPack,id);return;}
|
||||
if(!Boolean.TRUE.equals(hasPack.invoke(framework,player)))verifiedPackLoad.invoke(vendorPack,id);
|
||||
if(!readiness.loaded(id)||!Boolean.TRUE.equals(hasPack.invoke(framework,player)))verifiedPackLoad.invoke(vendorPack,id);
|
||||
if(Boolean.TRUE.equals(hasPack.invoke(framework,player)))readiness.proxyVerified(id);
|
||||
}catch(ReflectiveOperationException failure){readiness.forget(id);}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -0,0 +1,29 @@
|
|||
package com.dunerealms.pack;
|
||||
|
||||
import java.util.UUID;
|
||||
import org.junit.jupiter.api.Test;
|
||||
import static org.junit.jupiter.api.Assertions.*;
|
||||
|
||||
final class PackSessionProofTest {
|
||||
@Test void bindsVerifiedStatusToTheExactBackendChallenge() {
|
||||
var key = PackSessionProof.secret("12".repeat(32));
|
||||
var player = UUID.randomUUID();
|
||||
var pack = PackSessionProof.PACK_ID;
|
||||
byte[] nonce = new byte[16], hash = new byte[20];
|
||||
var positive = PackSessionProof.response(key, player, pack, hash, nonce, true);
|
||||
assertEquals(Boolean.TRUE, PackSessionProof.read(key, player, pack, hash, nonce, positive));
|
||||
assertNull(PackSessionProof.read(key, UUID.randomUUID(), pack, hash, nonce, positive));
|
||||
assertNull(PackSessionProof.read(key, player, UUID.randomUUID(), hash, nonce, positive));
|
||||
nonce[0]++;
|
||||
assertNull(PackSessionProof.read(key, player, pack, hash, nonce, positive));
|
||||
var revoked = PackSessionProof.response(key, player, pack, hash, nonce, false);
|
||||
assertEquals(Boolean.FALSE, PackSessionProof.read(key, player, pack, hash, nonce, revoked));
|
||||
revoked[revoked.length - 1]++;
|
||||
assertNull(PackSessionProof.read(key, player, pack, hash, nonce, revoked));
|
||||
nonce[0]--;
|
||||
var otherKey = PackSessionProof.secret("13".repeat(32));
|
||||
assertNull(PackSessionProof.read(otherKey, player, pack, hash, nonce, positive));
|
||||
hash[0]++;
|
||||
assertNull(PackSessionProof.read(key, player, pack, hash, nonce, positive));
|
||||
}
|
||||
}
|
||||
Loading…
Reference in a new issue

Staff