Skip to content

Commit

Permalink
Sonar findings
Browse files Browse the repository at this point in the history
  • Loading branch information
strehle committed Aug 24, 2023
1 parent 73599e8 commit 82a5857
Show file tree
Hide file tree
Showing 3 changed files with 37 additions and 6 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -27,13 +27,12 @@ public UaaClientDetails() {

UaaClientDetails(ClientDetails prototype) {
super(prototype);
this.setAdditionalInformation(prototype.getAdditionalInformation());
setAdditionalInformation(prototype.getAdditionalInformation());
}

public UaaClientDetails(String clientId, String clientSecret, String clientJwtConfig, String resourceIds,
public UaaClientDetails(String clientId, String resourceIds,
String scopes, String grantTypes, String authorities, String redirectUris) {
super(clientId, resourceIds, scopes, grantTypes, authorities, redirectUris);
setClientSecret(clientSecret);
this.clientJwtConfig = clientJwtConfig;
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -307,14 +307,14 @@ private static class ClientDetailsRowMapper implements RowMapper<ClientDetails>
public ClientDetails mapRow(ResultSet rs, int rowNum) throws SQLException {
UaaClientDetails details = new UaaClientDetails(
rs.getString(1),
rs.getString(2),
rs.getString(3),
rs.getString(4),
rs.getString(5),
rs.getString(6),
rs.getString(8),
rs.getString(7)
);
details.setClientSecret(rs.getString(2));
details.setClientJwtConfig(rs.getString(3));
if (rs.getObject(9) != null) {
details.setAccessTokenValiditySeconds(rs.getInt(9));
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -19,9 +19,12 @@
import static org.hamcrest.collection.IsIterableContainingInOrder.contains;
import static org.hamcrest.collection.IsMapContaining.hasEntry;
import static org.hamcrest.collection.IsMapWithSize.aMapWithSize;
import static org.junit.jupiter.api.Assertions.assertEquals;
import static org.junit.jupiter.api.Assertions.assertNotEquals;

class UaaClientDetailsTest {
@Nested

@Nested
class Creation {
private BaseClientDetails testClient;

Expand Down Expand Up @@ -63,6 +66,35 @@ void copiesAdditionalInformation() {
.withAdditionalInformation(allOf(aMapWithSize(1), hasEntry("key", "value")))
));
}

@Test
void testClientJwtConfig() {
UaaClientDetails copy = new UaaClientDetails(testClient);
copy.setClientJwtConfig("test");
assertEquals("test", copy.getClientJwtConfig());
}

@Test
void testEquals() {
UaaClientDetails copy = new UaaClientDetails(testClient);
UaaClientDetails copy2 = new UaaClientDetails(testClient);
copy.setClientJwtConfig("test");
assertNotEquals(copy, copy2);
assertNotEquals(copy, new UaaClientDetails());
copy.setClientJwtConfig(null);
assertEquals(copy, copy2);
}

@Test
void testHashCode() {
UaaClientDetails copy = new UaaClientDetails(testClient);
UaaClientDetails copy2 = new UaaClientDetails(testClient.getClientId(), "",
"test.none", "", "test.admin", null);
copy.setClientJwtConfig("test");
assertNotEquals(copy.hashCode(), copy2.hashCode());
copy.setClientJwtConfig(null);
assertEquals(copy.hashCode(), copy2.hashCode());
}
}

@Nested
Expand Down

0 comments on commit 82a5857

Please sign in to comment.