Skip to content

Commit 911c794

Browse files
committed
Replace remove method with expunge in deleteOauthProvider and add corresponding unit test
1 parent df8c869 commit 911c794

2 files changed

Lines changed: 13 additions & 1 deletion

File tree

plugins/user-authenticators/oauth2/src/main/java/org/apache/cloudstack/oauth2/OAuth2AuthManagerImpl.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -236,7 +236,7 @@ private OauthProviderVO saveOauthProvider(String provider, String description, S
236236

237237
@Override
238238
public boolean deleteOauthProvider(Long id) {
239-
return _oauthProviderDao.remove(id);
239+
return _oauthProviderDao.expunge(id);
240240
}
241241

242242
@Override

plugins/user-authenticators/oauth2/src/test/java/org/apache/cloudstack/oauth2/OAuth2AuthManagerImplTest.java

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -176,6 +176,18 @@ public void testListOauthProviders() {
176176
assertEquals(providerList, result);
177177
}
178178

179+
@Test
180+
public void testDeleteOauthProviderHardDeletes() {
181+
Long providerId = 42L;
182+
when(_oauthProviderDao.expunge(providerId)).thenReturn(true);
183+
184+
boolean result = _authManager.deleteOauthProvider(providerId);
185+
186+
assertTrue(result);
187+
Mockito.verify(_oauthProviderDao).expunge(providerId);
188+
Mockito.verify(_oauthProviderDao, Mockito.never()).remove(Mockito.anyLong());
189+
}
190+
179191
@Test
180192
public void testGetCommands() {
181193
List<Class<?>> expectedCmdList = new ArrayList<>();

0 commit comments

Comments
 (0)