Skip to content

Commit 90aa02f

Browse files
committed
Style fixes from Sonar CI
1 parent 786c557 commit 90aa02f

File tree

6 files changed

+10
-23
lines changed

6 files changed

+10
-23
lines changed

sdk/src/main/java/io/opentdf/platform/sdk/Manifest.java

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -483,8 +483,6 @@ protected static Manifest readManifest(Reader reader) {
483483
throw new IllegalArgumentException("Manifest with null encryptionInformation");
484484
} else if (result.encryptionInformation.integrityInformation == null) {
485485
throw new IllegalArgumentException("Manifest with null integrityInformation");
486-
} else if (result.encryptionInformation.integrityInformation.segments == null) {
487-
throw new IllegalArgumentException("Manifest with invalid integrityInformation");
488486
} else if (result.encryptionInformation.integrityInformation.rootSignature == null) {
489487
throw new IllegalArgumentException("Manifest with null rootSignature");
490488
} else if (result.encryptionInformation.integrityInformation.rootSignature.algorithm == null

sdk/src/main/java/io/opentdf/platform/sdk/TDF.java

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -361,9 +361,7 @@ public void readPayload(OutputStream outputStream) throws TDFReadFailed,
361361
for (Manifest.Segment segment : manifest.encryptionInformation.integrityInformation.segments) {
362362
if (segment.encryptedSegmentSize > Config.MAX_SEGMENT_SIZE) {
363363
throw new IllegalStateException("Segment size " + segment.encryptedSegmentSize + " exceeded limit " + Config.MAX_SEGMENT_SIZE);
364-
}/* else if (segment.encryptedSegmentSize < Config.MIN_SEGMENT_SIZE) {
365-
throw new IllegalStateException("Segment size " + segment.encryptedSegmentSize + " is under minimum " + Config.MIN_SEGMENT_SIZE);
366-
}*/ // Commented out due to tests needing small segment sizes with existing payloads
364+
} // MIN_SEGMENT_SIZE NOT validated out due to tests needing small segment sizes with existing payloads
367365

368366
byte[] readBuf = new byte[(int) segment.encryptedSegmentSize];
369367
int bytesRead = tdfReader.readPayloadBytes(readBuf);

sdk/src/test/java/io/opentdf/platform/sdk/ConfigTest.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -54,7 +54,7 @@ void withSegmentSize_shouldSetSegmentSize() {
5454
@Test
5555
void withSegmentSize_shouldIgnoreSegmentSize() {
5656
try {
57-
Config.newTDFConfig(Config.withSegmentSize(1024));
57+
Config.withSegmentSize(1024);
5858
fail("Expected exception");
5959
} catch (IllegalArgumentException e) {
6060
// expected

sdk/src/test/java/io/opentdf/platform/sdk/Fuzzing.java

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -18,27 +18,27 @@
1818
import io.opentdf.platform.sdk.TDF.Reader;
1919

2020
public class Fuzzing {
21-
private static final String testDuration = "600s";
22-
private static final OutputStream ignoreOutputStream = new OutputStream() {
21+
private static final String TEST_DURATION = "600s";
22+
private static final OutputStream IGNORE_OUTPUT_STREAM = new OutputStream() {
2323
@Override
2424
public void write(int b) {
2525
// ignored
2626
}
2727

2828
@Override
29-
public void write(byte b[], int off, int len) {
29+
public void write(byte[] b, int off, int len) {
3030
// ignored
3131
}
3232
};
3333

34-
@FuzzTest(maxDuration=testDuration)
34+
@FuzzTest(maxDuration=TEST_DURATION)
3535
public void fuzzNanoTDF(FuzzedDataProvider data) throws IOException {
3636
byte[] fuzzBytes = data.consumeRemainingAsBytes();
3737
NanoTDF nanoTDF = new NanoTDF();
38-
nanoTDF.readNanoTDF(ByteBuffer.wrap(fuzzBytes), ignoreOutputStream, NanoTDFTest.kas);
38+
nanoTDF.readNanoTDF(ByteBuffer.wrap(fuzzBytes), IGNORE_OUTPUT_STREAM, NanoTDFTest.kas);
3939
}
4040

41-
@FuzzTest(maxDuration=testDuration)
41+
@FuzzTest(maxDuration=TEST_DURATION)
4242
public void fuzzTDF(FuzzedDataProvider data) throws FailedToCreateGMAC, NoSuchAlgorithmException, IOException, JOSEException, ParseException, DecoderException {
4343
byte[] fuzzBytes = data.consumeRemainingAsBytes();
4444
byte[] key = new byte[32]; // use consistent zero key for performance and so fuzz can relate to seed
@@ -51,13 +51,13 @@ public void fuzzTDF(FuzzedDataProvider data) throws FailedToCreateGMAC, NoSuchAl
5151
try {
5252
Reader reader = tdf.loadTDF(new SeekableInMemoryByteChannel(fuzzBytes), TDFTest.kas, readerConfig);
5353

54-
reader.readPayload(ignoreOutputStream);
54+
reader.readPayload(IGNORE_OUTPUT_STREAM);
5555
} catch (SDKException | InvalidZipException | JsonParseException | IOException | IllegalArgumentException e) {
5656
// expected failure cases
5757
}
5858
}
5959

60-
@FuzzTest(maxDuration=testDuration)
60+
@FuzzTest(maxDuration=TEST_DURATION)
6161
public void fuzzZipRead(FuzzedDataProvider data) {
6262
byte[] fuzzBytes = data.consumeRemainingAsBytes();
6363
try {

sdk/src/test/java/io/opentdf/platform/sdk/TDFTest.java

Lines changed: 0 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,6 @@
11
package io.opentdf.platform.sdk;
22

3-
import com.google.common.util.concurrent.ListenableFuture;
4-
53
import com.nimbusds.jose.JOSEException;
6-
import io.opentdf.platform.policy.attributes.GetAttributeValuesByFqnsRequest;
7-
import io.opentdf.platform.policy.attributes.GetAttributeValuesByFqnsResponse;
8-
import io.opentdf.platform.policy.attributes.AttributesServiceGrpc;
94
import io.opentdf.platform.sdk.Config.KASInfo;
105
import io.opentdf.platform.sdk.TDF.Reader;
116
import io.opentdf.platform.sdk.nanotdf.NanoTDFType;

sdk/src/test/java/io/opentdf/platform/sdk/ZipReaderTest.java

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,4 @@
11
package io.opentdf.platform.sdk;
2-
import com.google.gson.Gson;
32
import com.google.gson.GsonBuilder;
43

54
import io.opentdf.platform.sdk.Manifest.ManifestDeserializer;
@@ -12,13 +11,10 @@
1211

1312
import java.io.ByteArrayInputStream;
1413
import java.io.ByteArrayOutputStream;
15-
import java.io.File;
1614
import java.io.IOException;
1715
import java.io.RandomAccessFile;
1816
import java.nio.channels.SeekableByteChannel;
1917
import java.nio.charset.StandardCharsets;
20-
import java.nio.file.Files;
21-
import java.nio.file.Path;
2218
import java.util.HashMap;
2319
import java.util.Map;
2420
import java.util.Random;

0 commit comments

Comments
 (0)