Skip to content

Commit 244b729

Browse files
committed
Disable autoformatting on build, and block Java11 Codebuilds on bad formatting
1 parent 926bc95 commit 244b729

File tree

8 files changed

+17
-30
lines changed

8 files changed

+17
-30
lines changed

codebuild/corretto11.yml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,4 +6,5 @@ phases:
66
java: corretto11
77
build:
88
commands:
9+
- mvn com.coveo:fmt-maven-plugin:check
910
- mvn install -Dgpg.skip=true '-DtestVectorZip=https://github.com/awslabs/aws-encryption-sdk-test-vectors/raw/master/vectors/awses-decrypt/python-1.3.8.zip'

codebuild/openjdk11.yml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,4 +6,5 @@ phases:
66
java: openjdk11
77
build:
88
commands:
9+
- mvn com.coveo:fmt-maven-plugin:check
910
- mvn install -Dgpg.skip=true '-DtestVectorZip=https://github.com/awslabs/aws-encryption-sdk-test-vectors/raw/master/vectors/awses-decrypt/python-1.3.8.zip'

pom.xml

Lines changed: 5 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -142,14 +142,11 @@
142142
<plugin>
143143
<groupId>com.coveo</groupId>
144144
<artifactId>fmt-maven-plugin</artifactId>
145-
<version>2.9</version>
146-
<executions>
147-
<execution>
148-
<goals>
149-
<goal>format</goal>
150-
</goals>
151-
</execution>
152-
</executions>
145+
<version>2.10</version>
146+
<!-- Configure no goals. -->
147+
<!--Until our CI builds no longer depend on Java 8, skip this during build.-->
148+
<!--We instead manually check this in Java 11 environments to block builds, -->
149+
<!--And additionally check this explicitly through Github Actions.-->
153150
</plugin>
154151
</plugins>
155152
</build>

src/test/java/com/amazonaws/encryptionsdk/AwsCryptoTest.java

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -406,8 +406,7 @@ public EncryptionMaterials getMaterialsForEncrypt(EncryptionMaterialsRequest req
406406
new DefaultCryptoMaterialsManager(masterKeyProvider)
407407
.getMaterialsForEncrypt(request);
408408

409-
return encryptionMaterials
410-
.toBuilder()
409+
return encryptionMaterials.toBuilder()
411410
.setAlgorithm(CryptoAlgorithm.ALG_AES_256_GCM_HKDF_SHA512_COMMIT_KEY_ECDSA_P384)
412411
.build();
413412
}
@@ -1094,8 +1093,7 @@ public EncryptionMaterials getMaterialsForEncrypt(EncryptionMaterialsRequest req
10941093
new DefaultCryptoMaterialsManager(masterKeyProvider)
10951094
.getMaterialsForEncrypt(request);
10961095

1097-
return encryptionMaterials
1098-
.toBuilder()
1096+
return encryptionMaterials.toBuilder()
10991097
.setAlgorithm(CryptoAlgorithm.ALG_AES_256_GCM_IV12_TAG16_HKDF_SHA384_ECDSA_P384)
11001098
.build();
11011099
}

src/test/java/com/amazonaws/encryptionsdk/caching/CacheTestFixtures.java

