Skip to content

Commit

Permalink
Merge pull request #35986 from izeye
Browse files Browse the repository at this point in the history
* gh-35986:
  Remove redundant Files.delete() calls in tests

Closes gh-35986
  • Loading branch information
scottfrederick committed Jun 23, 2023
2 parents 7b0aa7d + 4a2c9d9 commit 5ecca4b
Show file tree
Hide file tree
Showing 2 changed files with 0 additions and 9 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,6 @@
package org.springframework.boot.buildpack.platform.docker.ssl;

import java.io.IOException;
import java.nio.file.Files;
import java.nio.file.Path;
import java.security.KeyStore;
import java.security.KeyStoreException;
Expand Down Expand Up @@ -60,7 +59,6 @@ void createKeyStoreWithCertChain()
assertThat(keyStore.containsAlias("test-alias-1")).isTrue();
assertThat(keyStore.getCertificate("test-alias-1")).isNotNull();
assertThat(keyStore.getKey("test-alias-1", new char[] {})).isNull();
Files.delete(certPath);
}

@Test
Expand All @@ -72,8 +70,6 @@ void createKeyStoreWithCertChainAndRsaPrivateKey()
assertThat(keyStore.containsAlias("test-alias")).isTrue();
assertThat(keyStore.getCertificate("test-alias")).isNotNull();
assertThat(keyStore.getKey("test-alias", new char[] {})).isNotNull();
Files.delete(certPath);
Files.delete(keyPath);
}

}
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,6 @@
import java.io.IOException;
import java.net.URI;
import java.net.URISyntaxException;
import java.nio.file.Files;
import java.nio.file.Path;
import java.nio.file.Paths;
import java.security.PrivateKey;
Expand Down Expand Up @@ -63,7 +62,6 @@ void parsePkcs8RsaKeyFile() throws IOException {
PrivateKey privateKey = PrivateKeyParser.parse(path);
assertThat(privateKey).isNotNull();
assertThat(privateKey.getFormat()).isEqualTo("PKCS#8");
Files.delete(path);
}

@ParameterizedTest
Expand Down Expand Up @@ -93,7 +91,6 @@ void parsePkcs1RsaKeyFile() throws IOException {
assertThat(privateKey).isNotNull();
// keys in PKCS#1 format are converted to PKCS#8 for parsing
assertThat(privateKey.getFormat()).isEqualTo("PKCS#8");
Files.delete(path);
}

@Test
Expand All @@ -103,15 +100,13 @@ void parsePkcs1EcKeyFile() throws IOException {
assertThat(privateKey).isNotNull();
// keys in PKCS#1 format are converted to PKCS#8 for parsing
assertThat(privateKey.getFormat()).isEqualTo("PKCS#8");
Files.delete(path);
}

@Test
void parseWithNonKeyFileWillThrowException() throws IOException {
Path path = this.fileWriter.writeFile("text.pem", "plain text");
assertThatIllegalStateException().isThrownBy(() -> PrivateKeyParser.parse(path))
.withMessageContaining(path.toString());
Files.delete(path);
}

@Test
Expand Down

0 comments on commit 5ecca4b

Please sign in to comment.