Skip to content

Commit

Permalink
Merge branch '1.2.x'
Browse files Browse the repository at this point in the history
Closes gh-1657
  • Loading branch information
jgrandja committed Jun 25, 2024
2 parents d8b5e78 + 520fe25 commit ce76f5c
Show file tree
Hide file tree
Showing 2 changed files with 26 additions and 7 deletions.
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/*
* Copyright 2020-2023 the original author or authors.
* Copyright 2020-2024 the original author or authors.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
Expand Down Expand Up @@ -174,11 +174,13 @@ private void assertUniqueIdentifiers(RegisteredClient registeredClient) {
throw new IllegalArgumentException("Registered client must be unique. "
+ "Found duplicate client identifier: " + registeredClient.getClientId());
}
count = this.jdbcOperations.queryForObject(COUNT_REGISTERED_CLIENT_SQL + "client_secret = ?", Integer.class,
registeredClient.getClientSecret());
if (count != null && count > 0) {
throw new IllegalArgumentException("Registered client must be unique. "
+ "Found duplicate client secret for identifier: " + registeredClient.getId());
if (StringUtils.hasText(registeredClient.getClientSecret())) {
count = this.jdbcOperations.queryForObject(COUNT_REGISTERED_CLIENT_SQL + "client_secret = ?", Integer.class,
registeredClient.getClientSecret());
if (count != null && count > 0) {
throw new IllegalArgumentException("Registered client must be unique. "
+ "Found duplicate client secret for identifier: " + registeredClient.getId());
}
}
}

Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/*
* Copyright 2020-2023 the original author or authors.
* Copyright 2020-2024 the original author or authors.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
Expand Down Expand Up @@ -168,6 +168,23 @@ public void saveWhenClientSecretNullThenSaved() {
assertThat(registeredClient).isEqualTo(expectedRegisteredClient);
}

// gh-1641
@Test
public void saveWhenMultipleWithClientSecretEmptyThenSaved() {
RegisteredClient registeredClient1 = TestRegisteredClients.registeredClient()
.id("registration-1")
.clientId("client-1")
.clientSecret("")
.build();
this.registeredClientRepository.save(registeredClient1);
RegisteredClient registeredClient2 = TestRegisteredClients.registeredClient()
.id("registration-2")
.clientId("client-2")
.clientSecret("")
.build();
this.registeredClientRepository.save(registeredClient2);
}

@Test
public void saveWhenExistingClientIdThenThrowIllegalArgumentException() {
RegisteredClient registeredClient1 = TestRegisteredClients.registeredClient()
Expand Down

0 comments on commit ce76f5c

Please sign in to comment.