-
Notifications
You must be signed in to change notification settings - Fork 786
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Add: Scope update validation with http client configs
- Loading branch information
Showing
3 changed files
with
405 additions
and
0 deletions.
There are no files selected for viewing
112 changes: 112 additions & 0 deletions
112
...backend/src/test/java/org/wso2/am/integration/tests/other/SharedScopeTestWIthRestart.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,112 @@ | ||
package org.wso2.am.integration.tests.other; | ||
|
||
import org.apache.commons.logging.Log; | ||
import org.apache.commons.logging.LogFactory; | ||
import org.testng.Assert; | ||
import org.testng.annotations.AfterClass; | ||
import org.testng.annotations.BeforeClass; | ||
import org.testng.annotations.DataProvider; | ||
import org.testng.annotations.Factory; | ||
import org.testng.annotations.Test; | ||
import org.wso2.am.integration.clients.publisher.api.v1.dto.ScopeDTO; | ||
import org.wso2.am.integration.test.utils.base.APIMIntegrationConstants; | ||
import org.wso2.am.integration.tests.api.lifecycle.APIManagerLifecycleBaseTest; | ||
import org.wso2.carbon.automation.engine.context.AutomationContext; | ||
import org.wso2.carbon.automation.engine.context.TestUserMode; | ||
import org.wso2.carbon.integration.common.utils.mgt.ServerConfigurationManager; | ||
|
||
import java.io.File; | ||
import java.util.ArrayList; | ||
import java.util.List; | ||
|
||
public class SharedScopeTestWIthRestart extends APIManagerLifecycleBaseTest { | ||
private final Log log = LogFactory.getLog(SharedScopeTestCase.class); | ||
|
||
private String sharedScopeName = "TestSharedScopeWithRestart"; | ||
private String sharedScopeDisplayName = "Test Shared Scope with Restart"; | ||
private String description = "This is a test shared scope with Restart"; | ||
private String updatedDescription = "This is a updated test shared scope with Restart"; | ||
private String updatedDescription1 = "This is a updated test shared scope with Restart(2)"; | ||
private String updatedDescription2 = "This is a updated test shared scope with Restart(3)"; | ||
private List<String> roles = new ArrayList<>(); | ||
private String sharedScopeId; | ||
private ServerConfigurationManager serverConfigurationManager; | ||
|
||
@Factory(dataProvider = "userModeDataProvider") | ||
public SharedScopeTestWIthRestart(TestUserMode userMode) { | ||
this.userMode = userMode; | ||
} | ||
|
||
@DataProvider | ||
public static Object[][] userModeDataProvider() { | ||
return new Object[][] { new Object[] { TestUserMode.SUPER_TENANT_ADMIN }}; | ||
} | ||
|
||
@BeforeClass(alwaysRun = true) | ||
public void setEnvironment() throws Exception { | ||
super.init(userMode); | ||
superTenantKeyManagerContext = new AutomationContext(APIMIntegrationConstants.AM_PRODUCT_GROUP_NAME, | ||
APIMIntegrationConstants.AM_KEY_MANAGER_INSTANCE, | ||
TestUserMode.SUPER_TENANT_ADMIN); | ||
serverConfigurationManager = new ServerConfigurationManager(superTenantKeyManagerContext); | ||
serverConfigurationManager.applyConfiguration(new File( | ||
getAMResourceLocation() + File.separator + "operationPolicy" | ||
+ File.separator + "deployment.toml")); | ||
serverConfigurationManager.restartGracefully(); | ||
} | ||
|
||
@Test(groups = { "wso2.am" }, description = "Test add shared scope") | ||
public void testAddSharedScope() throws Exception { | ||
ScopeDTO scopeDTO = new ScopeDTO(); | ||
scopeDTO.setName(sharedScopeName); | ||
scopeDTO.setDisplayName(sharedScopeDisplayName); | ||
scopeDTO.setDescription(description); | ||
|
||
roles.add("Internal/publisher"); | ||
roles.add("admin"); | ||
scopeDTO.setBindings(roles); | ||
|
||
ScopeDTO addedScopeDTO = restAPIPublisher.addSharedScope(scopeDTO); | ||
sharedScopeId = addedScopeDTO.getId(); | ||
Assert.assertNotNull(sharedScopeId, "The scope ID cannot be null or empty"); | ||
} | ||
|
||
@Test(groups = { "wso2.am" }, description = "Test get and update shared scope", | ||
dependsOnMethods = "testAddSharedScope") | ||
public void testGetAndUpdateSharedScope() throws Exception { | ||
ScopeDTO sharedScopeDTO = restAPIPublisher.getSharedScopeById(sharedScopeId); | ||
Assert.assertEquals(sharedScopeDTO.getName(), sharedScopeName, | ||
"Shared scope name does not match with the expected name"); | ||
Assert.assertEquals(sharedScopeDTO.getDisplayName(), sharedScopeDisplayName, | ||
"Shared scope display name does not match with the expected display name"); | ||
Assert.assertTrue(sharedScopeDTO.getBindings().contains("admin"), | ||
"Shared scope does not include the expected role"); | ||
|
||
sharedScopeDTO.setDescription(updatedDescription); | ||
ScopeDTO updateScopeDTO = restAPIPublisher.updateSharedScope(sharedScopeId, sharedScopeDTO); | ||
Assert.assertEquals(updateScopeDTO.getDescription(), updatedDescription, | ||
"Shared scope description does not match with the expected description"); | ||
|
||
sharedScopeDTO.setDescription(updatedDescription1); | ||
updateScopeDTO = restAPIPublisher.updateSharedScope(sharedScopeId, sharedScopeDTO); | ||
Assert.assertEquals(updateScopeDTO.getDescription(), updatedDescription1, | ||
"Shared scope description does not match with the expected description"); | ||
|
||
sharedScopeDTO.setDescription(updatedDescription2); | ||
updateScopeDTO = restAPIPublisher.updateSharedScope(sharedScopeId, sharedScopeDTO); | ||
Assert.assertEquals(updateScopeDTO.getDescription(), updatedDescription2, | ||
"Shared scope description does not match with the expected description"); | ||
} | ||
|
||
@Test(groups = { "wso2.am" }, description = "Test get and update shared scope", | ||
dependsOnMethods = "testGetAndUpdateSharedScope") | ||
public void testDeleteSharedScope() throws Exception { | ||
restAPIPublisher.deleteSharedScope(sharedScopeId); | ||
} | ||
|
||
@AfterClass(alwaysRun = true) | ||
public void destroy() throws Exception { | ||
serverConfigurationManager = new ServerConfigurationManager(superTenantKeyManagerContext); | ||
serverConfigurationManager.restoreToLastConfiguration(); | ||
} | ||
} |
286 changes: 286 additions & 0 deletions
286
...integration/tests-backend/src/test/resources/artifacts/AM/operationPolicy/deployment.toml
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,286 @@ | ||
[server] | ||
hostname = "localhost" | ||
#offset=0 | ||
base_path = "${carbon.protocol}://${carbon.host}:${carbon.management.port}" | ||
server_role = "default" | ||
enable_shutdown_from_api = true | ||
enable_restart_from_api = true | ||
|
||
[super_admin] | ||
username = "admin" | ||
password = "admin" | ||
create_admin_account = true | ||
|
||
[user_store] | ||
type = "database_unique_id" | ||
|
||
[database.apim_db] | ||
driver = "$env{API_MANAGER_DATABASE_DRIVER}" | ||
url = "$env{API_MANAGER_DATABASE_URL}" | ||
username = "$env{API_MANAGER_DATABASE_USERNAME}" | ||
password = "$env{API_MANAGER_DATABASE_PASSWORD}" | ||
validationQuery = "$env{API_MANAGER_DATABASE_VALIDATION_QUERY}" | ||
|
||
[database.shared_db] | ||
driver = "$env{SHARED_DATABASE_DRIVER}" | ||
url = "$env{SHARED_DATABASE_URL}" | ||
username = "$env{SHARED_DATABASE_USERNAME}" | ||
password = "$env{SHARED_DATABASE_PASSWORD}" | ||
validationQuery = "$env{SHARED_DATABASE_VALIDATION_QUERY}" | ||
|
||
[keystore.tls] | ||
file_name = "wso2carbon.jks" | ||
type = "JKS" | ||
password = "wso2carbon" | ||
alias = "wso2carbon" | ||
key_password = "wso2carbon" | ||
|
||
[[apim.gateway.environment]] | ||
name = "Default" | ||
type = "hybrid" | ||
provider = "wso2" | ||
display_in_api_console = true | ||
description = "This is a hybrid gateway that handles both production and sandbox token traffic." | ||
show_as_token_endpoint_url = true | ||
service_url = "https://localhost:${mgt.transport.https.port}/services/" | ||
username = "admin" | ||
password = "admin" | ||
ws_endpoint = "ws://localhost:9099" | ||
http_endpoint = "http://localhost:${http.nio.port}" | ||
https_endpoint = "https://localhost:${https.nio.port}" | ||
|
||
[[apim.gateway.environment]] | ||
name = "devportalEnv" | ||
display_name = "Developer portal Test Environment" | ||
type = "hybrid" | ||
display_in_api_console = false | ||
description = "development api gateway broker" | ||
provider = "solace" | ||
service_url = "http://localhost:9960" | ||
username = "testUser" | ||
ws_endpoint = "ws://localhost:9960/" | ||
wss_endpoint = "wss://localhost:9960/" | ||
http_endpoint = "http://localhost:9960" | ||
https_endpoint = "https://localhost:9960/" | ||
password = "testPassword" | ||
show_as_token_endpoint_url = false | ||
|
||
[apim.gateway.environment.properties] | ||
Organization = "TestWSO2" | ||
DisplayName = "Developer portal Test Environment" | ||
DevAccountName = "devPortTestEnv" | ||
|
||
#[apim.cache.gateway_token] | ||
#enable = true | ||
#expiry_time = "15m" | ||
|
||
#[apim.cache.resource] | ||
#enable = true | ||
|
||
#[apim.cache.km_token] | ||
#enable = false | ||
#expiry_time = "15m" | ||
|
||
#[apim.cache.recent_apis] | ||
#enable = false | ||
|
||
#[apim.cache.scopes] | ||
#enable = true | ||
|
||
#[apim.cache.publisher_roles] | ||
#enable = true | ||
|
||
#[apim.cache.jwt_claim] | ||
#enable = true | ||
#expiry_time = "15m" | ||
|
||
#[apim.cache.tags] | ||
#expiry_time = "2m" | ||
|
||
#[apim.analytics] | ||
#enable = false | ||
#store_api_url = "https://localhost:7444" | ||
#username = "$ref{super_admin.username}" | ||
#password = "$ref{super_admin.password}" | ||
#event_publisher_type = "default" | ||
#event_publisher_type = "custom" | ||
#event_publisher_impl = "org.wso2.carbon.apimgt.usage.publisher.APIMgtUsageDataBridgeDataPublisher" | ||
#publish_response_size = true | ||
|
||
#[[apim.analytics.url_group]] | ||
#analytics_url =["tcp://analytics1:7611","tcp://analytics2:7611"] | ||
#analytics_auth_url =["ssl://analytics1:7711","ssl://analytics2:7711"] | ||
#type = "loadbalance" | ||
|
||
#[[apim.analytics.url_group]] | ||
#analytics_url =["tcp://analytics1:7612","tcp://analytics2:7612"] | ||
#analytics_auth_url =["ssl://analytics1:7712","ssl://analytics2:7712"] | ||
#type = "failover" | ||
|
||
|
||
#[apim.key_manager] | ||
#service_url = "https://localhost:${mgt.transport.https.port}/services/" | ||
#username = "$ref{super_admin.username}" | ||
#password = "$ref{super_admin.password}" | ||
#pool.init_idle_capacity = 50 | ||
#pool.max_idle = 100 | ||
#key_validation_handler_type = "default" | ||
#key_validation_handler_type = "custom" | ||
#key_validation_handler_impl = "org.wso2.carbon.apimgt.keymgt.handlers.DefaultKeyValidationHandler" | ||
|
||
#[apim.jwt] | ||
#enable = true | ||
#encoding = "base64" # base64,base64url | ||
#generator_impl = "org.wso2.carbon.apimgt.keymgt.token.JWTGenerator" | ||
#claim_dialect = "http://wso2.org/claims" | ||
#header = "X-JWT-Assertion" | ||
#signing_algorithm = "SHA256withRSA" | ||
#enable_user_claims = true | ||
#claims_extractor_impl = "org.wso2.carbon.apimgt.impl.token.DefaultClaimsRetriever" | ||
|
||
#[apim.oauth_config] | ||
#enable_outbound_auth_header = false | ||
#auth_header = "Authorization" | ||
#revoke_endpoint = "https://localhost:${https.nio.port}/revoke" | ||
#enable_token_encryption = false | ||
#enable_token_hashing = false | ||
|
||
#[apim.devportal] | ||
#url = "https://localhost:${mgt.transport.https.port}/devportal" | ||
#enable_application_sharing = false | ||
#if application_sharing_type, application_sharing_impl both defined priority goes to application_sharing_impl | ||
#application_sharing_type = "default" #changed type, saml, default #todo: check the new config for rest api | ||
#application_sharing_impl = "org.wso2.carbon.apimgt.impl.SAMLGroupIDExtractorImpl" | ||
#display_multiple_versions = false | ||
#display_deprecated_apis = false | ||
#enable_comments = true | ||
#enable_ratings = true | ||
#enable_forum = true | ||
|
||
[apim.cors] | ||
allow_origins = "*" | ||
allow_methods = ["GET","PUT","POST","DELETE","PATCH","OPTIONS"] | ||
allow_headers = ["authorization","Access-Control-Allow-Origin","Content-Type","SOAPAction"] | ||
allow_credentials = false | ||
|
||
#[[apim.throttling.url_group]] | ||
#analytics_url = ["tcp://localhost:7611","tcp://localhost:7611"] | ||
#analytics_auth_url = ["ssl://localhost:7711","ssl://localhost:7711"] | ||
#type = "loadbalance" | ||
|
||
#[apim.throttling] | ||
#enable_data_publishing = true | ||
#enable_policy_deploy = true | ||
#enable_blacklist_condition = true | ||
|
||
#throttle_decision_endpoints = ["tcp://localhost:5672","tcp://localhost:5672"] | ||
# | ||
#enable_persistence = true | ||
|
||
#[apim.throttling.blacklist_condition] | ||
#start_delay = "5m" | ||
#period = "1h" | ||
|
||
#[apim.throttling.jms] | ||
#start_delay = "5m" | ||
|
||
#[apim.throttling.event_sync] | ||
#hostName = "0.0.0.0" | ||
#port = 11224 | ||
# | ||
#[apim.throttling.event_management] | ||
#hostName = "0.0.0.0" | ||
#port = 10005 | ||
|
||
#[[apim.throttling.url_group]] | ||
#traffic_manager_urls = ["tcp://localhost:9611","tcp://localhost:9611"] | ||
#traffic_manager_auth_urls = ["ssl://localhost:9711","ssl://localhost:9711"] | ||
#type = "loadbalance" | ||
# | ||
#[[apim.throttling.url_group]] | ||
#traffic_manager_urls = ["tcp://localhost:9611","tcp://localhost:9611"] | ||
#traffic_manager_auth_urls = ["ssl://localhost:9711","ssl://localhost:9711"] | ||
#type = "failover" | ||
|
||
#[apim.workflow] | ||
#enable = false | ||
#service_url = "https://localhost:9445/bpmn" | ||
#username = "$ref{super_admin.username}" | ||
#password = "$ref{super_admin.password}" | ||
#callback_endpoint = "https://localhost:${mgt.transport.https.port}/api/am/publisher/v0.16/workflows/update-workflow-status" | ||
#token_endpoint = "https://localhost:${https.nio.port}/token" | ||
#client_registration_endpoint = "https://localhost:${mgt.transport.https.port}/client-registration/v0.17/register" | ||
#client_registration_username = "$ref{super_admin.username}" | ||
#client_registration_password = "$ref{super_admin.password}" | ||
|
||
#data bridge config | ||
#[transport.receiver] | ||
#type = "binary" | ||
#worker_threads = 10 | ||
#session_timeout = "30m" | ||
#keystore.file_name = "$ref{keystore.tls.file_name}" | ||
#keystore.password = "$ref{keystore.tls.password}" | ||
#tcp_port = 9611 | ||
#ssl_port = 9711 | ||
#ssl_receiver_thread_pool_size = 100 | ||
#tcp_receiver_thread_pool_size = 100 | ||
#ssl_enabled_protocols = ["TLSv1","TLSv1.1","TLSv1.2"] | ||
#ciphers = ["SSL_RSA_WITH_RC4_128_MD5","SSL_RSA_WITH_RC4_128_SHA"] | ||
|
||
#[apim.notification] | ||
#from_address = "APIM.com" | ||
#username = "APIM" | ||
#password = "APIM+123" | ||
#hostname = "localhost" | ||
#port = 3025 | ||
#enable_start_tls = false | ||
#enable_authentication = true | ||
|
||
#[apim.token.revocation] | ||
#notifier_impl = "org.wso2.carbon.apimgt.keymgt.events.TokenRevocationNotifierImpl" | ||
#enable_realtime_notifier = true | ||
#realtime_notifier.ttl = 5000 | ||
#enable_persistent_notifier = true | ||
#persistent_notifier.hostname = "https://localhost:2379/v2/keys/jti/" | ||
#persistent_notifier.ttl = 5000 | ||
#persistent_notifier.username = "root" | ||
#persistent_notifier.password = "root" | ||
|
||
[[event_handler]] | ||
name="userPostSelfRegistration" | ||
subscriptions=["POST_ADD_USER"] | ||
|
||
[transport] | ||
passthru_https.listener.ssl_profile_interval = 6000 | ||
passthru_https.sender.ssl_profile.interval = 6000 | ||
|
||
[security_audit] | ||
api_token="b57973cf-b74c-4ade-921d-ece83251eceb" | ||
collection_id="f73b8171-4f71-499b-891a-d34aa71f2d45" | ||
base_url="https://localhost:9943/am-auditApi-sample/api/auditapi" | ||
global=true | ||
|
||
[apim.certificate_reloader] | ||
period = "1m" | ||
|
||
[database.local] | ||
url = "jdbc:h2:./repository/database/WSO2CARBON_DB;DB_CLOSE_ON_EXIT=FALSE" | ||
|
||
[[event_listener]] | ||
id = "token_revocation" | ||
type = "org.wso2.carbon.identity.core.handler.AbstractIdentityHandler" | ||
name = "org.wso2.is.notification.ApimOauthEventInterceptor" | ||
order = 1 | ||
[event_listener.properties] | ||
notification_endpoint = "https://localhost:${mgt.transport.https.port}/internal/data/v1/notify" | ||
username = "${admin.username}" | ||
password = "${admin.password}" | ||
'header.X-WSO2-KEY-MANAGER' = "default" | ||
|
||
[apim.sync_runtime_artifacts.gateway.skip_list] | ||
apis = ["admin--git2231head_v1.0.0.xml","admin--PizzaShackAPI_v1.0.0.xml","admin--ScriptMediatorAPI_v1.0.xml", | ||
"APIThrottleBackendAPI.xml","BackEndSecurity.xml","DigestAuth_API.xml","git2231.xml","HttpPATCHSupport_API.xml","JWKS-Backend.xml","JWTBackendAPI.xml","multiVSR_v1.0.0.xml","Response_API_1.xml","Response_API_2.xml","Response_Custom_API.xml","Response_Error_API.xml","Response_Loc_API.xml","SpecialCRN_v1.0.0.xml","status_code_204_API.xml","stockquote.xml","XML_API.xml","Version1.xml","Version2.xml","schemaValidationAPI.xml"] | ||
|
||
[apim.http_client] | ||
max_total= "200" | ||
default_max_per_route= "2" |
Oops, something went wrong.