Skip to content

Commit 42a8651

Browse files
committed
Enhance RegisterOAuthProviderCmdTest with additional provider mock data
1 parent b367434 commit 42a8651

1 file changed

Lines changed: 9 additions & 1 deletion

File tree

plugins/user-authenticators/oauth2/src/test/java/org/apache/cloudstack/oauth2/api/command/RegisterOAuthProviderCmdTest.java

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,7 @@
2020
package org.apache.cloudstack.oauth2.api.command;
2121

2222
import static org.junit.Assert.assertEquals;
23+
import static org.mockito.ArgumentMatchers.any;
2324
import static org.mockito.Mockito.mock;
2425
import static org.mockito.Mockito.when;
2526

@@ -46,7 +47,14 @@ public void setUp() throws Exception {
4647
@Test
4748
public void testExecute() throws ServerApiException {
4849
OauthProviderVO provider = mock(OauthProviderVO.class);
49-
when(_oauth2mgr.registerOauthProvider(_cmd)).thenReturn(provider);
50+
when(provider.getDomainId()).thenReturn(null);
51+
when(provider.getUuid()).thenReturn("test-uuid");
52+
when(provider.getProvider()).thenReturn("github");
53+
when(provider.getDescription()).thenReturn("test");
54+
when(provider.getClientId()).thenReturn("client-id");
55+
when(provider.getSecretKey()).thenReturn("secret-key");
56+
when(provider.getRedirectUri()).thenReturn("http://localhost");
57+
when(_oauth2mgr.registerOauthProvider(any(RegisterOAuthProviderCmd.class))).thenReturn(provider);
5058

5159
_cmd.execute();
5260
assertEquals(ApiConstants.OAUTH_PROVIDER, ((OauthProviderResponse)_cmd.getResponseObject()).getObjectName());

0 commit comments

Comments
 (0)