Lines changed: 2 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -33,10 +33,7 @@ public static EncryptionMaterialsRequest createMaterialsRequest(int index) {
3333

3434
public static EncryptionMaterials createMaterialsResult(EncryptionMaterialsRequest request) {
3535
return new DefaultCryptoMaterialsManager(FIXED_KEY)
36-
.getMaterialsForEncrypt(request)
37-
.toBuilder()
38-
.setCleartextDataKey(new SentinelKey())
39-
.build();
36+
.getMaterialsForEncrypt(request).toBuilder().setCleartextDataKey(new SentinelKey()).build();
4037
}
4138

4239
public static DecryptionMaterialsRequest createDecryptRequest(int index) {
@@ -57,8 +54,7 @@ public static DecryptionMaterialsRequest createDecryptRequest(EncryptionMaterial
5754
public static DecryptionMaterials createDecryptResult(DecryptionMaterialsRequest request) {
5855
DecryptionMaterials realResult =
5956
new DefaultCryptoMaterialsManager(FIXED_KEY).decryptMaterials(request);
60-
return realResult
61-
.toBuilder()
57+
return realResult.toBuilder()
6258
.setDataKey(
6359
new DataKey(
6460
new SentinelKey(),

src/test/java/com/amazonaws/encryptionsdk/caching/CachingCryptoMaterialsManagerTest.java

Lines changed: 3 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -116,8 +116,7 @@ public void whenAlgorithmIsUncachable_resultNotStoredInCache() throws Exception
116116
EncryptionMaterialsRequest request =
117117
CacheTestFixtures.createMaterialsRequest(0).toBuilder().setPlaintextSize(100).build();
118118
EncryptionMaterials result =
119-
CacheTestFixtures.createMaterialsResult(request)
120-
.toBuilder()
119+
CacheTestFixtures.createMaterialsResult(request).toBuilder()
121120
.setAlgorithm(CryptoAlgorithm.ALG_AES_128_GCM_IV12_TAG16_NO_KDF)
122121
.build();
123122
setupForCacheMiss(request, result);
@@ -139,16 +138,14 @@ public void whenAlgorithmIsUncachable_resultNotStoredInCache() throws Exception
139138
@Test
140139
public void whenInitialUsageExceedsLimit_cacheIsBypassed() throws Exception {
141140
EncryptionMaterialsRequest request =
142-
CacheTestFixtures.createMaterialsRequest(0)
143-
.toBuilder()
141+
CacheTestFixtures.createMaterialsRequest(0).toBuilder()
144142
// Even at _exactly_ the byte-use limit, we won't try the cache,
145143
// because it's unlikely to be useful to leave an entry with zero
146144
// bytes remaining.
147145
.setPlaintextSize(200)
148146
.build();
149147
EncryptionMaterials result =
150-
CacheTestFixtures.createMaterialsResult(request)
151-
.toBuilder()
148+
CacheTestFixtures.createMaterialsResult(request).toBuilder()
152149
.setAlgorithm(CryptoAlgorithm.ALG_AES_256_GCM_HKDF_SHA512_COMMIT_KEY)
153150
.build();
154151
setupForCacheMiss(request, result);

src/test/java/com/amazonaws/encryptionsdk/caching/LocalCryptoMaterialsCacheThreadStormTest.java

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -139,8 +139,7 @@ public void decryptAddThread() {
139139

140140
CacheTestFixtures.SentinelKey key = new CacheTestFixtures.SentinelKey();
141141
DecryptionMaterials result =
142-
BASE_DECRYPT
143-
.toBuilder()
142+
BASE_DECRYPT.toBuilder()
144143
.setDataKey(
145144
new DataKey(
146145
key, new byte[0], new byte[0], BASE_DECRYPT.getDataKey().getMasterKey()))
@@ -225,8 +224,7 @@ public void encryptAddThread() {
225224
ThreadLocalRandom.current().nextBytes(ref);
226225

227226
EncryptionMaterials result =
228-
BASE_ENCRYPT
229-
.toBuilder()
227+
BASE_ENCRYPT.toBuilder()
230228
.setCleartextDataKey(new CacheTestFixtures.SentinelKey())
231229
.build();
232230
ConcurrentHashMap<CacheTestFixtures.SentinelKey, Object> keys =

src/test/java/com/amazonaws/encryptionsdk/internal/EncryptionHandlerTest.java

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -149,8 +149,7 @@ public void whenConstructWithForbidPolicyAndNonCommittingAlg_succeeds() throws E
149149
@Test
150150
public void whenConstructWithRequirePolicyAndNonCommittingAlg_fails() throws Exception {
151151
final EncryptionMaterials resultWithV1Alg =
152-
testResult
153-
.toBuilder()
152+
testResult.toBuilder()
154153
.setAlgorithm(CryptoAlgorithm.ALG_AES_256_GCM_IV12_TAG16_HKDF_SHA384_ECDSA_P384)
155154
.build();
156155

0 commit comments

Comments
 (0)