Skip to content
Draft
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -40,6 +40,20 @@
/** Tests for {@link OAuth2Utils}. */
class OAuth2UtilsTest {

@Test
void testPrivateKeyFromPkcs8_invalidKey() {
String invalidKey = "-----BEGIN PRIVATE KEY-----\n" +
"INVALID_KEY_DATA\n" +
"-----END PRIVATE KEY-----\n";
assertThrows(java.io.IOException.class, () -> OAuth2Utils.privateKeyFromPkcs8(invalidKey));

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

medium

Avoid using the fully qualified class name java.io.IOException.class. It is cleaner and more idiomatic to import java.io.IOException and use IOException.class directly.

Suggested change
assertThrows(java.io.IOException.class, () -> OAuth2Utils.privateKeyFromPkcs8(invalidKey));
assertThrows(IOException.class, () -> OAuth2Utils.privateKeyFromPkcs8(invalidKey));

}

@Test
void testPrivateKeyFromPkcs8_malformedPem() {
String malformedKey = "just some random string";
assertThrows(java.io.IOException.class, () -> OAuth2Utils.privateKeyFromPkcs8(malformedKey));

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

medium

Avoid using the fully qualified class name java.io.IOException.class. It is cleaner and more idiomatic to import java.io.IOException and use IOException.class directly.

Suggested change
assertThrows(java.io.IOException.class, () -> OAuth2Utils.privateKeyFromPkcs8(malformedKey));
assertThrows(IOException.class, () -> OAuth2Utils.privateKeyFromPkcs8(malformedKey));

}

@Test
void testValidCredentials() {
String username = "testUser";
Expand Down
Loading