use of org.wso2.carbon.identity.oauth.dcr.internal.DCRDataHolder in project identity-inbound-auth-oauth by wso2-extensions.
the class DCRMServiceTest method updateApplication.
private OAuthConsumerAppDTO updateApplication() throws IdentityOAuthAdminException, IdentityApplicationManagementException {
startTenantFlow();
dummyGrantTypes.add("dummy1");
dummyGrantTypes.add("dummy2");
applicationUpdateRequest = new ApplicationUpdateRequest();
applicationUpdateRequest.setClientName(dummyClientName);
applicationUpdateRequest.setGrantTypes(dummyGrantTypes);
applicationUpdateRequest.setTokenType(dummyTokenType);
applicationUpdateRequest.setBackchannelLogoutUri(dummyBackchannelLogoutUri);
OAuthConsumerAppDTO dto = new OAuthConsumerAppDTO();
dto.setApplicationName(dummyClientName);
dto.setOauthConsumerSecret(dummyConsumerSecret);
dto.setOauthConsumerKey(dummyConsumerKey);
dto.setCallbackUrl(dummyCallbackUrl);
dto.setUsername(dummyUserName.concat("@").concat(dummyTenantDomain));
when(mockOAuthAdminService.getOAuthApplicationData(dummyConsumerKey)).thenReturn(dto);
Whitebox.setInternalState(dcrmService, "oAuthAdminService", mockOAuthAdminService);
ServiceProvider serviceProvider = new ServiceProvider();
serviceProvider.setApplicationName(dummyClientName);
DCRDataHolder dcrDataHolder = DCRDataHolder.getInstance();
dcrDataHolder.setApplicationManagementService(mockApplicationManagementService);
when(mockApplicationManagementService.getServiceProvider(dummyClientName, dummyTenantDomain)).thenReturn(serviceProvider);
return dto;
}
use of org.wso2.carbon.identity.oauth.dcr.internal.DCRDataHolder in project identity-inbound-auth-oauth by wso2-extensions.
the class DCRManagementServiceTest method registerOAuthApplicationWithNewSPNoRedirectUri.
@Test
public void registerOAuthApplicationWithNewSPNoRedirectUri() throws Exception {
registerOAuthApplication();
registrationRequestProfile.setRedirectUris(new ArrayList<>());
mockApplicationManagementService = mock(ApplicationManagementService.class);
DCRDataHolder dcrDataHolder = DCRDataHolder.getInstance();
dcrDataHolder.setApplicationManagementService(mockApplicationManagementService);
when(mockApplicationManagementService.getServiceProvider(applicationName, tenantDomain)).thenReturn(null, new ServiceProvider());
try {
dcrManagementService.registerOAuthApplication(registrationRequestProfile);
} catch (IdentityException ex) {
assertEquals(ex.getMessage(), "RedirectUris property must have at least one URI value.");
return;
}
fail("Expected IdentityException was not thrown by registerOAuthApplication method");
}
use of org.wso2.carbon.identity.oauth.dcr.internal.DCRDataHolder in project identity-inbound-auth-oauth by wso2-extensions.
the class DCRManagementServiceTest method registerOAuthApplicationWithInvalidSPName.
@Test
public void registerOAuthApplicationWithInvalidSPName() throws Exception {
registerOAuthApplication();
mockApplicationManagementService = mock(ApplicationManagementService.class);
ServiceProvider serviceProvider = new ServiceProvider();
DCRDataHolder dcrDataHolder = DCRDataHolder.getInstance();
dcrDataHolder.setApplicationManagementService(mockApplicationManagementService);
when(mockApplicationManagementService.getServiceProvider(applicationName, tenantDomain)).thenReturn(serviceProvider);
assertNotNull(dcrDataHolder);
registrationRequestProfile.setClientName(invalidClientName);
try {
dcrManagementService.registerOAuthApplication(registrationRequestProfile);
} catch (IdentityException ex) {
assertEquals(ex.getMessage(), "The Application name: " + invalidClientName + " is not valid! It is not adhering to" + " the regex: " + DCRMUtils.getSPValidatorRegex());
return;
}
fail("Expected IdentityException was not thrown by registerOAuthApplication method");
}
use of org.wso2.carbon.identity.oauth.dcr.internal.DCRDataHolder in project identity-inbound-auth-oauth by wso2-extensions.
the class DCRManagementServiceTest method oAuthApplicationAvailableExceptionTest.
@Test
public void oAuthApplicationAvailableExceptionTest() throws Exception {
startTenantFlow();
mockApplicationManagementService = mock(ApplicationManagementService.class);
DCRDataHolder dcrDataHolder = DCRDataHolder.getInstance();
dcrDataHolder.setApplicationManagementService(mockApplicationManagementService);
doThrow(new IdentityApplicationManagementException("")).when(mockApplicationManagementService).getServiceProvider(applicationName, tenantDomain);
try {
dcrManagementService.isOAuthApplicationAvailable(applicationName);
} catch (DCRException ex) {
assertEquals(ex.getMessage(), "Error occurred while retrieving information of OAuthApp " + applicationName);
return;
}
fail("Expected IdentityException was not thrown by isOAuthApplicationAvailable method");
}
use of org.wso2.carbon.identity.oauth.dcr.internal.DCRDataHolder in project identity-inbound-auth-oauth by wso2-extensions.
the class DCRManagementServiceTest method registerOAuthApplicationWithNullExistingSP.
@Test
public void registerOAuthApplicationWithNullExistingSP() {
registerOAuthApplication();
mockApplicationManagementService = mock(ApplicationManagementService.class);
DCRDataHolder dcrDataHolder = DCRDataHolder.getInstance();
dcrDataHolder.setApplicationManagementService(mockApplicationManagementService);
assertNotNull(dcrDataHolder, "null DCRDataHolder");
try {
dcrManagementService.registerOAuthApplication(registrationRequestProfile);
} catch (IdentityException ex) {
assertEquals(ex.getMessage(), "Couldn't create Service Provider Application " + applicationName);
return;
}
fail("Expected IdentityException was not thrown by registerOAuthApplication method");
}
Aggregations