SdcKeysManager sm = new SdcKeysManager();
sm.storeSessionKey(sessionId,
SessionEncryption.JCE_ALGO, SessionEncryption.newKeyBytes());
FrameInfo frameInfo = FrameInfo.newBuilder()
.setSessionId(sessionId)
.setPayload(sm.getSessionEncryption().encrypt(request.toByteString())).build();
FetchRequestHandler handler = new FetchRequestHandler(
sm,
EasyMock.createMock(ThreadPoolExecutor.class),
EasyMock.createMock(Injector.class),
EasyMock.createMock(ClockUtil.class));
FetchRequest parsed = sm.getSessionEncryption().getFrom(frameInfo,
new SessionEncryption.Parse<FetchRequest>() {
public FetchRequest parse(ByteString s) throws InvalidProtocolBufferException {
return FetchRequest.parseFrom(s);
}
});
assertEquals(request, parsed);
FrameInfo frameInfo2 = FrameInfo.newBuilder()
.setSessionId(UUID.randomUUID().toString())
.setPayload(sm.getSessionEncryption().encrypt(request.toByteString())).build();
FetchRequest parsed2 = sm.getSessionEncryption().getFrom(frameInfo2,
new SessionEncryption.Parse<FetchRequest>() {