From e2b99f3f5cbc5969ae96f07f57a0181003ea291f Mon Sep 17 00:00:00 2001 From: Thisara-Welmilla Date: Mon, 18 Sep 2023 12:02:01 +0530 Subject: [PATCH 01/16] Enable tenanted qualified urls configs --- .../src/repository/resources/conf/deployment.toml | 4 ++++ .../artifacts/IS/analytics/config/analytics_enabled.toml | 4 ++++ .../IS/analytics/config/identity_event_analytics_enabled.toml | 4 ++++ .../IS/application/mgt/role_validation_disabled.toml | 4 ++++ .../artifacts/IS/application/mgt/role_validation_enabled.toml | 4 ++++ .../test/resources/artifacts/IS/email/email_otp_config.toml | 4 ++++ .../artifacts/IS/identityMgt/case_insensitive_user_false.toml | 4 ++++ .../artifacts/IS/identityMgt/user_mgt_regex_changed.toml | 4 ++++ .../resources/artifacts/IS/identity_encryption_enabled.toml | 4 ++++ .../test/resources/artifacts/IS/identity_hash_enabled.toml | 4 ++++ .../test/resources/artifacts/IS/identity_new_resource.toml | 4 ++++ .../resources/artifacts/IS/oauth/add_scope_deployment.toml | 4 ++++ .../artifacts/IS/oauth/jwt-token-gen-enabled-identity.toml | 4 ++++ .../oauth/jwt_token_issuer_add_remaining_user_attribute.toml | 4 ++++ .../artifacts/IS/oauth/jwt_token_issuer_convert_to_oidc.toml | 4 ++++ .../artifacts/IS/oauth/jwt_token_issuer_enabled.toml | 4 ++++ .../resources/artifacts/IS/oauth/skip_consent_enabled.toml | 4 ++++ .../artifacts/IS/oauth/token_renewal_per_request_enabled.toml | 4 ++++ .../artifacts/IS/provisioning/db_separation_config.toml | 4 ++++ .../artifacts/IS/provisioning/default_configs_with_h2_db.toml | 4 ++++ .../IS/saml/application_authentication_changed_acs.toml | 4 ++++ .../IS/saml/saml-assertion-query-enabled-deployment.toml | 4 ++++ .../artifacts/IS/saml/saml-sso-for-admin-console.toml | 4 ++++ .../IS/saml/saml_ecp_consent_management_disabled.toml | 4 ++++ .../IS/scim/IDENTITY4776/catalina_server_config.toml | 4 ++++ .../resources/artifacts/IS/scim2/me_unsecured_identity.toml | 4 ++++ .../artifacts/IS/user/enable_email_username_deployment.toml | 4 ++++ .../artifacts/IS/user/enable_federated_association.toml | 4 ++++ .../artifacts/IS/userMgt/carbon15051/email_login_config.toml | 4 ++++ .../resources/artifacts/IS/userMgt/jdbc_user_mgt_config.toml | 4 ++++ .../resources/artifacts/IS/userMgt/ldap_user_mgt_config.toml | 4 ++++ .../artifacts/IS/userMgt/read_only_ldap_user_mgt_config.toml | 4 ++++ 32 files changed, 128 insertions(+) diff --git a/modules/distribution/src/repository/resources/conf/deployment.toml b/modules/distribution/src/repository/resources/conf/deployment.toml index 4d16278ad4f..d3e53d8db81 100644 --- a/modules/distribution/src/repository/resources/conf/deployment.toml +++ b/modules/distribution/src/repository/resources/conf/deployment.toml @@ -3,6 +3,10 @@ hostname = "localhost" node_ip = "127.0.0.1" base_path = "https://$ref{server.hostname}:${carbon.management.port}" +[tenant_context] +enable_tenant_qualified_urls = "true" +enable_tenanted_sessions = "true" + [super_admin] username = "admin" password = "admin" diff --git a/modules/integration/tests-integration/tests-backend/src/test/resources/artifacts/IS/analytics/config/analytics_enabled.toml b/modules/integration/tests-integration/tests-backend/src/test/resources/artifacts/IS/analytics/config/analytics_enabled.toml index f6b3ad134b5..bbeab44b1f3 100644 --- a/modules/integration/tests-integration/tests-backend/src/test/resources/artifacts/IS/analytics/config/analytics_enabled.toml +++ b/modules/integration/tests-integration/tests-backend/src/test/resources/artifacts/IS/analytics/config/analytics_enabled.toml @@ -3,6 +3,10 @@ hostname = "localhost" node_ip = "127.0.0.1" base_path = "https://$ref{server.hostname}:${carbon.management.port}" +[tenant_context] +enable_tenant_qualified_urls = "true" +enable_tenanted_sessions = "true" + [super_admin] username = "admin" password = "admin" diff --git a/modules/integration/tests-integration/tests-backend/src/test/resources/artifacts/IS/analytics/config/identity_event_analytics_enabled.toml b/modules/integration/tests-integration/tests-backend/src/test/resources/artifacts/IS/analytics/config/identity_event_analytics_enabled.toml index 013fdbda27c..e63705aabea 100644 --- a/modules/integration/tests-integration/tests-backend/src/test/resources/artifacts/IS/analytics/config/identity_event_analytics_enabled.toml +++ b/modules/integration/tests-integration/tests-backend/src/test/resources/artifacts/IS/analytics/config/identity_event_analytics_enabled.toml @@ -3,6 +3,10 @@ hostname = "localhost" node_ip = "127.0.0.1" base_path = "https://$ref{server.hostname}:${carbon.management.port}" +[tenant_context] +enable_tenant_qualified_urls = "true" +enable_tenanted_sessions = "true" + [super_admin] username = "admin" password = "admin" diff --git a/modules/integration/tests-integration/tests-backend/src/test/resources/artifacts/IS/application/mgt/role_validation_disabled.toml b/modules/integration/tests-integration/tests-backend/src/test/resources/artifacts/IS/application/mgt/role_validation_disabled.toml index 85ef7af3bc1..229c523d043 100644 --- a/modules/integration/tests-integration/tests-backend/src/test/resources/artifacts/IS/application/mgt/role_validation_disabled.toml +++ b/modules/integration/tests-integration/tests-backend/src/test/resources/artifacts/IS/application/mgt/role_validation_disabled.toml @@ -3,6 +3,10 @@ hostname = "localhost" node_ip = "127.0.0.1" base_path = "https://$ref{server.hostname}:${carbon.management.port}" +[tenant_context] +enable_tenant_qualified_urls = "true" +enable_tenanted_sessions = "true" + [super_admin] username = "admin" password = "admin" diff --git a/modules/integration/tests-integration/tests-backend/src/test/resources/artifacts/IS/application/mgt/role_validation_enabled.toml b/modules/integration/tests-integration/tests-backend/src/test/resources/artifacts/IS/application/mgt/role_validation_enabled.toml index 85b8bd3ef43..c8a598e7df3 100644 --- a/modules/integration/tests-integration/tests-backend/src/test/resources/artifacts/IS/application/mgt/role_validation_enabled.toml +++ b/modules/integration/tests-integration/tests-backend/src/test/resources/artifacts/IS/application/mgt/role_validation_enabled.toml @@ -3,6 +3,10 @@ hostname = "localhost" node_ip = "127.0.0.1" base_path = "https://$ref{server.hostname}:${carbon.management.port}" +[tenant_context] +enable_tenant_qualified_urls = "true" +enable_tenanted_sessions = "true" + [super_admin] username = "admin" password = "admin" diff --git a/modules/integration/tests-integration/tests-backend/src/test/resources/artifacts/IS/email/email_otp_config.toml b/modules/integration/tests-integration/tests-backend/src/test/resources/artifacts/IS/email/email_otp_config.toml index 77d325f5126..b7ed6b335c2 100644 --- a/modules/integration/tests-integration/tests-backend/src/test/resources/artifacts/IS/email/email_otp_config.toml +++ b/modules/integration/tests-integration/tests-backend/src/test/resources/artifacts/IS/email/email_otp_config.toml @@ -4,6 +4,10 @@ node_ip = "127.0.0.1" base_path = "https://$ref{server.hostname}:${carbon.management.port}" disable_addressing = true +[tenant_context] +enable_tenant_qualified_urls = "true" +enable_tenanted_sessions = "true" + [super_admin] username = "admin" password = "admin" diff --git a/modules/integration/tests-integration/tests-backend/src/test/resources/artifacts/IS/identityMgt/case_insensitive_user_false.toml b/modules/integration/tests-integration/tests-backend/src/test/resources/artifacts/IS/identityMgt/case_insensitive_user_false.toml index 95d6f563413..f072993a4fc 100644 --- a/modules/integration/tests-integration/tests-backend/src/test/resources/artifacts/IS/identityMgt/case_insensitive_user_false.toml +++ b/modules/integration/tests-integration/tests-backend/src/test/resources/artifacts/IS/identityMgt/case_insensitive_user_false.toml @@ -3,6 +3,10 @@ hostname = "localhost" node_ip = "127.0.0.1" base_path = "https://$ref{server.hostname}:${carbon.management.port}" +[tenant_context] +enable_tenant_qualified_urls = "true" +enable_tenanted_sessions = "true" + [super_admin] username = "admin" password = "admin" diff --git a/modules/integration/tests-integration/tests-backend/src/test/resources/artifacts/IS/identityMgt/user_mgt_regex_changed.toml b/modules/integration/tests-integration/tests-backend/src/test/resources/artifacts/IS/identityMgt/user_mgt_regex_changed.toml index 5e721775096..287618bae27 100644 --- a/modules/integration/tests-integration/tests-backend/src/test/resources/artifacts/IS/identityMgt/user_mgt_regex_changed.toml +++ b/modules/integration/tests-integration/tests-backend/src/test/resources/artifacts/IS/identityMgt/user_mgt_regex_changed.toml @@ -4,6 +4,10 @@ node_ip = "127.0.0.1" base_path = "https://$ref{server.hostname}:${carbon.management.port}" offset = "410" +[tenant_context] +enable_tenant_qualified_urls = "true" +enable_tenanted_sessions = "true" + [super_admin] username = "admin" password = "admin" diff --git a/modules/integration/tests-integration/tests-backend/src/test/resources/artifacts/IS/identity_encryption_enabled.toml b/modules/integration/tests-integration/tests-backend/src/test/resources/artifacts/IS/identity_encryption_enabled.toml index 5beb46bf566..0fa0fdb3e56 100644 --- a/modules/integration/tests-integration/tests-backend/src/test/resources/artifacts/IS/identity_encryption_enabled.toml +++ b/modules/integration/tests-integration/tests-backend/src/test/resources/artifacts/IS/identity_encryption_enabled.toml @@ -3,6 +3,10 @@ hostname = "localhost" node_ip = "127.0.0.1" base_path = "https://$ref{server.hostname}:${carbon.management.port}" +[tenant_context] +enable_tenant_qualified_urls = "true" +enable_tenanted_sessions = "true" + [super_admin] username = "admin" password = "admin" diff --git a/modules/integration/tests-integration/tests-backend/src/test/resources/artifacts/IS/identity_hash_enabled.toml b/modules/integration/tests-integration/tests-backend/src/test/resources/artifacts/IS/identity_hash_enabled.toml index 62f1a79b668..3b154788273 100644 --- a/modules/integration/tests-integration/tests-backend/src/test/resources/artifacts/IS/identity_hash_enabled.toml +++ b/modules/integration/tests-integration/tests-backend/src/test/resources/artifacts/IS/identity_hash_enabled.toml @@ -3,6 +3,10 @@ hostname = "localhost" node_ip = "127.0.0.1" base_path = "https://$ref{server.hostname}:${carbon.management.port}" +[tenant_context] +enable_tenant_qualified_urls = "true" +enable_tenanted_sessions = "true" + [super_admin] username = "admin" password = "admin" diff --git a/modules/integration/tests-integration/tests-backend/src/test/resources/artifacts/IS/identity_new_resource.toml b/modules/integration/tests-integration/tests-backend/src/test/resources/artifacts/IS/identity_new_resource.toml index 04d0aad2a75..b75b328d816 100644 --- a/modules/integration/tests-integration/tests-backend/src/test/resources/artifacts/IS/identity_new_resource.toml +++ b/modules/integration/tests-integration/tests-backend/src/test/resources/artifacts/IS/identity_new_resource.toml @@ -3,6 +3,10 @@ hostname = "localhost" node_ip = "127.0.0.1" base_path = "https://$ref{server.hostname}:${carbon.management.port}" +[tenant_context] +enable_tenant_qualified_urls = "true" +enable_tenanted_sessions = "true" + [super_admin] username = "admin" password = "admin" diff --git a/modules/integration/tests-integration/tests-backend/src/test/resources/artifacts/IS/oauth/add_scope_deployment.toml b/modules/integration/tests-integration/tests-backend/src/test/resources/artifacts/IS/oauth/add_scope_deployment.toml index a7a3c8337d0..63b9d786251 100644 --- a/modules/integration/tests-integration/tests-backend/src/test/resources/artifacts/IS/oauth/add_scope_deployment.toml +++ b/modules/integration/tests-integration/tests-backend/src/test/resources/artifacts/IS/oauth/add_scope_deployment.toml @@ -3,6 +3,10 @@ hostname = "localhost" node_ip = "127.0.0.1" base_path = "https://$ref{server.hostname}:${carbon.management.port}" +[tenant_context] +enable_tenant_qualified_urls = "true" +enable_tenanted_sessions = "true" + [super_admin] username = "admin" password = "admin" diff --git a/modules/integration/tests-integration/tests-backend/src/test/resources/artifacts/IS/oauth/jwt-token-gen-enabled-identity.toml b/modules/integration/tests-integration/tests-backend/src/test/resources/artifacts/IS/oauth/jwt-token-gen-enabled-identity.toml index 4e7a8eee2a0..a38cb137a6e 100644 --- a/modules/integration/tests-integration/tests-backend/src/test/resources/artifacts/IS/oauth/jwt-token-gen-enabled-identity.toml +++ b/modules/integration/tests-integration/tests-backend/src/test/resources/artifacts/IS/oauth/jwt-token-gen-enabled-identity.toml @@ -3,6 +3,10 @@ hostname = "localhost" node_ip = "127.0.0.1" base_path = "https://$ref{server.hostname}:${carbon.management.port}" +[tenant_context] +enable_tenant_qualified_urls = "true" +enable_tenanted_sessions = "true" + [super_admin] username = "admin" password = "admin" diff --git a/modules/integration/tests-integration/tests-backend/src/test/resources/artifacts/IS/oauth/jwt_token_issuer_add_remaining_user_attribute.toml b/modules/integration/tests-integration/tests-backend/src/test/resources/artifacts/IS/oauth/jwt_token_issuer_add_remaining_user_attribute.toml index cc92fc48874..69a84406b0f 100644 --- a/modules/integration/tests-integration/tests-backend/src/test/resources/artifacts/IS/oauth/jwt_token_issuer_add_remaining_user_attribute.toml +++ b/modules/integration/tests-integration/tests-backend/src/test/resources/artifacts/IS/oauth/jwt_token_issuer_add_remaining_user_attribute.toml @@ -3,6 +3,10 @@ hostname = "localhost" node_ip = "127.0.0.1" base_path = "https://$ref{server.hostname}:${carbon.management.port}" +[tenant_context] +enable_tenant_qualified_urls = "true" +enable_tenanted_sessions = "true" + [super_admin] username = "admin" password = "admin" diff --git a/modules/integration/tests-integration/tests-backend/src/test/resources/artifacts/IS/oauth/jwt_token_issuer_convert_to_oidc.toml b/modules/integration/tests-integration/tests-backend/src/test/resources/artifacts/IS/oauth/jwt_token_issuer_convert_to_oidc.toml index 4260c454dfb..a17f0a3b1e6 100644 --- a/modules/integration/tests-integration/tests-backend/src/test/resources/artifacts/IS/oauth/jwt_token_issuer_convert_to_oidc.toml +++ b/modules/integration/tests-integration/tests-backend/src/test/resources/artifacts/IS/oauth/jwt_token_issuer_convert_to_oidc.toml @@ -3,6 +3,10 @@ hostname = "localhost" node_ip = "127.0.0.1" base_path = "https://$ref{server.hostname}:${carbon.management.port}" +[tenant_context] +enable_tenant_qualified_urls = "true" +enable_tenanted_sessions = "true" + [super_admin] username = "admin" password = "admin" diff --git a/modules/integration/tests-integration/tests-backend/src/test/resources/artifacts/IS/oauth/jwt_token_issuer_enabled.toml b/modules/integration/tests-integration/tests-backend/src/test/resources/artifacts/IS/oauth/jwt_token_issuer_enabled.toml index 5e32413e0be..e63b264b2a6 100644 --- a/modules/integration/tests-integration/tests-backend/src/test/resources/artifacts/IS/oauth/jwt_token_issuer_enabled.toml +++ b/modules/integration/tests-integration/tests-backend/src/test/resources/artifacts/IS/oauth/jwt_token_issuer_enabled.toml @@ -3,6 +3,10 @@ hostname = "localhost" node_ip = "127.0.0.1" base_path = "https://$ref{server.hostname}:${carbon.management.port}" +[tenant_context] +enable_tenant_qualified_urls = "true" +enable_tenanted_sessions = "true" + [super_admin] username = "admin" password = "admin" diff --git a/modules/integration/tests-integration/tests-backend/src/test/resources/artifacts/IS/oauth/skip_consent_enabled.toml b/modules/integration/tests-integration/tests-backend/src/test/resources/artifacts/IS/oauth/skip_consent_enabled.toml index e289772eb65..39fc435417b 100644 --- a/modules/integration/tests-integration/tests-backend/src/test/resources/artifacts/IS/oauth/skip_consent_enabled.toml +++ b/modules/integration/tests-integration/tests-backend/src/test/resources/artifacts/IS/oauth/skip_consent_enabled.toml @@ -3,6 +3,10 @@ hostname = "localhost" node_ip = "127.0.0.1" base_path = "https://$ref{server.hostname}:${carbon.management.port}" +[tenant_context] +enable_tenant_qualified_urls = "true" +enable_tenanted_sessions = "true" + [super_admin] username = "admin" password = "admin" diff --git a/modules/integration/tests-integration/tests-backend/src/test/resources/artifacts/IS/oauth/token_renewal_per_request_enabled.toml b/modules/integration/tests-integration/tests-backend/src/test/resources/artifacts/IS/oauth/token_renewal_per_request_enabled.toml index 45d89179c3e..8423ab01ff5 100644 --- a/modules/integration/tests-integration/tests-backend/src/test/resources/artifacts/IS/oauth/token_renewal_per_request_enabled.toml +++ b/modules/integration/tests-integration/tests-backend/src/test/resources/artifacts/IS/oauth/token_renewal_per_request_enabled.toml @@ -3,6 +3,10 @@ hostname = "localhost" node_ip = "127.0.0.1" base_path = "https://$ref{server.hostname}:${carbon.management.port}" +[tenant_context] +enable_tenant_qualified_urls = "true" +enable_tenanted_sessions = "true" + [super_admin] username = "admin" password = "admin" diff --git a/modules/integration/tests-integration/tests-backend/src/test/resources/artifacts/IS/provisioning/db_separation_config.toml b/modules/integration/tests-integration/tests-backend/src/test/resources/artifacts/IS/provisioning/db_separation_config.toml index 282f9b60f22..1be46f257af 100644 --- a/modules/integration/tests-integration/tests-backend/src/test/resources/artifacts/IS/provisioning/db_separation_config.toml +++ b/modules/integration/tests-integration/tests-backend/src/test/resources/artifacts/IS/provisioning/db_separation_config.toml @@ -3,6 +3,10 @@ hostname = "localhost" node_ip = "127.0.0.1" base_path = "https://$ref{server.hostname}:${carbon.management.port}" +[tenant_context] +enable_tenant_qualified_urls = "true" +enable_tenanted_sessions = "true" + [super_admin] username = "admin" password = "admin" diff --git a/modules/integration/tests-integration/tests-backend/src/test/resources/artifacts/IS/provisioning/default_configs_with_h2_db.toml b/modules/integration/tests-integration/tests-backend/src/test/resources/artifacts/IS/provisioning/default_configs_with_h2_db.toml index 8f1c1394259..fe03bf051b4 100644 --- a/modules/integration/tests-integration/tests-backend/src/test/resources/artifacts/IS/provisioning/default_configs_with_h2_db.toml +++ b/modules/integration/tests-integration/tests-backend/src/test/resources/artifacts/IS/provisioning/default_configs_with_h2_db.toml @@ -3,6 +3,10 @@ hostname = "localhost" node_ip = "127.0.0.1" base_path = "https://$ref{server.hostname}:${carbon.management.port}" +[tenant_context] +enable_tenant_qualified_urls = "true" +enable_tenanted_sessions = "true" + [super_admin] username = "admin" password = "admin" diff --git a/modules/integration/tests-integration/tests-backend/src/test/resources/artifacts/IS/saml/application_authentication_changed_acs.toml b/modules/integration/tests-integration/tests-backend/src/test/resources/artifacts/IS/saml/application_authentication_changed_acs.toml index ab7cf7b682f..77a10b0bf70 100644 --- a/modules/integration/tests-integration/tests-backend/src/test/resources/artifacts/IS/saml/application_authentication_changed_acs.toml +++ b/modules/integration/tests-integration/tests-backend/src/test/resources/artifacts/IS/saml/application_authentication_changed_acs.toml @@ -3,6 +3,10 @@ hostname = "localhost" node_ip = "127.0.0.1" base_path = "https://$ref{server.hostname}:${carbon.management.port}" +[tenant_context] +enable_tenant_qualified_urls = "true" +enable_tenanted_sessions = "true" + [super_admin] username = "admin" password = "admin" diff --git a/modules/integration/tests-integration/tests-backend/src/test/resources/artifacts/IS/saml/saml-assertion-query-enabled-deployment.toml b/modules/integration/tests-integration/tests-backend/src/test/resources/artifacts/IS/saml/saml-assertion-query-enabled-deployment.toml index 0aea90dcc5e..ad060afd047 100644 --- a/modules/integration/tests-integration/tests-backend/src/test/resources/artifacts/IS/saml/saml-assertion-query-enabled-deployment.toml +++ b/modules/integration/tests-integration/tests-backend/src/test/resources/artifacts/IS/saml/saml-assertion-query-enabled-deployment.toml @@ -3,6 +3,10 @@ hostname = "localhost" node_ip = "127.0.0.1" base_path = "https://$ref{server.hostname}:${carbon.management.port}" +[tenant_context] +enable_tenant_qualified_urls = "true" +enable_tenanted_sessions = "true" + [super_admin] username = "admin" password = "admin" diff --git a/modules/integration/tests-integration/tests-backend/src/test/resources/artifacts/IS/saml/saml-sso-for-admin-console.toml b/modules/integration/tests-integration/tests-backend/src/test/resources/artifacts/IS/saml/saml-sso-for-admin-console.toml index 14faad863d3..f053d6bff62 100644 --- a/modules/integration/tests-integration/tests-backend/src/test/resources/artifacts/IS/saml/saml-sso-for-admin-console.toml +++ b/modules/integration/tests-integration/tests-backend/src/test/resources/artifacts/IS/saml/saml-sso-for-admin-console.toml @@ -3,6 +3,10 @@ hostname = "localhost" node_ip = "127.0.0.1" base_path = "https://$ref{server.hostname}:${carbon.management.port}" +[tenant_context] +enable_tenant_qualified_urls = "true" +enable_tenanted_sessions = "true" + [super_admin] username = "admin" password = "admin" diff --git a/modules/integration/tests-integration/tests-backend/src/test/resources/artifacts/IS/saml/saml_ecp_consent_management_disabled.toml b/modules/integration/tests-integration/tests-backend/src/test/resources/artifacts/IS/saml/saml_ecp_consent_management_disabled.toml index 845fd25aa80..8fa2357f1fe 100644 --- a/modules/integration/tests-integration/tests-backend/src/test/resources/artifacts/IS/saml/saml_ecp_consent_management_disabled.toml +++ b/modules/integration/tests-integration/tests-backend/src/test/resources/artifacts/IS/saml/saml_ecp_consent_management_disabled.toml @@ -3,6 +3,10 @@ hostname = "localhost" node_ip = "127.0.0.1" base_path = "https://$ref{server.hostname}:${carbon.management.port}" +[tenant_context] +enable_tenant_qualified_urls = "true" +enable_tenanted_sessions = "true" + [super_admin] username = "admin" password = "admin" diff --git a/modules/integration/tests-integration/tests-backend/src/test/resources/artifacts/IS/scim/IDENTITY4776/catalina_server_config.toml b/modules/integration/tests-integration/tests-backend/src/test/resources/artifacts/IS/scim/IDENTITY4776/catalina_server_config.toml index 1bdebb7f357..a2776654e8a 100644 --- a/modules/integration/tests-integration/tests-backend/src/test/resources/artifacts/IS/scim/IDENTITY4776/catalina_server_config.toml +++ b/modules/integration/tests-integration/tests-backend/src/test/resources/artifacts/IS/scim/IDENTITY4776/catalina_server_config.toml @@ -3,6 +3,10 @@ hostname = "localhost" node_ip = "127.0.0.1" base_path = "https://$ref{server.hostname}:${carbon.management.port}" +[tenant_context] +enable_tenant_qualified_urls = "true" +enable_tenanted_sessions = "true" + [super_admin] username = "admin" password = "admin" diff --git a/modules/integration/tests-integration/tests-backend/src/test/resources/artifacts/IS/scim2/me_unsecured_identity.toml b/modules/integration/tests-integration/tests-backend/src/test/resources/artifacts/IS/scim2/me_unsecured_identity.toml index 7a33ab8fa53..a9b79315063 100644 --- a/modules/integration/tests-integration/tests-backend/src/test/resources/artifacts/IS/scim2/me_unsecured_identity.toml +++ b/modules/integration/tests-integration/tests-backend/src/test/resources/artifacts/IS/scim2/me_unsecured_identity.toml @@ -3,6 +3,10 @@ hostname = "localhost" node_ip = "127.0.0.1" base_path = "https://$ref{server.hostname}:${carbon.management.port}" +[tenant_context] +enable_tenant_qualified_urls = "true" +enable_tenanted_sessions = "true" + [super_admin] username = "admin" password = "admin" diff --git a/modules/integration/tests-integration/tests-backend/src/test/resources/artifacts/IS/user/enable_email_username_deployment.toml b/modules/integration/tests-integration/tests-backend/src/test/resources/artifacts/IS/user/enable_email_username_deployment.toml index 001f3b1e880..97be4fe10bd 100644 --- a/modules/integration/tests-integration/tests-backend/src/test/resources/artifacts/IS/user/enable_email_username_deployment.toml +++ b/modules/integration/tests-integration/tests-backend/src/test/resources/artifacts/IS/user/enable_email_username_deployment.toml @@ -3,6 +3,10 @@ hostname = "localhost" node_ip = "127.0.0.1" base_path = "https://$ref{server.hostname}:${carbon.management.port}" +[tenant_context] +enable_tenant_qualified_urls = "true" +enable_tenanted_sessions = "true" + [super_admin] username = "admin" password = "admin" diff --git a/modules/integration/tests-integration/tests-backend/src/test/resources/artifacts/IS/user/enable_federated_association.toml b/modules/integration/tests-integration/tests-backend/src/test/resources/artifacts/IS/user/enable_federated_association.toml index e4fd0c3a499..394763abc18 100644 --- a/modules/integration/tests-integration/tests-backend/src/test/resources/artifacts/IS/user/enable_federated_association.toml +++ b/modules/integration/tests-integration/tests-backend/src/test/resources/artifacts/IS/user/enable_federated_association.toml @@ -3,6 +3,10 @@ hostname = "localhost" node_ip = "127.0.0.1" base_path = "https://$ref{server.hostname}:${carbon.management.port}" +[tenant_context] +enable_tenant_qualified_urls = "true" +enable_tenanted_sessions = "true" + [super_admin] username = "admin" password = "admin" diff --git a/modules/integration/tests-integration/tests-backend/src/test/resources/artifacts/IS/userMgt/carbon15051/email_login_config.toml b/modules/integration/tests-integration/tests-backend/src/test/resources/artifacts/IS/userMgt/carbon15051/email_login_config.toml index f695d98af85..508ee29c739 100644 --- a/modules/integration/tests-integration/tests-backend/src/test/resources/artifacts/IS/userMgt/carbon15051/email_login_config.toml +++ b/modules/integration/tests-integration/tests-backend/src/test/resources/artifacts/IS/userMgt/carbon15051/email_login_config.toml @@ -3,6 +3,10 @@ hostname = "localhost" node_ip = "127.0.0.1" base_path = "https://$ref{server.hostname}:${carbon.management.port}" +[tenant_context] +enable_tenant_qualified_urls = "true" +enable_tenanted_sessions = "true" + [super_admin] username = "admin" password = "admin" diff --git a/modules/integration/tests-integration/tests-backend/src/test/resources/artifacts/IS/userMgt/jdbc_user_mgt_config.toml b/modules/integration/tests-integration/tests-backend/src/test/resources/artifacts/IS/userMgt/jdbc_user_mgt_config.toml index b4c36cde0d8..94876121388 100644 --- a/modules/integration/tests-integration/tests-backend/src/test/resources/artifacts/IS/userMgt/jdbc_user_mgt_config.toml +++ b/modules/integration/tests-integration/tests-backend/src/test/resources/artifacts/IS/userMgt/jdbc_user_mgt_config.toml @@ -3,6 +3,10 @@ hostname = "localhost" node_ip = "127.0.0.1" base_path = "https://$ref{server.hostname}:${carbon.management.port}" +[tenant_context] +enable_tenant_qualified_urls = "true" +enable_tenanted_sessions = "true" + [super_admin] username = "admin" password = "admin" diff --git a/modules/integration/tests-integration/tests-backend/src/test/resources/artifacts/IS/userMgt/ldap_user_mgt_config.toml b/modules/integration/tests-integration/tests-backend/src/test/resources/artifacts/IS/userMgt/ldap_user_mgt_config.toml index 67c09884b6e..0b704f610d7 100644 --- a/modules/integration/tests-integration/tests-backend/src/test/resources/artifacts/IS/userMgt/ldap_user_mgt_config.toml +++ b/modules/integration/tests-integration/tests-backend/src/test/resources/artifacts/IS/userMgt/ldap_user_mgt_config.toml @@ -3,6 +3,10 @@ hostname = "localhost" node_ip = "127.0.0.1" base_path = "https://$ref{server.hostname}:${carbon.management.port}" +[tenant_context] +enable_tenant_qualified_urls = "true" +enable_tenanted_sessions = "true" + [super_admin] username = "admin" password = "admin" diff --git a/modules/integration/tests-integration/tests-backend/src/test/resources/artifacts/IS/userMgt/read_only_ldap_user_mgt_config.toml b/modules/integration/tests-integration/tests-backend/src/test/resources/artifacts/IS/userMgt/read_only_ldap_user_mgt_config.toml index 961caacb042..d2fb5ef50bd 100644 --- a/modules/integration/tests-integration/tests-backend/src/test/resources/artifacts/IS/userMgt/read_only_ldap_user_mgt_config.toml +++ b/modules/integration/tests-integration/tests-backend/src/test/resources/artifacts/IS/userMgt/read_only_ldap_user_mgt_config.toml @@ -3,6 +3,10 @@ hostname = "localhost" node_ip = "127.0.0.1" base_path = "https://$ref{server.hostname}:${carbon.management.port}" +[tenant_context] +enable_tenant_qualified_urls = "true" +enable_tenanted_sessions = "true" + [super_admin] username = "admin" password = "admin" From c9023f01d12bbb645461b924db091b17536f89b8 Mon Sep 17 00:00:00 2001 From: Thisara-Welmilla Date: Mon, 18 Sep 2023 12:42:48 +0530 Subject: [PATCH 02/16] Add common methods to get tenant qualified URLs. --- .../common/utils/ISIntegrationTest.java | 63 ++++++++++++++++++- 1 file changed, 62 insertions(+), 1 deletion(-) diff --git a/modules/integration/tests-common/integration-test-utils/src/main/java/org/wso2/identity/integration/common/utils/ISIntegrationTest.java b/modules/integration/tests-common/integration-test-utils/src/main/java/org/wso2/identity/integration/common/utils/ISIntegrationTest.java index 95a3cf7c940..f1471f3ada4 100644 --- a/modules/integration/tests-common/integration-test-utils/src/main/java/org/wso2/identity/integration/common/utils/ISIntegrationTest.java +++ b/modules/integration/tests-common/integration-test-utils/src/main/java/org/wso2/identity/integration/common/utils/ISIntegrationTest.java @@ -20,16 +20,18 @@ import org.apache.commons.logging.Log; import org.apache.commons.logging.LogFactory; +import org.wso2.carbon.automation.engine.configurations.UrlGenerationUtil; import org.wso2.carbon.automation.engine.context.AutomationContext; import org.wso2.carbon.automation.engine.context.TestUserMode; import org.wso2.carbon.automation.engine.context.beans.ContextUrls; +import org.wso2.carbon.automation.engine.context.beans.Instance; import org.wso2.carbon.automation.engine.context.beans.Tenant; import org.wso2.carbon.automation.engine.context.beans.User; import org.wso2.carbon.automation.engine.frameworkutils.FrameworkPathUtil; import org.wso2.carbon.automation.test.utils.common.TestConfigurationProvider; import org.wso2.carbon.integration.common.admin.client.AuthenticatorClient; import org.wso2.carbon.integration.common.utils.LoginLogoutClient; -import org.wso2.carbon.utils.CarbonUtils; +import org.wso2.carbon.utils.multitenancy.MultitenantConstants; import javax.xml.xpath.XPathExpressionException; import java.io.File; @@ -37,6 +39,9 @@ public class ISIntegrationTest { public static final String URL_SEPARATOR = "/"; + public static final String TENANTED_URL_PATH_SPECIFIER = "/t/"; + private static final String PRODUCT_GROUP_PORT_HTTPS = "https"; + protected Log log = LogFactory.getLog(getClass()); protected AutomationContext isServer; protected String backendURL; @@ -143,6 +148,62 @@ public void setSystemproperties() { System.setProperty("javax.net.ssl.trustStoreType", "JKS"); } + + /** + * Get the qualified endpoint URL with the hostname for the given tenant. + * + * @param endpointURL The endpoint URL with the hostname. + * @param tenantDomain Tenanted domain. + * @return Tenant qualified URL. + */ + public String getTenantQualifiedURL(String endpointURL, String tenantDomain) { + + try { + if(!tenantDomain.equalsIgnoreCase(MultitenantConstants.SUPER_TENANT_DOMAIN_NAME)) { + String baseURL = getBaseURL(); + endpointURL = endpointURL.replace(baseURL, baseURL + TENANTED_URL_PATH_SPECIFIER + tenantDomain); + } + return endpointURL; + } catch (XPathExpressionException e) { + throw new RuntimeException(e); + } + } + + /** + * Get the qualified endpoint URL without the hostname for the given tenant. + * + * @param endpointURLWithHostname The endpoint URL without the hostname. + * @param tenantDomain Tenanted domain. + * @return Tenant qualified URL without hostname. + */ + public String getTenantQualifiedURLWithoutHostName(String endpointURLWithHostname, String tenantDomain) { + + if(!tenantDomain.equalsIgnoreCase(MultitenantConstants.SUPER_TENANT_DOMAIN_NAME)) { + endpointURLWithHostname = TENANTED_URL_PATH_SPECIFIER + tenantDomain + endpointURLWithHostname; + } + return endpointURLWithHostname; + } + + /** + * Get the based URL eg: https://localhost:9443. + * + * @return The base URL. + */ + private String getBaseURL() throws XPathExpressionException { + + String baseURL; + Instance instance = isServer.getInstance(); + String httpsPort = isServer.getInstance().getPorts().get(PRODUCT_GROUP_PORT_HTTPS); + String hostName = UrlGenerationUtil.getWorkerHost(instance); + + if(httpsPort != null) { + baseURL = PRODUCT_GROUP_PORT_HTTPS + "://" + hostName + ":" + httpsPort; + } else { + baseURL = PRODUCT_GROUP_PORT_HTTPS + "://" + hostName; + } + return baseURL; + } + // protected void addJDBCUserStore(String dbURI, String driverName, String userName, String password, // boolean disabled, String description, String domainName) throws Exception { // UserStoreConfigAdminServiceClient userStoreConfigurationClient = From fb8c8d4154bb869eb070374dde7ee5a4f1065ea0 Mon Sep 17 00:00:00 2001 From: Thisara-Welmilla Date: Thu, 21 Sep 2023 15:02:11 +0530 Subject: [PATCH 03/16] Add common methods to get tenant qualified URLs. --- .../common/utils/ISIntegrationTest.java | 16 ++++++++-------- 1 file changed, 8 insertions(+), 8 deletions(-) diff --git a/modules/integration/tests-common/integration-test-utils/src/main/java/org/wso2/identity/integration/common/utils/ISIntegrationTest.java b/modules/integration/tests-common/integration-test-utils/src/main/java/org/wso2/identity/integration/common/utils/ISIntegrationTest.java index f1471f3ada4..02ca8a12146 100644 --- a/modules/integration/tests-common/integration-test-utils/src/main/java/org/wso2/identity/integration/common/utils/ISIntegrationTest.java +++ b/modules/integration/tests-common/integration-test-utils/src/main/java/org/wso2/identity/integration/common/utils/ISIntegrationTest.java @@ -159,9 +159,12 @@ public void setSystemproperties() { public String getTenantQualifiedURL(String endpointURL, String tenantDomain) { try { - if(!tenantDomain.equalsIgnoreCase(MultitenantConstants.SUPER_TENANT_DOMAIN_NAME)) { + if(!tenantDomain.isBlank() && !tenantDomain.equalsIgnoreCase( + MultitenantConstants.SUPER_TENANT_DOMAIN_NAME)) { + String baseURL = getBaseURL(); - endpointURL = endpointURL.replace(baseURL, baseURL + TENANTED_URL_PATH_SPECIFIER + tenantDomain); + endpointURL = endpointURL.replace(baseURL, + baseURL + TENANTED_URL_PATH_SPECIFIER + tenantDomain); } return endpointURL; } catch (XPathExpressionException e) { @@ -178,7 +181,7 @@ public String getTenantQualifiedURL(String endpointURL, String tenantDomain) { */ public String getTenantQualifiedURLWithoutHostName(String endpointURLWithHostname, String tenantDomain) { - if(!tenantDomain.equalsIgnoreCase(MultitenantConstants.SUPER_TENANT_DOMAIN_NAME)) { + if(!tenantDomain.isBlank() && !tenantDomain.equalsIgnoreCase(MultitenantConstants.SUPER_TENANT_DOMAIN_NAME)) { endpointURLWithHostname = TENANTED_URL_PATH_SPECIFIER + tenantDomain + endpointURLWithHostname; } return endpointURLWithHostname; @@ -191,17 +194,14 @@ public String getTenantQualifiedURLWithoutHostName(String endpointURLWithHostnam */ private String getBaseURL() throws XPathExpressionException { - String baseURL; Instance instance = isServer.getInstance(); String httpsPort = isServer.getInstance().getPorts().get(PRODUCT_GROUP_PORT_HTTPS); String hostName = UrlGenerationUtil.getWorkerHost(instance); if(httpsPort != null) { - baseURL = PRODUCT_GROUP_PORT_HTTPS + "://" + hostName + ":" + httpsPort; - } else { - baseURL = PRODUCT_GROUP_PORT_HTTPS + "://" + hostName; + return PRODUCT_GROUP_PORT_HTTPS + "://" + hostName + ":" + httpsPort; } - return baseURL; + return PRODUCT_GROUP_PORT_HTTPS + "://" + hostName; } // protected void addJDBCUserStore(String dbURI, String driverName, String userName, String password, From b74c521b02f93d46adafd6aaca507c5f04b0d553 Mon Sep 17 00:00:00 2001 From: Thisara-Welmilla Date: Thu, 21 Sep 2023 15:25:35 +0530 Subject: [PATCH 04/16] Modify git action scripts. --- .github/scripts/pr-builder.sh | 3 ++- .github/workflows/pr-builder-test-JDK11.yml | 2 +- 2 files changed, 3 insertions(+), 2 deletions(-) diff --git a/.github/scripts/pr-builder.sh b/.github/scripts/pr-builder.sh index 4b74570a7c6..c92f9a491d8 100644 --- a/.github/scripts/pr-builder.sh +++ b/.github/scripts/pr-builder.sh @@ -28,7 +28,8 @@ echo "==========================================================" echo "Cloning product-is" echo "==========================================================" -git clone https://github.com/wso2/product-is +# git clone https://github.com/wso2/product-is +git clone -b enable-tenant-qualified-urls --single-branch https://github.com/wso2/product-is if [ "$REPO" = "product-is" ]; then diff --git a/.github/workflows/pr-builder-test-JDK11.yml b/.github/workflows/pr-builder-test-JDK11.yml index 4e7aa32a2c0..8cf752525a6 100644 --- a/.github/workflows/pr-builder-test-JDK11.yml +++ b/.github/workflows/pr-builder-test-JDK11.yml @@ -75,7 +75,7 @@ jobs: JAVA_8_HOME: ${{env.J8HOME}} JAVA_11_HOME: ${{env.J11HOME}} run: | - wget https://raw.githubusercontent.com/wso2/product-is/master/.github/scripts/pr-builder.sh + wget https://raw.githubusercontent.com/wso2/product-is/enable-tenant-qualified-urls/.github/scripts/pr-builder.sh bash pr-builder.sh - name: Archive PR diff file if: always() From 726bc6fd287bf1b383dd9a12517c104383bdcfdd Mon Sep 17 00:00:00 2001 From: Thisara-Welmilla Date: Mon, 25 Sep 2023 14:06:59 +0530 Subject: [PATCH 05/16] Modify to tenant qualified urls. --- .../test/CrossProtocolLogoutTestCase.java | 1 - .../integration/test/EmailOTPTestCase.java | 4 +--- .../AbstractAnalyticsLoginTestCase.java | 6 +----- .../test/consent/SelfSignUpConsentTest.java | 4 +--- .../test/idp/mgt/ResidentIDPConfigsTestCase.java | 6 +++--- .../OAuth2ServiceSAML2BearerGrantTestCase.java | 2 -- .../test/oidc/OIDCFederatedIdpInitLogoutTest.java | 5 +---- ...ChallengeQuestionPostAuthnHandlerTestCase.java | 6 +----- .../test/saml/AbstractSAMLSSOTestCase.java | 6 +----- .../test/saml/RegistryMountTestCase.java | 4 +--- .../test/saml/SAMLErrorResponseTestCase.java | 4 +--- .../test/saml/SAMLIdPInitiatedSSOTestCase.java | 2 +- ...AMLLocalAndOutboundAuthenticatorsTestCase.java | 5 ++--- .../test/saml/SAMLMetadataTestCase.java | 2 +- .../integration/test/saml/SAMLSSOTestCase.java | 4 ++-- .../integration/test/sts/TestPassiveSTS.java | 15 +-------------- .../identity/integration/test/util/Utils.java | 5 +---- .../email/template/EmailTemplateChangeUITest.java | 2 +- 18 files changed, 20 insertions(+), 63 deletions(-) diff --git a/modules/integration/tests-integration/tests-backend/src/test/java/org/wso2/identity/integration/test/CrossProtocolLogoutTestCase.java b/modules/integration/tests-integration/tests-backend/src/test/java/org/wso2/identity/integration/test/CrossProtocolLogoutTestCase.java index 376a7653458..637a7cce2cc 100644 --- a/modules/integration/tests-integration/tests-backend/src/test/java/org/wso2/identity/integration/test/CrossProtocolLogoutTestCase.java +++ b/modules/integration/tests-integration/tests-backend/src/test/java/org/wso2/identity/integration/test/CrossProtocolLogoutTestCase.java @@ -421,7 +421,6 @@ private HttpResponse sendSAMLMessage(String url, String samlMsgKey, String samlM HttpPost post = new HttpPost(url); post.setHeader(USER_AGENT, OAuth2Constant.USER_AGENT); urlParameters.add(new BasicNameValuePair(samlMsgKey, samlMsgValue)); - urlParameters.add(new BasicNameValuePair("tenantDomain", "carbon.super")); post.setEntity(new UrlEncodedFormEntity(urlParameters)); return client.execute(post); } diff --git a/modules/integration/tests-integration/tests-backend/src/test/java/org/wso2/identity/integration/test/EmailOTPTestCase.java b/modules/integration/tests-integration/tests-backend/src/test/java/org/wso2/identity/integration/test/EmailOTPTestCase.java index ac8ef0d0699..57b771dbbf9 100644 --- a/modules/integration/tests-integration/tests-backend/src/test/java/org/wso2/identity/integration/test/EmailOTPTestCase.java +++ b/modules/integration/tests-integration/tests-backend/src/test/java/org/wso2/identity/integration/test/EmailOTPTestCase.java @@ -106,7 +106,6 @@ public class EmailOTPTestCase extends ISIntegrationTest { CommonConstants.IS_DEFAULT_HTTPS_PORT + "/authenticationendpoint/email_otp.do"; private static final String USER_AGENT = "Apache-HttpClient/4.2.5 (java 1.5)"; private static final String profileName = "default"; - private static final String TENANT_DOMAIN_PARAM = "tenantDomain"; private Lookup cookieSpecRegistry; private RequestConfig requestConfig; @@ -225,10 +224,9 @@ private void deleteUser() { private HttpResponse sendSAMLMessage(String url, String samlMsgValue) throws IOException { List urlParameters = new ArrayList<>(); - HttpPost post = new HttpPost(url); + HttpPost post = new HttpPost(getTenantQualifiedURL(url, tenantInfo.getDomain())); post.setHeader("User-Agent", USER_AGENT); urlParameters.add(new BasicNameValuePair(CommonConstants.SAML_REQUEST_PARAM, samlMsgValue)); - urlParameters.add(new BasicNameValuePair(TENANT_DOMAIN_PARAM, config.getTenantDomain())); post.setEntity(new UrlEncodedFormEntity(urlParameters)); return httpClient.execute(post); } diff --git a/modules/integration/tests-integration/tests-backend/src/test/java/org/wso2/identity/integration/test/analytics/authentication/AbstractAnalyticsLoginTestCase.java b/modules/integration/tests-integration/tests-backend/src/test/java/org/wso2/identity/integration/test/analytics/authentication/AbstractAnalyticsLoginTestCase.java index 24fa24d71e4..cf3c4c2498b 100644 --- a/modules/integration/tests-integration/tests-backend/src/test/java/org/wso2/identity/integration/test/analytics/authentication/AbstractAnalyticsLoginTestCase.java +++ b/modules/integration/tests-integration/tests-backend/src/test/java/org/wso2/identity/integration/test/analytics/authentication/AbstractAnalyticsLoginTestCase.java @@ -63,7 +63,6 @@ public abstract class AbstractAnalyticsLoginTestCase extends ISIntegrationTest { private static final String INBOUND_AUTH_TYPE = "samlsso"; private static final String ATTRIBUTE_CS_INDEX_VALUE = "1239245949"; private static final String ATTRIBUTE_CS_INDEX_NAME = "attrConsumServiceIndex"; - private static final String TENANT_DOMAIN_PARAM = "tenantDomain"; private static final String SAML_SSO_URL = "https://localhost:9853/samlsso"; private static final String ACS_URL = "http://localhost:8490/%s/home.jsp"; @@ -390,12 +389,9 @@ private HttpResponse sendSAMLMessage(String url, String samlMsgKey, String samlM HttpClient httpClient = sharedHttpClient; List urlParameters = new ArrayList(); - HttpPost post = new HttpPost(url); + HttpPost post = new HttpPost(getTenantQualifiedURL(url, tenantInfo.getDomain())); post.setHeader("User-Agent", USER_AGENT); urlParameters.add(new BasicNameValuePair(samlMsgKey, samlMsgValue)); - if (config.getUserMode() == TestUserMode.TENANT_ADMIN || config.getUserMode() == TestUserMode.TENANT_USER) { - urlParameters.add(new BasicNameValuePair(TENANT_DOMAIN_PARAM, config.getUser().getTenantDomain())); - } post.setEntity(new UrlEncodedFormEntity(urlParameters)); return httpClient.execute(post); } diff --git a/modules/integration/tests-integration/tests-backend/src/test/java/org/wso2/identity/integration/test/consent/SelfSignUpConsentTest.java b/modules/integration/tests-integration/tests-backend/src/test/java/org/wso2/identity/integration/test/consent/SelfSignUpConsentTest.java index 228d2ecb60e..5fab1055a4b 100644 --- a/modules/integration/tests-integration/tests-backend/src/test/java/org/wso2/identity/integration/test/consent/SelfSignUpConsentTest.java +++ b/modules/integration/tests-integration/tests-backend/src/test/java/org/wso2/identity/integration/test/consent/SelfSignUpConsentTest.java @@ -69,7 +69,6 @@ public class SelfSignUpConsentTest extends ISIntegrationTest { private static final String COUNTRY_WSO2_CLAIM = "http://wso2.org/claims/country"; private static final String CALLBACK_QUERY_PARAM = "callback"; private static final String USERNAME_QUERY_PARAM = "username"; - private static final String TENANT_DOMAIN_QUERY_PARAM = "tenantDomain"; private static final String ADMIN = "admin"; private static final String EBONY = "ebony"; private static final String PASSWORD = "UsEr@123"; @@ -296,8 +295,7 @@ private String doCallSignUpDo(String username) throws IOException { username = MultitenantUtils.getTenantAwareUsername(username); } String selfRegisterEndpoint = - signupDoEndpoint + "?" + USERNAME_QUERY_PARAM + "=" + username + "&" + TENANT_DOMAIN_QUERY_PARAM + "=" - + tenantDomain; + signupDoEndpoint + "?" + USERNAME_QUERY_PARAM + "=" + username; HttpResponse httpResponse = sendGetRequest(client, selfRegisterEndpoint); return DataExtractUtil.getContentData(httpResponse); } diff --git a/modules/integration/tests-integration/tests-backend/src/test/java/org/wso2/identity/integration/test/idp/mgt/ResidentIDPConfigsTestCase.java b/modules/integration/tests-integration/tests-backend/src/test/java/org/wso2/identity/integration/test/idp/mgt/ResidentIDPConfigsTestCase.java index e637f6b5111..33ed117f772 100644 --- a/modules/integration/tests-integration/tests-backend/src/test/java/org/wso2/identity/integration/test/idp/mgt/ResidentIDPConfigsTestCase.java +++ b/modules/integration/tests-integration/tests-backend/src/test/java/org/wso2/identity/integration/test/idp/mgt/ResidentIDPConfigsTestCase.java @@ -144,13 +144,13 @@ public static Object[][] federatedAuthConfigURLProvider() { "Expected Passive STS URL is not found in the tenant mode"}, {"wso2.com", "OpenIdUrl", "https://localhost:9853/openidserver", "Expected OpenID Server URL is not found in the tenant mode"}, - {"wso2.com", "ECPUrl", "https://localhost:9853/samlecp?tenantDomain=wso2.com", + {"wso2.com", "ECPUrl", "https://localhost:9853/t/wso2.com/samlecp", "Expected ECP URL is not found in the tenant mode"}, - {"wso2.com", "LogoutReqUrl", "https://localhost:9853/samlsso?tenantDomain=wso2.com", + {"wso2.com", "LogoutReqUrl", "https://localhost:9853/t/wso2.com/samlsso", "Expected Logout URL is not found in the tenant mode"}, {"wso2.com", "ArtifactResolveUrl", "https://localhost:9853/samlartresolve", "Expected Artifact Resolution URL is not found in the tenant mode"}, - {"wso2.com", "SSOUrl", "https://localhost:9853/samlsso?tenantDomain=wso2.com", + {"wso2.com", "SSOUrl", "https://localhost:9853/t/wso2.com/samlsso", "Expected SSO URL is not found in the tenant mode"}, {"wso2.com", "IDENTITY_PROVIDER_URL", "https://localhost:9853/services/t/wso2.com/wso2carbon-sts", "Expected Security Token Service URL is not found in the tenant mode"}, diff --git a/modules/integration/tests-integration/tests-backend/src/test/java/org/wso2/identity/integration/test/oauth2/OAuth2ServiceSAML2BearerGrantTestCase.java b/modules/integration/tests-integration/tests-backend/src/test/java/org/wso2/identity/integration/test/oauth2/OAuth2ServiceSAML2BearerGrantTestCase.java index 67294f1455f..443b5dbd8ba 100644 --- a/modules/integration/tests-integration/tests-backend/src/test/java/org/wso2/identity/integration/test/oauth2/OAuth2ServiceSAML2BearerGrantTestCase.java +++ b/modules/integration/tests-integration/tests-backend/src/test/java/org/wso2/identity/integration/test/oauth2/OAuth2ServiceSAML2BearerGrantTestCase.java @@ -85,7 +85,6 @@ public class OAuth2ServiceSAML2BearerGrantTestCase extends OAuth2ServiceAbstract private static final String COMMON_AUTH_URL = "https://localhost:9853/commonauth"; private static final String USER_AGENT = "Apache-HttpClient/4.2.5 (java 1.5)"; private static final String ACS_URL = "http://localhost:8490/%s/home.jsp"; - private static final String TENANT_DOMAIN_PARAM = "tenantDomain"; private static final String SAML_SSO_URL = "https://localhost:9853/samlsso"; private static final String ISSUER = "travelocity.com"; @@ -359,7 +358,6 @@ private HttpResponse sendSAMLRequest(String samlMsgValue) throws IOException { post.setHeader("User-Agent", USER_AGENT); urlParameters.add(new BasicNameValuePair(CommonConstants.SAML_REQUEST_PARAM, samlMsgValue)); - urlParameters.add(new BasicNameValuePair(TENANT_DOMAIN_PARAM, "carbon.super")); post.setEntity(new UrlEncodedFormEntity(urlParameters)); diff --git a/modules/integration/tests-integration/tests-backend/src/test/java/org/wso2/identity/integration/test/oidc/OIDCFederatedIdpInitLogoutTest.java b/modules/integration/tests-integration/tests-backend/src/test/java/org/wso2/identity/integration/test/oidc/OIDCFederatedIdpInitLogoutTest.java index 5127091d005..7492bcc49c8 100644 --- a/modules/integration/tests-integration/tests-backend/src/test/java/org/wso2/identity/integration/test/oidc/OIDCFederatedIdpInitLogoutTest.java +++ b/modules/integration/tests-integration/tests-backend/src/test/java/org/wso2/identity/integration/test/oidc/OIDCFederatedIdpInitLogoutTest.java @@ -147,8 +147,6 @@ public class OIDCFederatedIdpInitLogoutTest extends AbstractIdentityFederationTe private static final String HTTPS_LOCALHOST_SERVICES = "https://localhost:%s/"; private static final String SAML_IDP_SLO_URL = SECONDARY_IS_SAML_SSO_URL + "?slo=true"; - private static final String TENANT_DOMAIN_PARAM = "tenantDomain"; - private SCIM2RestClient scim2RestClient; private String secondaryISClientID; private String secondaryISClientSecret; @@ -349,10 +347,9 @@ public HttpResponse sendSAMLMessage(String url, String samlMsgKey, String samlMs throws IOException { List urlParameters = new ArrayList<>(); - HttpPost post = new HttpPost(url); + HttpPost post = new HttpPost(getTenantQualifiedURL(url, tenantInfo.getDomain())); post.setHeader("User-Agent", USER_AGENT); urlParameters.add(new BasicNameValuePair(samlMsgKey, samlMsgValue)); - urlParameters.add(new BasicNameValuePair(TENANT_DOMAIN_PARAM, "carbon.super")); post.setEntity(new UrlEncodedFormEntity(urlParameters)); return client.execute(post); diff --git a/modules/integration/tests-integration/tests-backend/src/test/java/org/wso2/identity/integration/test/postAuthnHandler/ChallengeQuestionPostAuthnHandlerTestCase.java b/modules/integration/tests-integration/tests-backend/src/test/java/org/wso2/identity/integration/test/postAuthnHandler/ChallengeQuestionPostAuthnHandlerTestCase.java index cb2556e5a85..a68e5f1a509 100644 --- a/modules/integration/tests-integration/tests-backend/src/test/java/org/wso2/identity/integration/test/postAuthnHandler/ChallengeQuestionPostAuthnHandlerTestCase.java +++ b/modules/integration/tests-integration/tests-backend/src/test/java/org/wso2/identity/integration/test/postAuthnHandler/ChallengeQuestionPostAuthnHandlerTestCase.java @@ -75,7 +75,6 @@ public class ChallengeQuestionPostAuthnHandlerTestCase extends ISIntegrationTest { - private static final String TENANT_DOMAIN_PARAM = "tenantDomain"; private static final Log log = LogFactory.getLog(ChallengeQuestionPostAuthnHandlerTestCase.class); // SAML Application attributes private static final String USER_AGENT = "Apache-HttpClient/4.2.5 (java 1.5)"; @@ -395,12 +394,9 @@ public void testLoginWithChallengeQuestions() { private HttpResponse sendSAMLMessage(String url, String samlMsgKey, String samlMsgValue, CloseableHttpClient httpClient) throws IOException { List urlParameters = new ArrayList(); - HttpPost post = new HttpPost(url); + HttpPost post = new HttpPost(getTenantQualifiedURL(url, tenantInfo.getDomain())); post.setHeader("User-Agent", USER_AGENT); urlParameters.add(new BasicNameValuePair(samlMsgKey, samlMsgValue)); - if (config.getUserMode() == TestUserMode.TENANT_ADMIN || config.getUserMode() == TestUserMode.TENANT_USER) { - urlParameters.add(new BasicNameValuePair(TENANT_DOMAIN_PARAM, config.getUser().getTenantDomain())); - } post.setEntity(new UrlEncodedFormEntity(urlParameters)); return httpClient.execute(post); } diff --git a/modules/integration/tests-integration/tests-backend/src/test/java/org/wso2/identity/integration/test/saml/AbstractSAMLSSOTestCase.java b/modules/integration/tests-integration/tests-backend/src/test/java/org/wso2/identity/integration/test/saml/AbstractSAMLSSOTestCase.java index 00197168648..fde73f3e236 100644 --- a/modules/integration/tests-integration/tests-backend/src/test/java/org/wso2/identity/integration/test/saml/AbstractSAMLSSOTestCase.java +++ b/modules/integration/tests-integration/tests-backend/src/test/java/org/wso2/identity/integration/test/saml/AbstractSAMLSSOTestCase.java @@ -84,7 +84,6 @@ public abstract class AbstractSAMLSSOTestCase extends ISIntegrationTest { private static final String INBOUND_AUTH_TYPE = "samlsso"; private static final String ATTRIBUTE_CS_INDEX_VALUE = "1239245949"; private static final String ATTRIBUTE_CS_INDEX_NAME = "attrConsumServiceIndex"; - public static final String TENANT_DOMAIN_PARAM = "tenantDomain"; protected static final String SAML = "saml"; protected static final String SAML_SSO_URL = "https://localhost:9853/samlsso"; protected static final String SAML_IDP_SLO_URL = SAML_SSO_URL + "?slo=true"; @@ -644,12 +643,9 @@ public HttpResponse sendSAMLMessage(String url, String samlMsgKey, String samlMs throws IOException { List urlParameters = new ArrayList(); - HttpPost post = new HttpPost(url); + HttpPost post = new HttpPost(getTenantQualifiedURL(url, tenantInfo.getDomain())); post.setHeader("User-Agent", USER_AGENT); urlParameters.add(new BasicNameValuePair(samlMsgKey, samlMsgValue)); - if (config.getUserMode() == TestUserMode.TENANT_ADMIN || config.getUserMode() == TestUserMode.TENANT_USER) { - urlParameters.add(new BasicNameValuePair(TENANT_DOMAIN_PARAM, config.getUser().getTenantDomain())); - } post.setEntity(new UrlEncodedFormEntity(urlParameters)); return httpClient.execute(post); diff --git a/modules/integration/tests-integration/tests-backend/src/test/java/org/wso2/identity/integration/test/saml/RegistryMountTestCase.java b/modules/integration/tests-integration/tests-backend/src/test/java/org/wso2/identity/integration/test/saml/RegistryMountTestCase.java index b8b99660ced..81cee405309 100644 --- a/modules/integration/tests-integration/tests-backend/src/test/java/org/wso2/identity/integration/test/saml/RegistryMountTestCase.java +++ b/modules/integration/tests-integration/tests-backend/src/test/java/org/wso2/identity/integration/test/saml/RegistryMountTestCase.java @@ -76,7 +76,6 @@ public class RegistryMountTestCase extends ISIntegrationTest { private static final String USER_AGENT = "Apache-HttpClient/4.2.5 (java 1.5)"; private static final String APPLICATION_NAME = "SAML-SSO-TestApplication"; private static final String ATTRIBUTE_CS_INDEX_VALUE = "1239245949"; - private static final String TENANT_DOMAIN_PARAM = "tenantDomain"; private static final String ACS_URL = "http://localhost:8490/%s/home.jsp"; private static final String COMMON_AUTH_URL = "https://localhost:9853/commonauth"; @@ -214,10 +213,9 @@ private HttpResponse sendGetRequest(String url) throws Exception { private HttpResponse sendSAMLMessage(String url, String samlMsgKey, String samlMsgValue) throws IOException { List urlParameters = new ArrayList<>(); - HttpPost post = new HttpPost(url); + HttpPost post = new HttpPost(getTenantQualifiedURL(url, tenantInfo.getDomain())); post.setHeader("User-Agent", USER_AGENT); urlParameters.add(new BasicNameValuePair(samlMsgKey, samlMsgValue)); - urlParameters.add(new BasicNameValuePair(TENANT_DOMAIN_PARAM, TENANT_DOMAIN)); post.setEntity(new UrlEncodedFormEntity(urlParameters)); return httpClient.execute(post); diff --git a/modules/integration/tests-integration/tests-backend/src/test/java/org/wso2/identity/integration/test/saml/SAMLErrorResponseTestCase.java b/modules/integration/tests-integration/tests-backend/src/test/java/org/wso2/identity/integration/test/saml/SAMLErrorResponseTestCase.java index ac2f74f00dc..9334c3cabb4 100644 --- a/modules/integration/tests-integration/tests-backend/src/test/java/org/wso2/identity/integration/test/saml/SAMLErrorResponseTestCase.java +++ b/modules/integration/tests-integration/tests-backend/src/test/java/org/wso2/identity/integration/test/saml/SAMLErrorResponseTestCase.java @@ -72,7 +72,6 @@ public class SAMLErrorResponseTestCase extends ISIntegrationTest { private static final String USER_AGENT = "Apache-HttpClient/4.2.5 (java 1.5)"; private static final String APPLICATION_NAME = "SAML-SSO-TestApplication"; private static final String ARTIFACT_ID = "travelocity.com"; - private static final String TENANT_DOMAIN_PARAM = "tenantDomain"; private static final String SAML_SSO_URL = "https://localhost:9853/samlsso"; private static final String ACS_URL = "http://localhost:8490/%s/home.jsp"; @@ -185,12 +184,11 @@ private void setSystemProperties() { private HttpResponse sendSAMLMessage(String url, Map parameters) throws Exception { List urlParameters = new ArrayList(); - HttpPost post = new HttpPost(url); + HttpPost post = new HttpPost(getTenantQualifiedURL(url, tenantInfo.getDomain())); post.setHeader("User-Agent", USER_AGENT); for (Map.Entry entry : parameters.entrySet()) { urlParameters.add(new BasicNameValuePair(entry.getKey(), entry.getValue())); } - urlParameters.add(new BasicNameValuePair(TENANT_DOMAIN_PARAM, isServer.getSuperTenant().getDomain())); post.setEntity(new UrlEncodedFormEntity(urlParameters)); return httpClient.execute(post); } diff --git a/modules/integration/tests-integration/tests-backend/src/test/java/org/wso2/identity/integration/test/saml/SAMLIdPInitiatedSSOTestCase.java b/modules/integration/tests-integration/tests-backend/src/test/java/org/wso2/identity/integration/test/saml/SAMLIdPInitiatedSSOTestCase.java index 42b7cf29797..61f27c4375e 100644 --- a/modules/integration/tests-integration/tests-backend/src/test/java/org/wso2/identity/integration/test/saml/SAMLIdPInitiatedSSOTestCase.java +++ b/modules/integration/tests-integration/tests-backend/src/test/java/org/wso2/identity/integration/test/saml/SAMLIdPInitiatedSSOTestCase.java @@ -61,7 +61,7 @@ public class SAMLIdPInitiatedSSOTestCase extends AbstractSAMLSSOTestCase { private static final String IDP_INIT_SSO_URL = "https://localhost:%s/samlsso?spEntityID=%s"; private static final String IDP_INIT_SSO_TENANT_URL - = "https://localhost:%s/samlsso?tenantDomain=wso2.com&spEntityID=%s"; + = "https://localhost:%s/t/wso2.com/samlsso?spEntityID=%s"; private static final String SAML_SSO_URL = "https://localhost:%s/samlsso"; private static final String SP_ACS_URL = "http://localhost:8490/%s/home.jsp"; private HttpClient httpClient; diff --git a/modules/integration/tests-integration/tests-backend/src/test/java/org/wso2/identity/integration/test/saml/SAMLLocalAndOutboundAuthenticatorsTestCase.java b/modules/integration/tests-integration/tests-backend/src/test/java/org/wso2/identity/integration/test/saml/SAMLLocalAndOutboundAuthenticatorsTestCase.java index 4df43494e29..1a0064dde64 100644 --- a/modules/integration/tests-integration/tests-backend/src/test/java/org/wso2/identity/integration/test/saml/SAMLLocalAndOutboundAuthenticatorsTestCase.java +++ b/modules/integration/tests-integration/tests-backend/src/test/java/org/wso2/identity/integration/test/saml/SAMLLocalAndOutboundAuthenticatorsTestCase.java @@ -77,7 +77,6 @@ public class SAMLLocalAndOutboundAuthenticatorsTestCase extends ISIntegrationTes private static final String CALLBACK_URL = "callbackUrl"; private static final String SAML_SSO_LOGIN_URL = "http://localhost:8490/%s/samlsso?SAML2.HTTPBinding=%s"; private static final String USER_AGENT = "Apache-HttpClient/4.2.5 (java 1.5)"; - public static final String TENANT_DOMAIN_PARAM = "tenantDomain"; private static final String SAML_SSO_URL = "https://localhost:" + CommonConstants.IS_DEFAULT_HTTPS_PORT + "/samlsso"; private static final String COMMON_AUTH_URL = "https://localhost:" + CommonConstants.IS_DEFAULT_HTTPS_PORT + @@ -283,8 +282,8 @@ public void testErrorCodeInRedirectUrl() throws Exception { String samlRequest = Utils.extractDataFromResponse(response, CommonConstants.SAML_REQUEST_PARAM, 5); Map paramters = new HashMap(); paramters.put(CommonConstants.SAML_REQUEST_PARAM, samlRequest); - response = Utils.sendSAMLMessage(SAML_SSO_URL, paramters, USER_AGENT, config.getUserMode(), - TENANT_DOMAIN_PARAM, config.getUser().getTenantDomain(), httpClient); + response = Utils.sendSAMLMessage(getTenantQualifiedURL(SAML_SSO_URL, config.getUser().getTenantDomain()) + , paramters, USER_AGENT, httpClient); EntityUtils.consume(response.getEntity()); response = Utils.sendRedirectRequest(response, USER_AGENT, ACS_URL, config.getApplication() .getArtifact(), httpClient); diff --git a/modules/integration/tests-integration/tests-backend/src/test/java/org/wso2/identity/integration/test/saml/SAMLMetadataTestCase.java b/modules/integration/tests-integration/tests-backend/src/test/java/org/wso2/identity/integration/test/saml/SAMLMetadataTestCase.java index bdd47492199..808a92f2f70 100644 --- a/modules/integration/tests-integration/tests-backend/src/test/java/org/wso2/identity/integration/test/saml/SAMLMetadataTestCase.java +++ b/modules/integration/tests-integration/tests-backend/src/test/java/org/wso2/identity/integration/test/saml/SAMLMetadataTestCase.java @@ -41,7 +41,7 @@ public class SAMLMetadataTestCase extends ISIntegrationTest { "https://localhost:9853/t/wso2.com/identity/metadata/saml2"; private static final String SAML_METADATA_ENDPOINT_WITH_SUPER_TENANT_AS_PATH_PARAM = "https://localhost:9853/t/carbon.super/identity/metadata/saml2"; - private static final String SAML_SSO_ENDPOINT_TENANT = "https://localhost:9853/samlsso?tenantDomain=wso2.com"; + private static final String SAML_SSO_ENDPOINT_TENANT = "https://localhost:9853/t/wso2.com/samlsso"; private static final String SAML_SSO_ENDPOINT_SUPER_TENANT = "https://localhost:9853/samlsso"; private static final String SAMLARTRESOLVE_ENDPOINT = "https://localhost:9853/samlartresolve"; diff --git a/modules/integration/tests-integration/tests-backend/src/test/java/org/wso2/identity/integration/test/saml/SAMLSSOTestCase.java b/modules/integration/tests-integration/tests-backend/src/test/java/org/wso2/identity/integration/test/saml/SAMLSSOTestCase.java index 79d4f9a1fec..c0c1c06b211 100644 --- a/modules/integration/tests-integration/tests-backend/src/test/java/org/wso2/identity/integration/test/saml/SAMLSSOTestCase.java +++ b/modules/integration/tests-integration/tests-backend/src/test/java/org/wso2/identity/integration/test/saml/SAMLSSOTestCase.java @@ -236,8 +236,8 @@ public void testSAMLRelayStateDecode() throws Exception { Map paramters = new HashMap(); paramters.put(CommonConstants.SAML_REQUEST_PARAM, samlRequest); paramters.put("RelayState", relayState); - response = Utils.sendSAMLMessage(SAML_SSO_URL, paramters, USER_AGENT, config.getUserMode(), - TENANT_DOMAIN_PARAM, config.getUser().getTenantDomain(), httpClient); + response = Utils.sendSAMLMessage(getTenantQualifiedURL(SAML_SSO_URL, + config.getUser().getTenantDomain()), paramters, USER_AGENT, httpClient); EntityUtils.consume(response.getEntity()); response = Utils.sendRedirectRequest(response, USER_AGENT, ACS_URL, config.getApp().getArtifact(), httpClient); diff --git a/modules/integration/tests-integration/tests-backend/src/test/java/org/wso2/identity/integration/test/sts/TestPassiveSTS.java b/modules/integration/tests-integration/tests-backend/src/test/java/org/wso2/identity/integration/test/sts/TestPassiveSTS.java index 2de033c22ca..b68e653492c 100644 --- a/modules/integration/tests-integration/tests-backend/src/test/java/org/wso2/identity/integration/test/sts/TestPassiveSTS.java +++ b/modules/integration/tests-integration/tests-backend/src/test/java/org/wso2/identity/integration/test/sts/TestPassiveSTS.java @@ -117,7 +117,7 @@ public void testInit() throws Exception { .setDefaultRequestConfig(requestConfig) .setDefaultCookieStore(cookieStore).build(); String isURL = backendURL.substring(0, backendURL.indexOf("services/")); - this.passiveStsURL = isURL + "passivests"; + this.passiveStsURL = getTenantQualifiedURL(isURL + "passivests", tenantDomain); setSystemProperties(); } @@ -195,7 +195,6 @@ public void testInvokePassiveSTSEndPoint() throws IOException { cookieStore.clear(); String passiveParams = "?wreply=" + PASSIVE_STS_SAMPLE_APP_URL + "&wtrealm=PassiveSTSSampleApp"; - passiveParams = appendTenantDomainQueryParam(passiveParams); HttpGet request = new HttpGet(this.passiveStsURL + passiveParams); HttpResponse response = client.execute(request); Assert.assertNotNull(response, "PassiveSTSSampleApp invoke response is null for tenant domain: " + @@ -258,7 +257,6 @@ public void testPassiveSAML2Assertion() throws Exception { + "%2Fwss%2Foasis-wss-saml-token-profile-1.1%23SAMLV2.0%3C%2Fwst%3ATokenType%3E%3C%2Fwst" + "%3ARequestSecurityToken%3E"; - passiveParams = appendTenantDomainQueryParam(passiveParams); HttpGet request = new HttpGet(this.passiveStsURL + passiveParams + wreqParam); HttpResponse response = client.execute(request); @@ -282,7 +280,6 @@ public void testPassiveSAML2AssertionWithoutWReply() throws Exception { + "%2Fwss%2Foasis-wss-saml-token-profile-1.1%23SAMLV2.0%3C%2Fwst%3ATokenType%3E%3C%2Fwst" + "%3ARequestSecurityToken%3E"; - passiveParams = appendTenantDomainQueryParam(passiveParams); HttpGet request = new HttpGet(this.passiveStsURL + passiveParams + wreqParam); HttpResponse response = client.execute(request); @@ -310,7 +307,6 @@ public void testPassiveSAML2AssertionForInvalidWReply() throws Exception { + "%2Fwss%2Foasis-wss-saml-token-profile-1.1%23SAMLV2.0%3C%2Fwst%3ATokenType%3E%3C%2Fwst" + "%3ARequestSecurityToken%3E"; - passiveParams = appendTenantDomainQueryParam(passiveParams); HttpGet request = new HttpGet(this.passiveStsURL + passiveParams + wreqParam); HttpResponse response = client.execute(request); @@ -340,7 +336,6 @@ public void testSessionHijacking() throws Exception { public void testSendLogoutRequest() throws Exception { String passiveParams = "?wa=wsignout1.0&wreply=" + PASSIVE_STS_SAMPLE_APP_URL + "&wtrealm=PassiveSTSSampleApp"; - passiveParams = appendTenantDomainQueryParam(passiveParams); HttpGet request = new HttpGet(this.passiveStsURL + passiveParams); HttpResponse response = client.execute(request); Assert.assertNotNull(response, "PassiveSTSSampleApp logout response is null for tenant domain: " + @@ -395,12 +390,4 @@ private boolean requestMissingClaims(HttpResponse response) { String redirectUrl = Utils.getRedirectUrl(response); return redirectUrl.contains("consent.do"); } - - private String appendTenantDomainQueryParam(String params) { - - if (!StringUtils.equals(tenantDomain, "carbon.super")) { - return params + "&tenantDomain=" + tenantDomain; - } - return params; - } } diff --git a/modules/integration/tests-integration/tests-backend/src/test/java/org/wso2/identity/integration/test/util/Utils.java b/modules/integration/tests-integration/tests-backend/src/test/java/org/wso2/identity/integration/test/util/Utils.java index e86e504b64b..f76f036f1a3 100644 --- a/modules/integration/tests-integration/tests-backend/src/test/java/org/wso2/identity/integration/test/util/Utils.java +++ b/modules/integration/tests-integration/tests-backend/src/test/java/org/wso2/identity/integration/test/util/Utils.java @@ -452,7 +452,7 @@ public static HttpResponse sendECPPostRequest(String url, String userAgent, Http return response; } - public static HttpResponse sendSAMLMessage(String url, Map parameters, String userAgent, TestUserMode userMode, String tenantDomainParam, String tenantDomain, HttpClient httpClient) throws IOException { + public static HttpResponse sendSAMLMessage(String url, Map parameters, String userAgent, HttpClient httpClient) throws IOException { List urlParameters = new ArrayList(); HttpPost post = new HttpPost(url); @@ -460,9 +460,6 @@ public static HttpResponse sendSAMLMessage(String url, Map param for (Map.Entry entry : parameters.entrySet()) { urlParameters.add(new BasicNameValuePair(entry.getKey(), entry.getValue())); } - if (userMode == TestUserMode.TENANT_ADMIN || userMode == TestUserMode.TENANT_USER) { - urlParameters.add(new BasicNameValuePair(tenantDomainParam, tenantDomain)); - } post.setEntity(new UrlEncodedFormEntity(urlParameters)); return httpClient.execute(post); } diff --git a/modules/integration/tests-ui-integration/tests-ui/src/test/java/org/wso2/identity/ui/integration/test/email/template/EmailTemplateChangeUITest.java b/modules/integration/tests-ui-integration/tests-ui/src/test/java/org/wso2/identity/ui/integration/test/email/template/EmailTemplateChangeUITest.java index 5bcb8d78133..37f7a71cba8 100644 --- a/modules/integration/tests-ui-integration/tests-ui/src/test/java/org/wso2/identity/ui/integration/test/email/template/EmailTemplateChangeUITest.java +++ b/modules/integration/tests-ui-integration/tests-ui/src/test/java/org/wso2/identity/ui/integration/test/email/template/EmailTemplateChangeUITest.java @@ -32,7 +32,7 @@ public class EmailTemplateChangeUITest extends ISIntegrationUiBaseTest { private static final String TEST_EMAIL_TYPE_PASSWORD = "Ask Password"; - private static final String TEST_EMAIL_BODY_ASK_PASSWORD = "Hi {first-name}\n\n\"\n\nPlease change your password for the newly created account : {user-name}. Please click the link below to create the password.\n\nhttps://localhost:8443/InfoRecoverySample/infoRecover/verify?confirmation={confirmation-code}&userstoredomain={userstore-domain}&username={url:user-name}&tenantdomain={tenant-domain}\n\nIf clicking the link doesn't seem to work, you can copy and paste the\nlink into your browser's address window."; + private static final String TEST_EMAIL_BODY_ASK_PASSWORD = "Hi {first-name}\n\n\"\n\nPlease change your password for the newly created account : {user-name}. Please click the link below to create the password.\n\nhttps://localhost:8443/t/wso2.com/InfoRecoverySample/infoRecover/verify?confirmation={confirmation-code}&userstoredomain={userstore-domain}&username={url:user-name}\n\nIf clicking the link doesn't seem to work, you can copy and paste the\nlink into your browser's address window."; @Test public void testChangeTemplateBody() throws Exception { From bad62731f1d68310c5d091343a9bcbdfec90233d Mon Sep 17 00:00:00 2001 From: Thisara-Welmilla Date: Wed, 27 Sep 2023 08:52:25 +0530 Subject: [PATCH 06/16] Fix failed integration tests --- .../test/consent/SelfSignUpConsentTest.java | 12 +++++----- .../idp/mgt/ResidentIDPConfigsTestCase.java | 22 +++++++++---------- .../test/oauth2/OAuth2RoleClaimTestCase.java | 8 ++++--- ...OAuth2ServiceClientCredentialTestCase.java | 2 +- .../OAuth2ServiceImplicitGrantTestCase.java | 3 ++- .../OAuth2ServiceIntrospectionTestCase.java | 2 +- ...Auth2ServiceRefreshTokenGrantTestCase.java | 5 +++-- .../OAuth2XACMLScopeValidatorTestCase.java | 6 ++--- .../test/oauth2/OIDCDiscoveryTestCase.java | 2 +- ...PermissionBasedScopeValidatorTestCase.java | 6 ++--- ...stemScopePermissionValidationTestCase.java | 9 +++++--- 11 files changed, 42 insertions(+), 35 deletions(-) diff --git a/modules/integration/tests-integration/tests-backend/src/test/java/org/wso2/identity/integration/test/consent/SelfSignUpConsentTest.java b/modules/integration/tests-integration/tests-backend/src/test/java/org/wso2/identity/integration/test/consent/SelfSignUpConsentTest.java index 228d2ecb60e..24d5b7cabdf 100644 --- a/modules/integration/tests-integration/tests-backend/src/test/java/org/wso2/identity/integration/test/consent/SelfSignUpConsentTest.java +++ b/modules/integration/tests-integration/tests-backend/src/test/java/org/wso2/identity/integration/test/consent/SelfSignUpConsentTest.java @@ -69,7 +69,6 @@ public class SelfSignUpConsentTest extends ISIntegrationTest { private static final String COUNTRY_WSO2_CLAIM = "http://wso2.org/claims/country"; private static final String CALLBACK_QUERY_PARAM = "callback"; private static final String USERNAME_QUERY_PARAM = "username"; - private static final String TENANT_DOMAIN_QUERY_PARAM = "tenantDomain"; private static final String ADMIN = "admin"; private static final String EBONY = "ebony"; private static final String PASSWORD = "UsEr@123"; @@ -79,7 +78,7 @@ public class SelfSignUpConsentTest extends ISIntegrationTest { private static final String FINANCIAL = "Financial"; private static final String ERROR_MESSAGE_SELF_REGISTRATION_DISABLED = "Self registration is disabled for tenant" + " - %s"; - private static final String ERROR_MESSAGE_INVALID_TENANT = "Invalid tenant domain :%s"; + private static final String ERROR_MESSAGE_INVALID_TENANT = "%s is an invalid tenant domain"; private static final String ERROR_MESSAGE_USERNAME_TAKEN = "Username '%s' is already taken. Please pick a " + "different username"; @@ -142,6 +141,7 @@ public void testInitialSelfSignUpPage() throws IOException { HttpClient client = HttpClientBuilder.create().build(); String selfRegisterEndpoint = selfRegisterDoEndpoint + "?" + CALLBACK_QUERY_PARAM + "=" + CALLBACK_ENDPOINT; + selfRegisterEndpoint = getTenantQualifiedURL(selfRegisterEndpoint, secondaryTenantDomain); HttpResponse httpResponse = sendGetRequest(client, selfRegisterEndpoint); String content = DataExtractUtil.getContentData(httpResponse); Assert.assertNotNull(content); @@ -296,8 +296,8 @@ private String doCallSignUpDo(String username) throws IOException { username = MultitenantUtils.getTenantAwareUsername(username); } String selfRegisterEndpoint = - signupDoEndpoint + "?" + USERNAME_QUERY_PARAM + "=" + username + "&" + TENANT_DOMAIN_QUERY_PARAM + "=" - + tenantDomain; + signupDoEndpoint + "?" + USERNAME_QUERY_PARAM + "=" + username; + selfRegisterEndpoint = getTenantQualifiedURL(selfRegisterEndpoint, tenantDomain); HttpResponse httpResponse = sendGetRequest(client, selfRegisterEndpoint); return DataExtractUtil.getContentData(httpResponse); } @@ -436,12 +436,12 @@ private void selfRegister(String username, String password, String givenName, St private String getConsentReqBody(String purposeId, int piiCategoryId, String username) { - return "{\\\"jurisdiction\\\":\\\"someJurisdiction\\\",\\\"collectionMethod\\\":\\\"Web Form - Self " + + return "{\\\"jurisdiction\\\":\\\"someJurisdiction\\\",\\\"collectionMethod\\\":\\\"Web Form - Self " + "Registration\\\"," + "\\\"language\\\":\\\"en\\\",\\\"piiPrincipalId\\\":\\\""+username+"\\\",\\\"services\\\":" + "[{\\\"tenantDomain\\\":\\\"wso2.com\\\",\\\"serviceDisplayName\\\":\\\"Resident IDP\\\"," + "\\\"serviceDescription\\\":\\\"Resident IDP\\\",\\\"purposes\\\":[{\\\"purposeId\\\":"+purposeId+"," + - "\\\"purposeCategoryId\\\":[1]," + + "\\\"purposeCategoryId\\\":[1]," + "\\\"consentType\\\":\\\"EXPLICIT\\\",\\\"piiCategory\\\":[{\\\"piiCategoryId\\\":"+piiCategoryId+"," + "\\\"validity\\\":\\\"DATE_UNTIL:INDEFINITE\\\"}],\\\"primaryPurpose\\\":true," + "\\\"termination\\\":\\\"DATE_UNTIL:INDEFINITE\\\",\\\"thirdPartyDisclosure\\\":false}],\\\"tenantId\\\":1}]," + diff --git a/modules/integration/tests-integration/tests-backend/src/test/java/org/wso2/identity/integration/test/idp/mgt/ResidentIDPConfigsTestCase.java b/modules/integration/tests-integration/tests-backend/src/test/java/org/wso2/identity/integration/test/idp/mgt/ResidentIDPConfigsTestCase.java index e637f6b5111..4841745672b 100644 --- a/modules/integration/tests-integration/tests-backend/src/test/java/org/wso2/identity/integration/test/idp/mgt/ResidentIDPConfigsTestCase.java +++ b/modules/integration/tests-integration/tests-backend/src/test/java/org/wso2/identity/integration/test/idp/mgt/ResidentIDPConfigsTestCase.java @@ -140,31 +140,31 @@ public static Object[][] federatedAuthConfigURLProvider() { "Expected OAuth10a Authorize URL is not found in the tenant mode"}, {"wso2.com", "OAuth1RequestTokenUrl", "https://localhost:9853/oauth/request-token", "Expected OAuth10a Request Token URL is not found in the tenant mode"}, - {"wso2.com", "IdentityProviderUrl", "https://localhost:9853/passivests", + {"wso2.com", "IdentityProviderUrl", "https://localhost:9853/t/wso2.com/passivests", "Expected Passive STS URL is not found in the tenant mode"}, {"wso2.com", "OpenIdUrl", "https://localhost:9853/openidserver", "Expected OpenID Server URL is not found in the tenant mode"}, - {"wso2.com", "ECPUrl", "https://localhost:9853/samlecp?tenantDomain=wso2.com", + {"wso2.com", "ECPUrl", "https://localhost:9853/t/wso2.com/samlecp", "Expected ECP URL is not found in the tenant mode"}, - {"wso2.com", "LogoutReqUrl", "https://localhost:9853/samlsso?tenantDomain=wso2.com", + {"wso2.com", "LogoutReqUrl", "https://localhost:9853/t/wso2.com/samlsso", "Expected Logout URL is not found in the tenant mode"}, - {"wso2.com", "ArtifactResolveUrl", "https://localhost:9853/samlartresolve", + {"wso2.com", "ArtifactResolveUrl", "https://localhost:9853/t/wso2.com/samlartresolve", "Expected Artifact Resolution URL is not found in the tenant mode"}, - {"wso2.com", "SSOUrl", "https://localhost:9853/samlsso?tenantDomain=wso2.com", + {"wso2.com", "SSOUrl", "https://localhost:9853/t/wso2.com/samlsso", "Expected SSO URL is not found in the tenant mode"}, {"wso2.com", "IDENTITY_PROVIDER_URL", "https://localhost:9853/services/t/wso2.com/wso2carbon-sts", "Expected Security Token Service URL is not found in the tenant mode"}, {"wso2.com", "OIDCWebFingerEPUrl", "https://localhost:9853/.well-known/webfinger", "Expected Web finger Endpoint URL is not found in the tenant mode"}, - {"wso2.com", "OIDCCheckSessionEPUrl", "https://localhost:9853/oidc/checksession", + {"wso2.com", "OIDCCheckSessionEPUrl", "https://localhost:9853/t/wso2.com/oidc/checksession", "Expected Session IFrame Endpoint URL is not found in the tenant mode"}, {"wso2.com", "OAuth2IntrospectEPUrl", "https://localhost:9853/t/wso2.com/oauth2/introspect", "Expected Token Introspection Endpoint URL is not found in the tenant mode"}, - {"wso2.com", "OAuth2RevokeEPUrl", "https://localhost:9853/oauth2/revoke", + {"wso2.com", "OAuth2RevokeEPUrl", "https://localhost:9853/t/wso2.com/oauth2/revoke", "Expected Token Revocation Endpoint URL is not found in the tenant mode"}, - {"wso2.com", "OIDCLogoutEPUrl", "https://localhost:9853/oidc/logout", + {"wso2.com", "OIDCLogoutEPUrl", "https://localhost:9853/t/wso2.com/oidc/logout", "Expected Logout Endpoint URL not found in the tenant mode"}, - {"wso2.com", "OAuth2AuthzEPUrl", "https://localhost:9853/oauth2/authorize", + {"wso2.com", "OAuth2AuthzEPUrl", "https://localhost:9853/t/wso2.com/oauth2/authorize", "Expected Authorization Endpoint URL is not found in the tenant mode"}, {"wso2.com", "OAuth2DCREPUrl", "https://localhost:9853/t/wso2.com/api/identity/oauth2/dcr/v1.1/register", "Expected Dynamic Client Registration Endpoint URL is not found in the tenant mode"}, @@ -172,9 +172,9 @@ public static Object[][] federatedAuthConfigURLProvider() { "Expected Dynamic Client Registration Endpoint URL is not found in the tenant mode"}, {"wso2.com", "OAuth2JWKSPage", "https://localhost:9853/t/wso2.com/oauth2/jwks", "Expected OAuth2 JWKS Page is not found in the tenant mode"}, - {"wso2.com", "OAuth2TokenEPUrl", "https://localhost:9853/oauth2/token", + {"wso2.com", "OAuth2TokenEPUrl", "https://localhost:9853/t/wso2.com/oauth2/token", "Expected Token Endpoint URL is not found in the tenant mode"}, - {"wso2.com", "OAuth2UserInfoEPUrl", "https://localhost:9853/oauth2/userinfo", + {"wso2.com", "OAuth2UserInfoEPUrl", "https://localhost:9853/t/wso2.com/oauth2/userinfo", "Expected User Info Endpoint URL is not found in the tenant mode"} }; } diff --git a/modules/integration/tests-integration/tests-backend/src/test/java/org/wso2/identity/integration/test/oauth2/OAuth2RoleClaimTestCase.java b/modules/integration/tests-integration/tests-backend/src/test/java/org/wso2/identity/integration/test/oauth2/OAuth2RoleClaimTestCase.java index 535147d549d..481e413a980 100644 --- a/modules/integration/tests-integration/tests-backend/src/test/java/org/wso2/identity/integration/test/oauth2/OAuth2RoleClaimTestCase.java +++ b/modules/integration/tests-integration/tests-backend/src/test/java/org/wso2/identity/integration/test/oauth2/OAuth2RoleClaimTestCase.java @@ -79,7 +79,7 @@ public void testInit() throws Exception { super.init(TestUserMode.TENANT_USER); - this.USERNAME = tenantInfo.getContextUser().getUserName(); + this.USERNAME = tenantInfo.getContextUser().getUserNameWithoutDomain(); this.PASSWORD = tenantInfo.getContextUser().getPassword(); setSystemproperties(); client = HttpClients.createDefault(); @@ -126,7 +126,8 @@ public void testRegisterApplication() throws Exception { "testRegisterApplication") public void testSendAuthorizedPost() throws Exception { - HttpPost request = new HttpPost(OAuth2Constant.ACCESS_TOKEN_ENDPOINT); + HttpPost request = new HttpPost(getTenantQualifiedURL( + OAuth2Constant.ACCESS_TOKEN_ENDPOINT, tenantInfo.getDomain())); List urlParameters = new ArrayList<>(); urlParameters.add(new BasicNameValuePair("grant_type", OAuth2Constant.OAUTH2_GRANT_TYPE_RESOURCE_OWNER)); @@ -159,7 +160,8 @@ public void testSendAuthorizedPostAfterRoleUpdate() throws Exception { scim2RestClient.updateUserRole(getAddUserPatchRole(userId), roleId); - HttpPost request = new HttpPost(OAuth2Constant.ACCESS_TOKEN_ENDPOINT); + HttpPost request = new HttpPost(getTenantQualifiedURL( + OAuth2Constant.ACCESS_TOKEN_ENDPOINT, tenantInfo.getDomain())); List urlParameters = new ArrayList<>(); urlParameters.add(new BasicNameValuePair("grant_type", OAuth2Constant.OAUTH2_GRANT_TYPE_RESOURCE_OWNER)); diff --git a/modules/integration/tests-integration/tests-backend/src/test/java/org/wso2/identity/integration/test/oauth2/OAuth2ServiceClientCredentialTestCase.java b/modules/integration/tests-integration/tests-backend/src/test/java/org/wso2/identity/integration/test/oauth2/OAuth2ServiceClientCredentialTestCase.java index 659e2e5ff16..09f3c93b223 100644 --- a/modules/integration/tests-integration/tests-backend/src/test/java/org/wso2/identity/integration/test/oauth2/OAuth2ServiceClientCredentialTestCase.java +++ b/modules/integration/tests-integration/tests-backend/src/test/java/org/wso2/identity/integration/test/oauth2/OAuth2ServiceClientCredentialTestCase.java @@ -127,7 +127,7 @@ public void testGetTokenUsingClientCredentialsGrant() throws Exception { ClientAuthentication clientAuth = new ClientSecretBasic(clientID, clientSecret); Scope scope = new Scope(OAUTH2_SCOPE_OPENID, "xyz"); - URI tokenEndpoint = new URI(OAuth2Constant.ACCESS_TOKEN_ENDPOINT); + URI tokenEndpoint = new URI(getTenantQualifiedURL(OAuth2Constant.ACCESS_TOKEN_ENDPOINT, tenantInfo.getDomain())); TokenRequest request = new TokenRequest(tokenEndpoint, clientAuth, clientCredentialsGrant, scope); HTTPResponse tokenHTTPResp = request.toHTTPRequest().send(); Assert.assertNotNull(tokenHTTPResp, "Access token http response is null."); diff --git a/modules/integration/tests-integration/tests-backend/src/test/java/org/wso2/identity/integration/test/oauth2/OAuth2ServiceImplicitGrantTestCase.java b/modules/integration/tests-integration/tests-backend/src/test/java/org/wso2/identity/integration/test/oauth2/OAuth2ServiceImplicitGrantTestCase.java index 189074b81a6..9034a86eca3 100644 --- a/modules/integration/tests-integration/tests-backend/src/test/java/org/wso2/identity/integration/test/oauth2/OAuth2ServiceImplicitGrantTestCase.java +++ b/modules/integration/tests-integration/tests-backend/src/test/java/org/wso2/identity/integration/test/oauth2/OAuth2ServiceImplicitGrantTestCase.java @@ -142,7 +142,8 @@ public void testSendAuthorozedPost() throws Exception { urlParameters.add(new BasicNameValuePair("consumerKey", consumerKey)); urlParameters.add(new BasicNameValuePair("scope", scopes)); urlParameters.add(new BasicNameValuePair("callbackurl", OAuth2Constant.CALLBACK_URL)); - urlParameters.add(new BasicNameValuePair("authorizeEndpoint", OAuth2Constant.APPROVAL_URL)); + urlParameters.add(new BasicNameValuePair("authorizeEndpoint", + getTenantQualifiedURL(OAuth2Constant.APPROVAL_URL, tenantInfo.getDomain()))); urlParameters.add(new BasicNameValuePair("authorize", OAuth2Constant.AUTHORIZE_PARAM)); urlParameters.add(new BasicNameValuePair("consumerSecret", consumerSecret)); diff --git a/modules/integration/tests-integration/tests-backend/src/test/java/org/wso2/identity/integration/test/oauth2/OAuth2ServiceIntrospectionTestCase.java b/modules/integration/tests-integration/tests-backend/src/test/java/org/wso2/identity/integration/test/oauth2/OAuth2ServiceIntrospectionTestCase.java index f82a55ed2e2..4f3db82aef9 100644 --- a/modules/integration/tests-integration/tests-backend/src/test/java/org/wso2/identity/integration/test/oauth2/OAuth2ServiceIntrospectionTestCase.java +++ b/modules/integration/tests-integration/tests-backend/src/test/java/org/wso2/identity/integration/test/oauth2/OAuth2ServiceIntrospectionTestCase.java @@ -105,7 +105,7 @@ public void testGetAccessToken() throws Exception { urlParameters.add(new BasicNameValuePair("consumerKey", consumerKey)); urlParameters.add(new BasicNameValuePair("consumerSecret", consumerSecret)); urlParameters.add(new BasicNameValuePair("accessEndpoint", - OAuth2Constant.ACCESS_TOKEN_ENDPOINT)); + getTenantQualifiedURL(OAuth2Constant.ACCESS_TOKEN_ENDPOINT, tenantInfo.getDomain()))); urlParameters.add(new BasicNameValuePair("authorize", OAuth2Constant.AUTHORIZE_PARAM)); HttpResponse response = sendPostRequestWithParameters(client, urlParameters, diff --git a/modules/integration/tests-integration/tests-backend/src/test/java/org/wso2/identity/integration/test/oauth2/OAuth2ServiceRefreshTokenGrantTestCase.java b/modules/integration/tests-integration/tests-backend/src/test/java/org/wso2/identity/integration/test/oauth2/OAuth2ServiceRefreshTokenGrantTestCase.java index 77471bc561b..587cc8588e6 100644 --- a/modules/integration/tests-integration/tests-backend/src/test/java/org/wso2/identity/integration/test/oauth2/OAuth2ServiceRefreshTokenGrantTestCase.java +++ b/modules/integration/tests-integration/tests-backend/src/test/java/org/wso2/identity/integration/test/oauth2/OAuth2ServiceRefreshTokenGrantTestCase.java @@ -53,7 +53,7 @@ public class OAuth2ServiceRefreshTokenGrantTestCase extends OAuth2ServiceAbstrac @BeforeClass(alwaysRun = true) public void testInit() throws Exception { super.init(TestUserMode.SUPER_TENANT_USER); - adminUsername = userInfo.getUserName(); + adminUsername = userInfo.getUserNameWithoutDomain(); adminPassword = userInfo.getPassword(); setSystemproperties(); @@ -111,7 +111,8 @@ public void testRefreshTokenGrant() throws Exception { } private JSONObject responseObject(List postParameters) throws Exception { - HttpPost httpPost = new HttpPost(OAuth2Constant.ACCESS_TOKEN_ENDPOINT); + HttpPost httpPost = new HttpPost(getTenantQualifiedURL( + OAuth2Constant.ACCESS_TOKEN_ENDPOINT, tenantInfo.getDomain())); //generate post request httpPost.setHeader("Authorization", "Basic " + getBase64EncodedString(consumerKey, consumerSecret)); httpPost.setHeader("Content-Type", "application/x-www-form-urlencoded"); diff --git a/modules/integration/tests-integration/tests-backend/src/test/java/org/wso2/identity/integration/test/oauth2/OAuth2XACMLScopeValidatorTestCase.java b/modules/integration/tests-integration/tests-backend/src/test/java/org/wso2/identity/integration/test/oauth2/OAuth2XACMLScopeValidatorTestCase.java index 6df5532c6e8..880c1172e2d 100644 --- a/modules/integration/tests-integration/tests-backend/src/test/java/org/wso2/identity/integration/test/oauth2/OAuth2XACMLScopeValidatorTestCase.java +++ b/modules/integration/tests-integration/tests-backend/src/test/java/org/wso2/identity/integration/test/oauth2/OAuth2XACMLScopeValidatorTestCase.java @@ -189,12 +189,12 @@ private boolean getTokenAndValidate(Scope scope) throws Exception { try { Secret password = new Secret(userInfo.getPassword()); - AuthorizationGrant passwordGrant = new ResourceOwnerPasswordCredentialsGrant(userInfo.getUserName(), - password); + AuthorizationGrant passwordGrant = new ResourceOwnerPasswordCredentialsGrant( + userInfo.getUserNameWithoutDomain(), password); ClientID clientID = new ClientID(consumerKey); Secret clientSecret = new Secret(consumerSecret); ClientAuthentication clientAuth = new ClientSecretBasic(clientID, clientSecret); - URI tokenEndpoint = new URI(OAuth2Constant.ACCESS_TOKEN_ENDPOINT); + URI tokenEndpoint = new URI(getTenantQualifiedURL(OAuth2Constant.ACCESS_TOKEN_ENDPOINT, tenantInfo.getDomain())); TokenRequest request = new TokenRequest(tokenEndpoint, clientAuth, passwordGrant, scope); HTTPResponse tokenHTTPResp = request.toHTTPRequest().send(); diff --git a/modules/integration/tests-integration/tests-backend/src/test/java/org/wso2/identity/integration/test/oauth2/OIDCDiscoveryTestCase.java b/modules/integration/tests-integration/tests-backend/src/test/java/org/wso2/identity/integration/test/oauth2/OIDCDiscoveryTestCase.java index a6cc5ceaa86..b41f4e769d4 100644 --- a/modules/integration/tests-integration/tests-backend/src/test/java/org/wso2/identity/integration/test/oauth2/OIDCDiscoveryTestCase.java +++ b/modules/integration/tests-integration/tests-backend/src/test/java/org/wso2/identity/integration/test/oauth2/OIDCDiscoveryTestCase.java @@ -86,7 +86,7 @@ public void testWebFinger() throws IOException { Object links = ((JSONObject)obj).get("links"); Assert.assertNotNull(links); String openIdProviderIssuerLocation = ((JSONObject)((JSONArray)links).get(0)).get("href").toString(); - String urlExpected = isServerBackendUrl + "/oauth2/token"; + String urlExpected = getTenantQualifiedURL(isServerBackendUrl + "/oauth2/token", config.getTenant()); Assert.assertEquals(openIdProviderIssuerLocation, urlExpected); } diff --git a/modules/integration/tests-integration/tests-backend/src/test/java/org/wso2/identity/integration/test/oauth2/PermissionBasedScopeValidatorTestCase.java b/modules/integration/tests-integration/tests-backend/src/test/java/org/wso2/identity/integration/test/oauth2/PermissionBasedScopeValidatorTestCase.java index 380880d0e1a..0d364c51b1a 100644 --- a/modules/integration/tests-integration/tests-backend/src/test/java/org/wso2/identity/integration/test/oauth2/PermissionBasedScopeValidatorTestCase.java +++ b/modules/integration/tests-integration/tests-backend/src/test/java/org/wso2/identity/integration/test/oauth2/PermissionBasedScopeValidatorTestCase.java @@ -118,12 +118,12 @@ private boolean getTokenAndValidate(Scope scope) throws Exception { try { Secret password = new Secret(userInfo.getPassword()); - AuthorizationGrant passwordGrant = new ResourceOwnerPasswordCredentialsGrant(userInfo.getUserName(), - password); + AuthorizationGrant passwordGrant = new ResourceOwnerPasswordCredentialsGrant( + userInfo.getUserNameWithoutDomain(), password); ClientID clientID = new ClientID(consumerKey); Secret clientSecret = new Secret(consumerSecret); ClientAuthentication clientAuth = new ClientSecretBasic(clientID, clientSecret); - URI tokenEndpoint = new URI(OAuth2Constant.ACCESS_TOKEN_ENDPOINT); + URI tokenEndpoint = new URI(getTenantQualifiedURL(OAuth2Constant.ACCESS_TOKEN_ENDPOINT, tenantInfo.getDomain())); TokenRequest request = new TokenRequest(tokenEndpoint, clientAuth, passwordGrant, scope); HTTPResponse tokenHTTPResp = request.toHTTPRequest().send(); diff --git a/modules/integration/tests-integration/tests-backend/src/test/java/org/wso2/identity/integration/test/oauth2/SystemScopePermissionValidationTestCase.java b/modules/integration/tests-integration/tests-backend/src/test/java/org/wso2/identity/integration/test/oauth2/SystemScopePermissionValidationTestCase.java index dc140d410f3..3b155d7da8a 100644 --- a/modules/integration/tests-integration/tests-backend/src/test/java/org/wso2/identity/integration/test/oauth2/SystemScopePermissionValidationTestCase.java +++ b/modules/integration/tests-integration/tests-backend/src/test/java/org/wso2/identity/integration/test/oauth2/SystemScopePermissionValidationTestCase.java @@ -62,6 +62,7 @@ public class SystemScopePermissionValidationTestCase extends OAuth2ServiceAbstra private String consumerSecret; private CloseableHttpClient client; private final String username; + private final String usernameWithoutTenantDomain; private final String userPassword; private final String activeTenant; private final TestUserMode testUserMode; @@ -82,6 +83,7 @@ public SystemScopePermissionValidationTestCase(TestUserMode userMode) throws Exc super.init(userMode); AutomationContext context = new AutomationContext("IDENTITY", userMode); this.username = context.getContextTenant().getTenantAdmin().getUserName(); + this.usernameWithoutTenantDomain = context.getContextTenant().getTenantAdmin().getUserNameWithoutDomain(); this.userPassword = context.getContextTenant().getTenantAdmin().getPassword(); this.activeTenant = context.getContextTenant().getDomain(); this.testUserMode = userMode; @@ -127,7 +129,7 @@ public void testGetAccessToken() throws Exception { urlParameters.add(new BasicNameValuePair("consumerKey", consumerKey)); urlParameters.add(new BasicNameValuePair("consumerSecret", consumerSecret)); urlParameters.add(new BasicNameValuePair("accessEndpoint", - OAuth2Constant.ACCESS_TOKEN_ENDPOINT)); + getTenantQualifiedURL(OAuth2Constant.ACCESS_TOKEN_ENDPOINT, tenantInfo.getDomain()))); urlParameters.add(new BasicNameValuePair("authorize", OAuth2Constant.AUTHORIZE_PARAM)); urlParameters.add(new BasicNameValuePair("scope", SYSTEM_SCOPE)); HttpResponse response = @@ -164,11 +166,12 @@ public void getTokenAndValidate() throws Exception { try { client = HttpClientBuilder.create().disableRedirectHandling().build(); Secret password = new Secret(userPassword); - AuthorizationGrant passwordGrant = new ResourceOwnerPasswordCredentialsGrant(username, password); + AuthorizationGrant passwordGrant = new ResourceOwnerPasswordCredentialsGrant( + usernameWithoutTenantDomain, password); ClientID clientID = new ClientID(consumerKey); Secret clientSecret = new Secret(consumerSecret); ClientAuthentication clientAuth = new ClientSecretBasic(clientID, clientSecret); - URI tokenEndpoint = new URI(OAuth2Constant.ACCESS_TOKEN_ENDPOINT); + URI tokenEndpoint = new URI(getTenantQualifiedURL(OAuth2Constant.ACCESS_TOKEN_ENDPOINT, tenantInfo.getDomain())); Scope systemScope = new Scope(SYSTEM_SCOPE); TokenRequest request = new TokenRequest(tokenEndpoint, clientAuth, passwordGrant, systemScope); From 2c8ebd76c831d1806b65bc7f24bf2099ea43dc3c Mon Sep 17 00:00:00 2001 From: Thisara-Welmilla Date: Sun, 1 Oct 2023 16:41:29 +0530 Subject: [PATCH 07/16] Add common methods to get tenant qualified URLs. --- .../common/utils/ISIntegrationTest.java | 2 +- .../v1/EmailTemplatesPositiveTest.java | 5 +- .../v1/IdentityGovernanceSuccessTest.java | 4 +- .../api/server/idp/v1/IdPSuccessTest.java | 133 +++++++++--------- .../library/v1/ScriptLibrarySuccessTest.java | 11 +- .../user/store/v1/UserStoreSuccessTest.java | 8 +- ...serDiscoverableApplicationSuccessTest.java | 15 +- .../apps/v1/UserAuthorizedAppsBaseTest.java | 2 +- .../apps/v2/UserAuthorizedAppsBaseTest.java | 2 +- 9 files changed, 97 insertions(+), 85 deletions(-) diff --git a/modules/integration/tests-common/integration-test-utils/src/main/java/org/wso2/identity/integration/common/utils/ISIntegrationTest.java b/modules/integration/tests-common/integration-test-utils/src/main/java/org/wso2/identity/integration/common/utils/ISIntegrationTest.java index 02ca8a12146..d6bae817266 100644 --- a/modules/integration/tests-common/integration-test-utils/src/main/java/org/wso2/identity/integration/common/utils/ISIntegrationTest.java +++ b/modules/integration/tests-common/integration-test-utils/src/main/java/org/wso2/identity/integration/common/utils/ISIntegrationTest.java @@ -179,7 +179,7 @@ public String getTenantQualifiedURL(String endpointURL, String tenantDomain) { * @param tenantDomain Tenanted domain. * @return Tenant qualified URL without hostname. */ - public String getTenantQualifiedURLWithoutHostName(String endpointURLWithHostname, String tenantDomain) { + public String getTenantedRelativePath(String endpointURLWithHostname, String tenantDomain) { if(!tenantDomain.isBlank() && !tenantDomain.equalsIgnoreCase(MultitenantConstants.SUPER_TENANT_DOMAIN_NAME)) { endpointURLWithHostname = TENANTED_URL_PATH_SPECIFIER + tenantDomain + endpointURLWithHostname; diff --git a/modules/integration/tests-integration/tests-backend/src/test/java/org/wso2/identity/integration/test/rest/api/server/email/template/v1/EmailTemplatesPositiveTest.java b/modules/integration/tests-integration/tests-backend/src/test/java/org/wso2/identity/integration/test/rest/api/server/email/template/v1/EmailTemplatesPositiveTest.java index f53b5883f59..85daaf70b46 100644 --- a/modules/integration/tests-integration/tests-backend/src/test/java/org/wso2/identity/integration/test/rest/api/server/email/template/v1/EmailTemplatesPositiveTest.java +++ b/modules/integration/tests-integration/tests-backend/src/test/java/org/wso2/identity/integration/test/rest/api/server/email/template/v1/EmailTemplatesPositiveTest.java @@ -135,8 +135,9 @@ public void testGetAllEmailTemplateTypes() throws Exception { .assertThat() .statusCode(HttpStatus.SC_OK) .body(baseIdentifier + "displayName", equalTo("AccountConfirmation")) - .body(baseIdentifier + "self", equalTo("/t/" + context.getContextTenant().getDomain() + - "/api/server/v1/email/template-types/QWNjb3VudENvbmZpcm1hdGlvbg")); + .body(baseIdentifier + "self", equalTo(getTenantedRelativePath( + "/api/server/v1/email/template-types/QWNjb3VudENvbmZpcm1hdGlvbg", + context.getContextTenant().getDomain()))); } // Get all email template types with required attributes. diff --git a/modules/integration/tests-integration/tests-backend/src/test/java/org/wso2/identity/integration/test/rest/api/server/identity/governance/v1/IdentityGovernanceSuccessTest.java b/modules/integration/tests-integration/tests-backend/src/test/java/org/wso2/identity/integration/test/rest/api/server/identity/governance/v1/IdentityGovernanceSuccessTest.java index fa4cfc51a5d..1ac773f9e9a 100644 --- a/modules/integration/tests-integration/tests-backend/src/test/java/org/wso2/identity/integration/test/rest/api/server/identity/governance/v1/IdentityGovernanceSuccessTest.java +++ b/modules/integration/tests-integration/tests-backend/src/test/java/org/wso2/identity/integration/test/rest/api/server/identity/governance/v1/IdentityGovernanceSuccessTest.java @@ -142,8 +142,8 @@ public void testGetGovernanceConnectors() { equalTo(category.getValue().getName())); validatableResponse.body("find{ it.id == '" + category.getKey() + "' }.self", - equalTo("/t/" + tenant + "/api/server/v1" + IDENTITY_GOVERNANCE_ENDPOINT_URI + "/" + - category.getValue().getId())); + equalTo(getTenantedRelativePath("/api/server/v1" + + IDENTITY_GOVERNANCE_ENDPOINT_URI + "/" + category.getValue().getId(), tenant))); } } diff --git a/modules/integration/tests-integration/tests-backend/src/test/java/org/wso2/identity/integration/test/rest/api/server/idp/v1/IdPSuccessTest.java b/modules/integration/tests-integration/tests-backend/src/test/java/org/wso2/identity/integration/test/rest/api/server/idp/v1/IdPSuccessTest.java index d3b4b0cb20d..9f624c128d5 100644 --- a/modules/integration/tests-integration/tests-backend/src/test/java/org/wso2/identity/integration/test/rest/api/server/idp/v1/IdPSuccessTest.java +++ b/modules/integration/tests-integration/tests-backend/src/test/java/org/wso2/identity/integration/test/rest/api/server/idp/v1/IdPSuccessTest.java @@ -100,64 +100,65 @@ public void testListMetaFederatedAuthenticators() throws Exception { .statusCode(HttpStatus.SC_OK) .body("find{ it.authenticatorId == 'T2ZmaWNlMzY1QXV0aGVudGljYXRvcg' }.name", equalTo ("Office365Authenticator")) - .body("find{ it.authenticatorId == 'T2ZmaWNlMzY1QXV0aGVudGljYXRvcg' }.self", equalTo("/t/" + - context.getContextTenant().getDomain() + - "/api/server/v1/identity-providers/meta/federated-authenticators" + - "/T2ZmaWNlMzY1QXV0aGVudGljYXRvcg")) + .body("find{ it.authenticatorId == 'T2ZmaWNlMzY1QXV0aGVudGljYXRvcg' }.self", equalTo( + getTenantedRelativePath("/api/server/v1/identity-providers/meta/federated-authenticators" + + "/T2ZmaWNlMzY1QXV0aGVudGljYXRvcg", context.getContextTenant().getDomain()))) .body("find{ it.authenticatorId == 'VHdpdHRlckF1dGhlbnRpY2F0b3I' }.name", equalTo ("TwitterAuthenticator")) - .body("find{ it.authenticatorId == 'VHdpdHRlckF1dGhlbnRpY2F0b3I' }.self", equalTo("/t/" + context - .getContextTenant().getDomain() + - "/api/server/v1/identity-providers/meta/federated-authenticators" + - "/VHdpdHRlckF1dGhlbnRpY2F0b3I")) + .body("find{ it.authenticatorId == 'VHdpdHRlckF1dGhlbnRpY2F0b3I' }.self", equalTo( + getTenantedRelativePath( + "/api/server/v1/identity-providers/meta/federated-authenticators" + + "/VHdpdHRlckF1dGhlbnRpY2F0b3I", context.getContextTenant().getDomain()))) .body("find{ it.authenticatorId == 'RmFjZWJvb2tBdXRoZW50aWNhdG9y' }.name", equalTo ("FacebookAuthenticator")) - .body("find{ it.authenticatorId == 'RmFjZWJvb2tBdXRoZW50aWNhdG9y' }.self", equalTo("/t/" + context - .getContextTenant().getDomain() + - "/api/server/v1/identity-providers/meta/federated-authenticators" + - "/RmFjZWJvb2tBdXRoZW50aWNhdG9y")) + .body("find{ it.authenticatorId == 'RmFjZWJvb2tBdXRoZW50aWNhdG9y' }.self", equalTo( + getTenantedRelativePath("/api/server/v1/identity-providers/meta/federated-authenticators" + + "/RmFjZWJvb2tBdXRoZW50aWNhdG9y", context.getContextTenant().getDomain()))) .body("find{ it.authenticatorId == 'R29vZ2xlT0lEQ0F1dGhlbnRpY2F0b3I' }.name", equalTo ("GoogleOIDCAuthenticator")) - .body("find{ it.authenticatorId == 'R29vZ2xlT0lEQ0F1dGhlbnRpY2F0b3I' }.self", equalTo("/t/" + - context.getContextTenant().getDomain() + - "/api/server/v1/identity-providers/meta/federated-authenticators" + - "/R29vZ2xlT0lEQ0F1dGhlbnRpY2F0b3I")) + .body("find{ it.authenticatorId == 'R29vZ2xlT0lEQ0F1dGhlbnRpY2F0b3I' }.self", equalTo( + getTenantedRelativePath("/api/server/v1/identity-providers/meta/federated-authenticators" + + "/R29vZ2xlT0lEQ0F1dGhlbnRpY2F0b3I", context.getContextTenant().getDomain()))) .body("find{ it.authenticatorId == 'TWljcm9zb2Z0V2luZG93c0xpdmVBdXRoZW50aWNhdG9y' }.name", equalTo ("MicrosoftWindowsLiveAuthenticator")) .body("find{ it.authenticatorId == 'TWljcm9zb2Z0V2luZG93c0xpdmVBdXRoZW50aWNhdG9y' }.self", equalTo - ("/t/" + context.getContextTenant().getDomain() + + (getTenantedRelativePath( "/api/server/v1/identity-providers/meta/federated-authenticators" + - "/TWljcm9zb2Z0V2luZG93c0xpdmVBdXRoZW50aWNhdG9y")) + "/TWljcm9zb2Z0V2luZG93c0xpdmVBdXRoZW50aWNhdG9y", context.getContextTenant().getDomain()))) .body("find{ it.authenticatorId == 'UGFzc2l2ZVNUU0F1dGhlbnRpY2F0b3I' }.name", equalTo ("PassiveSTSAuthenticator")) - .body("find{ it.authenticatorId == 'UGFzc2l2ZVNUU0F1dGhlbnRpY2F0b3I' }.self", equalTo("/t/" + - context.getContextTenant().getDomain() + - "/api/server/v1/identity-providers/meta/federated-authenticators" + - "/UGFzc2l2ZVNUU0F1dGhlbnRpY2F0b3I")) + .body("find{ it.authenticatorId == 'UGFzc2l2ZVNUU0F1dGhlbnRpY2F0b3I' }.self", equalTo( + getTenantedRelativePath( + "/api/server/v1/identity-providers/meta/federated-authenticators" + + "/UGFzc2l2ZVNUU0F1dGhlbnRpY2F0b3I", context.getContextTenant().getDomain()))) .body("find{ it.authenticatorId == 'SVdBS2VyYmVyb3NBdXRoZW50aWNhdG9y' }.name", equalTo ("IWAKerberosAuthenticator")) - .body("find{ it.authenticatorId == 'SVdBS2VyYmVyb3NBdXRoZW50aWNhdG9y' }.self", equalTo("/t/" + - context.getContextTenant().getDomain() + - "/api/server/v1/identity-providers/meta/federated-authenticators" + - "/SVdBS2VyYmVyb3NBdXRoZW50aWNhdG9y")) + .body("find{ it.authenticatorId == 'SVdBS2VyYmVyb3NBdXRoZW50aWNhdG9y' }.self", equalTo( + getTenantedRelativePath( + "/api/server/v1/identity-providers/meta/federated-authenticators" + + "/SVdBS2VyYmVyb3NBdXRoZW50aWNhdG9y", context.getContextTenant().getDomain()))) .body("find{ it.authenticatorId == 'U0FNTFNTT0F1dGhlbnRpY2F0b3I' }.name", equalTo ("SAMLSSOAuthenticator")) - .body("find{ it.authenticatorId == 'U0FNTFNTT0F1dGhlbnRpY2F0b3I' }.self", equalTo("/t/" + context - .getContextTenant().getDomain() + - "/api/server/v1/identity-providers/meta/federated-authenticators/U0FNTFNTT0F1dGhlbnRpY2F0b3I")) + .body("find{ it.authenticatorId == 'U0FNTFNTT0F1dGhlbnRpY2F0b3I' }.self", equalTo( + getTenantedRelativePath( + "/api/server/v1/identity-providers/meta/federated-authenticators/U0FNTFNTT0F1dGhlbnRpY2F0b3I", + context.getContextTenant().getDomain()))) .body("find{ it.authenticatorId == 'T3BlbklEQ29ubmVjdEF1dGhlbnRpY2F0b3I' }.name", equalTo ("OpenIDConnectAuthenticator")) - .body("find{ it.authenticatorId == 'T3BlbklEQ29ubmVjdEF1dGhlbnRpY2F0b3I' }.self", equalTo("/t/" + - context.getContextTenant().getDomain() + - "/api/server/v1/identity-providers/meta/federated-authenticators" + - "/T3BlbklEQ29ubmVjdEF1dGhlbnRpY2F0b3I")) + .body("find{ it.authenticatorId == 'T3BlbklEQ29ubmVjdEF1dGhlbnRpY2F0b3I' }.self", equalTo( + getTenantedRelativePath( + "/api/server/v1/identity-providers/meta/federated-authenticators" + + "/T3BlbklEQ29ubmVjdEF1dGhlbnRpY2F0b3I", context.getContextTenant().getDomain()))) .body("find{ it.authenticatorId == 'RW1haWxPVFA' }.name", equalTo("EmailOTP")) - .body("find{ it.authenticatorId == 'RW1haWxPVFA' }.self", equalTo("/t/" + context.getContextTenant - ().getDomain() + - "/api/server/v1/identity-providers/meta/federated-authenticators/RW1haWxPVFA")) + .body("find{ it.authenticatorId == 'RW1haWxPVFA' }.self", equalTo( + getTenantedRelativePath( + "/api/server/v1/identity-providers/meta/federated-authenticators/RW1haWxPVFA", + context.getContextTenant().getDomain()))) .body("find{ it.authenticatorId == 'U01TT1RQ' }.name", equalTo("SMSOTP")) - .body("find{ it.authenticatorId == 'U01TT1RQ' }.self", equalTo("/t/" + context.getContextTenant() - .getDomain() + "/api/server/v1/identity-providers/meta/federated-authenticators/U01TT1RQ")); + .body("find{ it.authenticatorId == 'U01TT1RQ' }.self", equalTo( + getTenantedRelativePath( + "/api/server/v1/identity-providers/meta/federated-authenticators/U01TT1RQ", + context.getContextTenant().getDomain()))); } @Test(dependsOnMethods = {"testListMetaFederatedAuthenticators"}) @@ -224,20 +225,19 @@ public void testListMetaOutboundConnectors() throws Exception { .assertThat() .statusCode(HttpStatus.SC_OK) .body("find{ it.connectorId == 'Z29vZ2xlYXBwcw' }.name", equalTo("googleapps")) - .body("find{ it.connectorId == 'Z29vZ2xlYXBwcw' }.self", equalTo("/t/" + context.getContextTenant() - .getDomain() + - "/api/server/v1/identity-providers/meta/outbound-provisioning-connectors" + - "/Z29vZ2xlYXBwcw")) + .body("find{ it.connectorId == 'Z29vZ2xlYXBwcw' }.self", equalTo( + getTenantedRelativePath( + "/api/server/v1/identity-providers/meta/outbound-provisioning-connectors" + + "/Z29vZ2xlYXBwcw", context.getContextTenant().getDomain()))) .body("find{ it.connectorId == 'c2FsZXNmb3JjZQ' }.name", equalTo("salesforce")) - .body("find{ it.connectorId == 'c2FsZXNmb3JjZQ' }.self", equalTo("/t/" + context.getContextTenant() - .getDomain() + - "/api/server/v1/identity-providers/meta/outbound-provisioning-connectors" + - "/c2FsZXNmb3JjZQ")) + .body("find{ it.connectorId == 'c2FsZXNmb3JjZQ' }.self", equalTo( + getTenantedRelativePath( + "/api/server/v1/identity-providers/meta/outbound-provisioning-connectors" + + "/c2FsZXNmb3JjZQ", context.getContextTenant().getDomain()))) .body("find{ it.connectorId == 'c2NpbQ' }.name", equalTo("scim")) - .body("find{ it.connectorId == 'c2NpbQ' }.self", equalTo("/t/" + context.getContextTenant() - .getDomain() + - "/api/server/v1/identity-providers/meta/outbound-provisioning-connectors" + - "/c2NpbQ")); + .body("find{ it.connectorId == 'c2NpbQ' }.self", equalTo(getTenantedRelativePath( + "/api/server/v1/identity-providers/meta/outbound-provisioning-connectors" + + "/c2NpbQ", context.getContextTenant().getDomain()))); } @Test(dependsOnMethods = {"testListMetaOutboundConnectors"}) @@ -305,8 +305,9 @@ public void testGetIdPs() throws Exception { .body(baseIdentifier + "description", equalTo("IDP for Google Federation")) .body(baseIdentifier + "isEnabled", equalTo(true)) .body(baseIdentifier + "image", equalTo("google-logo-url")) - .body(baseIdentifier + "self", equalTo("/t/" + context.getContextTenant().getDomain() + - "/api/server/v1/identity-providers/" + idPId)); + .body(baseIdentifier + "self", equalTo(getTenantedRelativePath( + "/api/server/v1/identity-providers/" + idPId, + context.getContextTenant().getDomain()))); } @Test(dependsOnMethods = {"testGetIdPs"}) @@ -325,8 +326,9 @@ public void testGetIdPsWithRequiredAttribute() throws Exception { .body(baseIdentifier + "description", equalTo("IDP for Google Federation")) .body(baseIdentifier + "isEnabled", equalTo(true)) .body(baseIdentifier + "image", equalTo("google-logo-url")) - .body(baseIdentifier + "self", equalTo("/t/" + context.getContextTenant().getDomain() + - "/api/server/v1/identity-providers/" + idPId)) + .body(baseIdentifier + "self", equalTo(getTenantedRelativePath( + "/api/server/v1/identity-providers/" + idPId, + context.getContextTenant().getDomain()))) .body(baseIdentifier + "homeRealmIdentifier", equalTo("localhost")); } @@ -343,9 +345,9 @@ public void testGetIdPFederatedAuthenticators() throws Exception { .statusCode(HttpStatus.SC_OK) .body(baseIdentifier + "name", equalTo("GoogleOIDCAuthenticator")) .body(baseIdentifier + "isEnabled", equalTo(true)) - .body(baseIdentifier + "self", equalTo("/t/" + context.getContextTenant().getDomain() + + .body(baseIdentifier + "self", equalTo(getTenantedRelativePath( "/api/server/v1/identity-providers/" + idPId + "/federated-authenticators/" + - SAMPLE_FEDERATED_AUTHENTICATOR_ID)); + SAMPLE_FEDERATED_AUTHENTICATOR_ID, context.getContextTenant().getDomain()))); } @Test(dependsOnMethods = {"testGetIdPFederatedAuthenticators"}) @@ -396,9 +398,9 @@ public void testGetIdPOutboundConnectors() throws Exception { .statusCode(HttpStatus.SC_OK) .body(baseIdentifier + "name", equalTo("scim")) .body(baseIdentifier + "isEnabled", equalTo(true)) - .body(baseIdentifier + "self", equalTo("/t/" + context.getContextTenant().getDomain() + + .body(baseIdentifier + "self", equalTo(getTenantedRelativePath( "/api/server/v1/identity-providers/" + idPId + "/provisioning/outbound-connectors/" + - SAMPLE_OUTBOUND_CONNECTOR_ID)); + SAMPLE_OUTBOUND_CONNECTOR_ID, context.getContextTenant().getDomain()))); } @Test(dependsOnMethods = {"testGetIdPOutboundConnectors"}) @@ -634,8 +636,9 @@ public void testGetFilBasedIdpTemplates() throws Exception { .statusCode(HttpStatus.SC_OK) .body(baseIdentifier + "name", equalTo("Facebook")) .body(baseIdentifier + "category", equalTo("DEFAULT")) - .body(baseIdentifier + "self", equalTo("/t/" + context.getContextTenant().getDomain() + - "/api/server/v1/identity-providers/templates/" + fileBasedIdpTemplateId)) + .body(baseIdentifier + "self", equalTo(getTenantedRelativePath( + "/api/server/v1/identity-providers/templates/" + + fileBasedIdpTemplateId, context.getContextTenant().getDomain()))) .body("templates.size()", notNullValue()); } @@ -688,8 +691,9 @@ public void testGetIdPTemplates() throws Exception { .body(baseIdentifier + "category", equalTo("DEFAULT")) .body(baseIdentifier + "image", equalTo("google-logo-url")) .body(baseIdentifier + "displayOrder", equalTo(10)) - .body(baseIdentifier + "self", equalTo("/t/" + context.getContextTenant().getDomain() + - "/api/server/v1/identity-providers/templates/" + idPTemplateId)) + .body(baseIdentifier + "self", equalTo(getTenantedRelativePath( + "/api/server/v1/identity-providers/templates/" + + idPTemplateId, context.getContextTenant().getDomain()))) .body("templates.size()", notNullValue()); } @@ -707,8 +711,9 @@ public void testFilterIdPTemplates() throws Exception { .statusCode(HttpStatus.SC_OK) .body(baseIdentifier + "name", equalTo("Google")) .body(baseIdentifier + "category", equalTo("DEFAULT")) - .body(baseIdentifier + "self", equalTo("/t/" + context.getContextTenant().getDomain() + - "/api/server/v1/identity-providers/templates/" + idPTemplateId)); + .body(baseIdentifier + "self", equalTo(getTenantedRelativePath( + "/api/server/v1/identity-providers/templates/" + + idPTemplateId, context.getContextTenant().getDomain()))); } @Test(dependsOnMethods = {"testFilterIdPTemplates"}) diff --git a/modules/integration/tests-integration/tests-backend/src/test/java/org/wso2/identity/integration/test/rest/api/server/script/library/v1/ScriptLibrarySuccessTest.java b/modules/integration/tests-integration/tests-backend/src/test/java/org/wso2/identity/integration/test/rest/api/server/script/library/v1/ScriptLibrarySuccessTest.java index dc17d11c183..92da574c941 100644 --- a/modules/integration/tests-integration/tests-backend/src/test/java/org/wso2/identity/integration/test/rest/api/server/script/library/v1/ScriptLibrarySuccessTest.java +++ b/modules/integration/tests-integration/tests-backend/src/test/java/org/wso2/identity/integration/test/rest/api/server/script/library/v1/ScriptLibrarySuccessTest.java @@ -113,8 +113,10 @@ public void testAddScriptLibrary() throws IOException { @Test(dependsOnMethods = {"testAddScriptLibrary"}) public void testGetScriptLibrary() throws XPathExpressionException { - SCRIPT_LIBRARY_CONTENT_REF = "/t/" + context.getContextTenant() - .getDomain() + "/api/server/v1/script-libraries/" + SCRIPT_LIBRARY_NAME + SCRIPT_LIBRARY_CONTENT_PATH; + SCRIPT_LIBRARY_CONTENT_REF = getTenantedRelativePath( + "/api/server/v1/script-libraries/" + SCRIPT_LIBRARY_NAME + SCRIPT_LIBRARY_CONTENT_PATH, + context.getContextTenant().getDomain()); + Response response = getResponseOfGet(SCRIPT_LIBRARY_API_BASE_PATH + PATH_SEPARATOR + SCRIPT_LIBRARY_NAME); response.then() .log().ifValidationFails() @@ -138,8 +140,9 @@ public void testGetScriptLibraries() { @Test(dependsOnMethods = {"testGetScriptLibrary"}) public void testUpdateScriptLibrary() throws IOException, XPathExpressionException { - SCRIPT_LIBRARY_CONTENT_REF = "/t/" + context.getContextTenant() - .getDomain() + "/api/server/v1/script-libraries/" + SCRIPT_LIBRARY_NAME + SCRIPT_LIBRARY_CONTENT_PATH; + SCRIPT_LIBRARY_CONTENT_REF = getTenantedRelativePath( + "/api/server/v1/script-libraries/" + SCRIPT_LIBRARY_NAME + SCRIPT_LIBRARY_CONTENT_PATH, + context.getContextTenant().getDomain()); String content = readResource("sample-script-library-updated.js"); String endpoint = SCRIPT_LIBRARY_API_BASE_PATH + PATH_SEPARATOR + SCRIPT_LIBRARY_NAME; Response response = getResponseOfMultipartPut(endpoint, content, SCRIPT_LIBRARY_UPDATED_DESCRIPTION); diff --git a/modules/integration/tests-integration/tests-backend/src/test/java/org/wso2/identity/integration/test/rest/api/server/user/store/v1/UserStoreSuccessTest.java b/modules/integration/tests-integration/tests-backend/src/test/java/org/wso2/identity/integration/test/rest/api/server/user/store/v1/UserStoreSuccessTest.java index a17ab628284..f2783b66502 100644 --- a/modules/integration/tests-integration/tests-backend/src/test/java/org/wso2/identity/integration/test/rest/api/server/user/store/v1/UserStoreSuccessTest.java +++ b/modules/integration/tests-integration/tests-backend/src/test/java/org/wso2/identity/integration/test/rest/api/server/user/store/v1/UserStoreSuccessTest.java @@ -149,8 +149,8 @@ public void testGetAvailableUserStoreClasses() throws IOException { validatableResponse.body("find{ it.typeId == '" + resEntry.getKey() + "' }.className", equalTo(resEntry.getValue().getClassName())); validatableResponse.body("find{ it.typeId == '" + resEntry.getKey() + "' }.self", - equalTo("/t/" + tenant + "/api/server/v1" + USER_STORE_PATH_COMPONENT + - PATH_SEPARATOR + "meta/types/" + resEntry.getValue().getTypeId())); + equalTo(getTenantedRelativePath("/api/server/v1" + USER_STORE_PATH_COMPONENT + + PATH_SEPARATOR + "meta/types/" + resEntry.getValue().getTypeId(), tenant))); } } @@ -193,8 +193,8 @@ public void testGetUserStore() throws IOException { validatableResponse.body("find{ it.id == '" + resEntry.getKey() + "' }.description", equalTo(resEntry.getValue().getDescription())); validatableResponse.body("find{ it.id == '" + resEntry.getKey() + "' }.self", - equalTo("/t/" + tenant + "/api/server/v1" + USER_STORE_PATH_COMPONENT + - PATH_SEPARATOR + resEntry.getValue().getId())); + equalTo(getTenantedRelativePath("/api/server/v1" + + USER_STORE_PATH_COMPONENT + PATH_SEPARATOR + resEntry.getValue().getId(), tenant))); } } diff --git a/modules/integration/tests-integration/tests-backend/src/test/java/org/wso2/identity/integration/test/rest/api/user/application/v1/UserDiscoverableApplicationSuccessTest.java b/modules/integration/tests-integration/tests-backend/src/test/java/org/wso2/identity/integration/test/rest/api/user/application/v1/UserDiscoverableApplicationSuccessTest.java index 983017f6e93..3b63f2fdc30 100644 --- a/modules/integration/tests-integration/tests-backend/src/test/java/org/wso2/identity/integration/test/rest/api/user/application/v1/UserDiscoverableApplicationSuccessTest.java +++ b/modules/integration/tests-integration/tests-backend/src/test/java/org/wso2/identity/integration/test/rest/api/user/application/v1/UserDiscoverableApplicationSuccessTest.java @@ -33,6 +33,7 @@ import java.util.Map; import java.util.stream.IntStream; +import javax.xml.xpath.XPathExpressionException; import static org.hamcrest.CoreMatchers.equalTo; import static org.hamcrest.CoreMatchers.not; import static org.hamcrest.Matchers.hasItem; @@ -100,7 +101,7 @@ public void testListAllApplications() { } @Test(description = "Test listing applications with offset and limit.", dataProvider = "offsetLimitProvider") - public void testListApplicationsWithOffsetLimit(int offset, int limit) { + public void testListApplicationsWithOffsetLimit(int offset, int limit) throws Exception { Map params = new HashMap() {{ put("offset", offset); @@ -307,27 +308,28 @@ private void assertForAllApplications(Response response) { .body("applications.find{ it.id == '" + serviceProvider.getApplicationResourceId() + "'}.image", equalTo(serviceProvider.getImageUrl())) .body("applications.find{ it.id == '" + serviceProvider.getApplicationResourceId() + "'}" + - ".accessUrl", equalTo(serviceProvider.getAccessUrl())) + ".accessUrl", equalTo(serviceProvider.getAccessUrl())) .body("applications.find{ it.id == '" + serviceProvider.getApplicationResourceId() + "'}" + ".description", equalTo(serviceProvider.getDescription())); }); } - private void assertNextLink(int offset, int limit, Response response) { + private void assertNextLink(int offset, int limit, Response response) throws XPathExpressionException { if ((offset + limit) < TOTAL_DISCOVERABLE_APP_COUNT) { response.then().log().ifValidationFails().body("links.rel", hasItem("next")); response.then().log().ifValidationFails().body("links.find { it.rel == 'next'}.href", equalTo - (String.format(RestAssured.basePath + USER_APPLICATION_ENDPOINT_URI + + (String.format(getTenantedRelativePath("/api/users/v1" + + USER_APPLICATION_ENDPOINT_URI, context.getContextTenant().getDomain()) + PAGINATION_LINK_QUERY_PARAM_STRING, (offset + limit), limit))); } else { response.then().log().ifValidationFails().body("links", not(hasItem("next"))); } } - private void assertPreviousLink(int offset, int limit, Response response) { + private void assertPreviousLink(int offset, int limit, Response response) throws XPathExpressionException { if (offset > 0) { // Previous link exists only if offset is greater than 0. int expectedOffsetQueryParam; @@ -342,7 +344,8 @@ private void assertPreviousLink(int offset, int limit, Response response) { } response.then().log().ifValidationFails().body("links.find { it.rel == 'previous'}.href", equalTo - (String.format(RestAssured.basePath + USER_APPLICATION_ENDPOINT_URI + + (String.format(getTenantedRelativePath("/api/users/v1" + + USER_APPLICATION_ENDPOINT_URI, context.getContextTenant().getDomain()) + PAGINATION_LINK_QUERY_PARAM_STRING, expectedOffsetQueryParam, expectedLimitQueryParam))); } else if (offset == 0) { diff --git a/modules/integration/tests-integration/tests-backend/src/test/java/org/wso2/identity/integration/test/rest/api/user/authorized/apps/v1/UserAuthorizedAppsBaseTest.java b/modules/integration/tests-integration/tests-backend/src/test/java/org/wso2/identity/integration/test/rest/api/user/authorized/apps/v1/UserAuthorizedAppsBaseTest.java index f1207cc74fd..882c6102c5c 100644 --- a/modules/integration/tests-integration/tests-backend/src/test/java/org/wso2/identity/integration/test/rest/api/user/authorized/apps/v1/UserAuthorizedAppsBaseTest.java +++ b/modules/integration/tests-integration/tests-backend/src/test/java/org/wso2/identity/integration/test/rest/api/user/authorized/apps/v1/UserAuthorizedAppsBaseTest.java @@ -59,7 +59,7 @@ void initUrls(String pathParam) { this.userAuthorizedAppsEndpointUri = String.format(AUTHORIZED_APPS_ENDPOINT_URI, pathParam); this.dcrEndpointUri = String.format(DCR_ENDPOINT_PATH_URI, tenant); - this.tokenEndpointUri = "/oauth2/token"; + this.tokenEndpointUri = getTenantedRelativePath("/oauth2/token", tenant); } public void registerApplication(String appName, String clientId, String clientSecret) { diff --git a/modules/integration/tests-integration/tests-backend/src/test/java/org/wso2/identity/integration/test/rest/api/user/authorized/apps/v2/UserAuthorizedAppsBaseTest.java b/modules/integration/tests-integration/tests-backend/src/test/java/org/wso2/identity/integration/test/rest/api/user/authorized/apps/v2/UserAuthorizedAppsBaseTest.java index 06c64cf1f5c..054864ff691 100644 --- a/modules/integration/tests-integration/tests-backend/src/test/java/org/wso2/identity/integration/test/rest/api/user/authorized/apps/v2/UserAuthorizedAppsBaseTest.java +++ b/modules/integration/tests-integration/tests-backend/src/test/java/org/wso2/identity/integration/test/rest/api/user/authorized/apps/v2/UserAuthorizedAppsBaseTest.java @@ -65,7 +65,7 @@ void initUrls(String pathParam) { this.userAuthorizedAppsEndpointUri = String.format(AUTHORIZED_APPS_ENDPOINT_URI, pathParam); this.userApplicationEndpointUri = APPLICATION_ENDPOINT_URI; this.dcrEndpointUri = String.format(DCR_ENDPOINT_PATH_URI, tenant); - this.tokenEndpointUri = "/oauth2/token"; + this.tokenEndpointUri = getTenantedRelativePath("/oauth2/token", tenant); } public void registerApplication(String appName, String clientId, String clientSecret) { From 597906d40667362d7552506a2d8ee95809e01ddf Mon Sep 17 00:00:00 2001 From: Thisara-Welmilla Date: Sun, 1 Oct 2023 17:51:38 +0530 Subject: [PATCH 08/16] Fix failed integration tests --- .../apps/v2/ApplicationAuthorizedAppsSuccessTest.java | 2 +- .../user/authorized/apps/v2/MeAuthorizedAppsSuccessTest.java | 2 +- .../rest/api/user/session/v1/UserSessionAdminSuccessTest.java | 2 +- .../test/rest/api/user/session/v1/UserSessionMeSuccessTest.java | 2 +- 4 files changed, 4 insertions(+), 4 deletions(-) diff --git a/modules/integration/tests-integration/tests-backend/src/test/java/org/wso2/identity/integration/test/rest/api/user/authorized/apps/v2/ApplicationAuthorizedAppsSuccessTest.java b/modules/integration/tests-integration/tests-backend/src/test/java/org/wso2/identity/integration/test/rest/api/user/authorized/apps/v2/ApplicationAuthorizedAppsSuccessTest.java index 5d5fad4963a..c463fa5c771 100644 --- a/modules/integration/tests-integration/tests-backend/src/test/java/org/wso2/identity/integration/test/rest/api/user/authorized/apps/v2/ApplicationAuthorizedAppsSuccessTest.java +++ b/modules/integration/tests-integration/tests-backend/src/test/java/org/wso2/identity/integration/test/rest/api/user/authorized/apps/v2/ApplicationAuthorizedAppsSuccessTest.java @@ -86,7 +86,7 @@ public ApplicationAuthorizedAppsSuccessTest(TestUserMode userMode) throws Except super.init(userMode); this.context = isServer; - this.authenticatingUserName = context.getContextTenant().getTenantAdmin().getUserName(); + this.authenticatingUserName = context.getContextTenant().getTenantAdmin().getUserNameWithoutDomain(); this.authenticatingCredential = context.getContextTenant().getTenantAdmin().getPassword(); this.tenant = context.getContextTenant().getDomain(); diff --git a/modules/integration/tests-integration/tests-backend/src/test/java/org/wso2/identity/integration/test/rest/api/user/authorized/apps/v2/MeAuthorizedAppsSuccessTest.java b/modules/integration/tests-integration/tests-backend/src/test/java/org/wso2/identity/integration/test/rest/api/user/authorized/apps/v2/MeAuthorizedAppsSuccessTest.java index 216b6ae14bb..7f7c93d7cb1 100644 --- a/modules/integration/tests-integration/tests-backend/src/test/java/org/wso2/identity/integration/test/rest/api/user/authorized/apps/v2/MeAuthorizedAppsSuccessTest.java +++ b/modules/integration/tests-integration/tests-backend/src/test/java/org/wso2/identity/integration/test/rest/api/user/authorized/apps/v2/MeAuthorizedAppsSuccessTest.java @@ -90,7 +90,7 @@ public MeAuthorizedAppsSuccessTest(TestUserMode userMode) throws Exception { super.init(userMode); this.context = isServer; - this.authenticatingUserName = context.getContextTenant().getTenantAdmin().getUserName(); + this.authenticatingUserName = context.getContextTenant().getTenantAdmin().getUserNameWithoutDomain(); this.authenticatingCredential = context.getContextTenant().getTenantAdmin().getPassword(); this.tenant = context.getContextTenant().getDomain(); diff --git a/modules/integration/tests-integration/tests-backend/src/test/java/org/wso2/identity/integration/test/rest/api/user/session/v1/UserSessionAdminSuccessTest.java b/modules/integration/tests-integration/tests-backend/src/test/java/org/wso2/identity/integration/test/rest/api/user/session/v1/UserSessionAdminSuccessTest.java index 62e16c1d6b3..719eea00c83 100644 --- a/modules/integration/tests-integration/tests-backend/src/test/java/org/wso2/identity/integration/test/rest/api/user/session/v1/UserSessionAdminSuccessTest.java +++ b/modules/integration/tests-integration/tests-backend/src/test/java/org/wso2/identity/integration/test/rest/api/user/session/v1/UserSessionAdminSuccessTest.java @@ -187,7 +187,7 @@ public void testGetSessionsWithPagination() { private void authenticateUser(String user) { - this.authenticatingUserName = user + "@" + tenant; + this.authenticatingUserName = user; this.authenticatingCredential = TEST_USER_PASSWORD; } diff --git a/modules/integration/tests-integration/tests-backend/src/test/java/org/wso2/identity/integration/test/rest/api/user/session/v1/UserSessionMeSuccessTest.java b/modules/integration/tests-integration/tests-backend/src/test/java/org/wso2/identity/integration/test/rest/api/user/session/v1/UserSessionMeSuccessTest.java index 0cee95315ad..f7cdcb4b672 100644 --- a/modules/integration/tests-integration/tests-backend/src/test/java/org/wso2/identity/integration/test/rest/api/user/session/v1/UserSessionMeSuccessTest.java +++ b/modules/integration/tests-integration/tests-backend/src/test/java/org/wso2/identity/integration/test/rest/api/user/session/v1/UserSessionMeSuccessTest.java @@ -52,7 +52,7 @@ public UserSessionMeSuccessTest(TestUserMode userMode, String username1, String this.tenant = context.getContextTenant().getDomain(); this.session_test_user1 = username1; this.session_test_user2 = username2; - this.authenticatingUserName = session_test_user1 + "@" + tenant; + this.authenticatingUserName = session_test_user1; this.authenticatingCredential = TEST_USER_PASSWORD; } From eb38b1278f93c6bd6605c42abf91f67050deee37 Mon Sep 17 00:00:00 2001 From: Thisara-Welmilla Date: Mon, 16 Oct 2023 06:07:12 +0530 Subject: [PATCH 09/16] Fix failing rest api integration test --- .../common/utils/ISIntegrationTest.java | 2 +- .../v1/EmailTemplatesPositiveTest.java | 5 +- .../v1/IdentityGovernanceSuccessTest.java | 4 +- .../api/server/idp/v1/IdPSuccessTest.java | 133 +++++++++--------- .../library/v1/ScriptLibrarySuccessTest.java | 11 +- .../user/store/v1/UserStoreSuccessTest.java | 8 +- ...serDiscoverableApplicationSuccessTest.java | 15 +- .../apps/v1/UserAuthorizedAppsBaseTest.java | 2 +- .../apps/v2/UserAuthorizedAppsBaseTest.java | 2 +- 9 files changed, 97 insertions(+), 85 deletions(-) diff --git a/modules/integration/tests-common/integration-test-utils/src/main/java/org/wso2/identity/integration/common/utils/ISIntegrationTest.java b/modules/integration/tests-common/integration-test-utils/src/main/java/org/wso2/identity/integration/common/utils/ISIntegrationTest.java index 02ca8a12146..d6bae817266 100644 --- a/modules/integration/tests-common/integration-test-utils/src/main/java/org/wso2/identity/integration/common/utils/ISIntegrationTest.java +++ b/modules/integration/tests-common/integration-test-utils/src/main/java/org/wso2/identity/integration/common/utils/ISIntegrationTest.java @@ -179,7 +179,7 @@ public String getTenantQualifiedURL(String endpointURL, String tenantDomain) { * @param tenantDomain Tenanted domain. * @return Tenant qualified URL without hostname. */ - public String getTenantQualifiedURLWithoutHostName(String endpointURLWithHostname, String tenantDomain) { + public String getTenantedRelativePath(String endpointURLWithHostname, String tenantDomain) { if(!tenantDomain.isBlank() && !tenantDomain.equalsIgnoreCase(MultitenantConstants.SUPER_TENANT_DOMAIN_NAME)) { endpointURLWithHostname = TENANTED_URL_PATH_SPECIFIER + tenantDomain + endpointURLWithHostname; diff --git a/modules/integration/tests-integration/tests-backend/src/test/java/org/wso2/identity/integration/test/rest/api/server/email/template/v1/EmailTemplatesPositiveTest.java b/modules/integration/tests-integration/tests-backend/src/test/java/org/wso2/identity/integration/test/rest/api/server/email/template/v1/EmailTemplatesPositiveTest.java index f53b5883f59..85daaf70b46 100644 --- a/modules/integration/tests-integration/tests-backend/src/test/java/org/wso2/identity/integration/test/rest/api/server/email/template/v1/EmailTemplatesPositiveTest.java +++ b/modules/integration/tests-integration/tests-backend/src/test/java/org/wso2/identity/integration/test/rest/api/server/email/template/v1/EmailTemplatesPositiveTest.java @@ -135,8 +135,9 @@ public void testGetAllEmailTemplateTypes() throws Exception { .assertThat() .statusCode(HttpStatus.SC_OK) .body(baseIdentifier + "displayName", equalTo("AccountConfirmation")) - .body(baseIdentifier + "self", equalTo("/t/" + context.getContextTenant().getDomain() + - "/api/server/v1/email/template-types/QWNjb3VudENvbmZpcm1hdGlvbg")); + .body(baseIdentifier + "self", equalTo(getTenantedRelativePath( + "/api/server/v1/email/template-types/QWNjb3VudENvbmZpcm1hdGlvbg", + context.getContextTenant().getDomain()))); } // Get all email template types with required attributes. diff --git a/modules/integration/tests-integration/tests-backend/src/test/java/org/wso2/identity/integration/test/rest/api/server/identity/governance/v1/IdentityGovernanceSuccessTest.java b/modules/integration/tests-integration/tests-backend/src/test/java/org/wso2/identity/integration/test/rest/api/server/identity/governance/v1/IdentityGovernanceSuccessTest.java index fa4cfc51a5d..1ac773f9e9a 100644 --- a/modules/integration/tests-integration/tests-backend/src/test/java/org/wso2/identity/integration/test/rest/api/server/identity/governance/v1/IdentityGovernanceSuccessTest.java +++ b/modules/integration/tests-integration/tests-backend/src/test/java/org/wso2/identity/integration/test/rest/api/server/identity/governance/v1/IdentityGovernanceSuccessTest.java @@ -142,8 +142,8 @@ public void testGetGovernanceConnectors() { equalTo(category.getValue().getName())); validatableResponse.body("find{ it.id == '" + category.getKey() + "' }.self", - equalTo("/t/" + tenant + "/api/server/v1" + IDENTITY_GOVERNANCE_ENDPOINT_URI + "/" + - category.getValue().getId())); + equalTo(getTenantedRelativePath("/api/server/v1" + + IDENTITY_GOVERNANCE_ENDPOINT_URI + "/" + category.getValue().getId(), tenant))); } } diff --git a/modules/integration/tests-integration/tests-backend/src/test/java/org/wso2/identity/integration/test/rest/api/server/idp/v1/IdPSuccessTest.java b/modules/integration/tests-integration/tests-backend/src/test/java/org/wso2/identity/integration/test/rest/api/server/idp/v1/IdPSuccessTest.java index d3b4b0cb20d..9f624c128d5 100644 --- a/modules/integration/tests-integration/tests-backend/src/test/java/org/wso2/identity/integration/test/rest/api/server/idp/v1/IdPSuccessTest.java +++ b/modules/integration/tests-integration/tests-backend/src/test/java/org/wso2/identity/integration/test/rest/api/server/idp/v1/IdPSuccessTest.java @@ -100,64 +100,65 @@ public void testListMetaFederatedAuthenticators() throws Exception { .statusCode(HttpStatus.SC_OK) .body("find{ it.authenticatorId == 'T2ZmaWNlMzY1QXV0aGVudGljYXRvcg' }.name", equalTo ("Office365Authenticator")) - .body("find{ it.authenticatorId == 'T2ZmaWNlMzY1QXV0aGVudGljYXRvcg' }.self", equalTo("/t/" + - context.getContextTenant().getDomain() + - "/api/server/v1/identity-providers/meta/federated-authenticators" + - "/T2ZmaWNlMzY1QXV0aGVudGljYXRvcg")) + .body("find{ it.authenticatorId == 'T2ZmaWNlMzY1QXV0aGVudGljYXRvcg' }.self", equalTo( + getTenantedRelativePath("/api/server/v1/identity-providers/meta/federated-authenticators" + + "/T2ZmaWNlMzY1QXV0aGVudGljYXRvcg", context.getContextTenant().getDomain()))) .body("find{ it.authenticatorId == 'VHdpdHRlckF1dGhlbnRpY2F0b3I' }.name", equalTo ("TwitterAuthenticator")) - .body("find{ it.authenticatorId == 'VHdpdHRlckF1dGhlbnRpY2F0b3I' }.self", equalTo("/t/" + context - .getContextTenant().getDomain() + - "/api/server/v1/identity-providers/meta/federated-authenticators" + - "/VHdpdHRlckF1dGhlbnRpY2F0b3I")) + .body("find{ it.authenticatorId == 'VHdpdHRlckF1dGhlbnRpY2F0b3I' }.self", equalTo( + getTenantedRelativePath( + "/api/server/v1/identity-providers/meta/federated-authenticators" + + "/VHdpdHRlckF1dGhlbnRpY2F0b3I", context.getContextTenant().getDomain()))) .body("find{ it.authenticatorId == 'RmFjZWJvb2tBdXRoZW50aWNhdG9y' }.name", equalTo ("FacebookAuthenticator")) - .body("find{ it.authenticatorId == 'RmFjZWJvb2tBdXRoZW50aWNhdG9y' }.self", equalTo("/t/" + context - .getContextTenant().getDomain() + - "/api/server/v1/identity-providers/meta/federated-authenticators" + - "/RmFjZWJvb2tBdXRoZW50aWNhdG9y")) + .body("find{ it.authenticatorId == 'RmFjZWJvb2tBdXRoZW50aWNhdG9y' }.self", equalTo( + getTenantedRelativePath("/api/server/v1/identity-providers/meta/federated-authenticators" + + "/RmFjZWJvb2tBdXRoZW50aWNhdG9y", context.getContextTenant().getDomain()))) .body("find{ it.authenticatorId == 'R29vZ2xlT0lEQ0F1dGhlbnRpY2F0b3I' }.name", equalTo ("GoogleOIDCAuthenticator")) - .body("find{ it.authenticatorId == 'R29vZ2xlT0lEQ0F1dGhlbnRpY2F0b3I' }.self", equalTo("/t/" + - context.getContextTenant().getDomain() + - "/api/server/v1/identity-providers/meta/federated-authenticators" + - "/R29vZ2xlT0lEQ0F1dGhlbnRpY2F0b3I")) + .body("find{ it.authenticatorId == 'R29vZ2xlT0lEQ0F1dGhlbnRpY2F0b3I' }.self", equalTo( + getTenantedRelativePath("/api/server/v1/identity-providers/meta/federated-authenticators" + + "/R29vZ2xlT0lEQ0F1dGhlbnRpY2F0b3I", context.getContextTenant().getDomain()))) .body("find{ it.authenticatorId == 'TWljcm9zb2Z0V2luZG93c0xpdmVBdXRoZW50aWNhdG9y' }.name", equalTo ("MicrosoftWindowsLiveAuthenticator")) .body("find{ it.authenticatorId == 'TWljcm9zb2Z0V2luZG93c0xpdmVBdXRoZW50aWNhdG9y' }.self", equalTo - ("/t/" + context.getContextTenant().getDomain() + + (getTenantedRelativePath( "/api/server/v1/identity-providers/meta/federated-authenticators" + - "/TWljcm9zb2Z0V2luZG93c0xpdmVBdXRoZW50aWNhdG9y")) + "/TWljcm9zb2Z0V2luZG93c0xpdmVBdXRoZW50aWNhdG9y", context.getContextTenant().getDomain()))) .body("find{ it.authenticatorId == 'UGFzc2l2ZVNUU0F1dGhlbnRpY2F0b3I' }.name", equalTo ("PassiveSTSAuthenticator")) - .body("find{ it.authenticatorId == 'UGFzc2l2ZVNUU0F1dGhlbnRpY2F0b3I' }.self", equalTo("/t/" + - context.getContextTenant().getDomain() + - "/api/server/v1/identity-providers/meta/federated-authenticators" + - "/UGFzc2l2ZVNUU0F1dGhlbnRpY2F0b3I")) + .body("find{ it.authenticatorId == 'UGFzc2l2ZVNUU0F1dGhlbnRpY2F0b3I' }.self", equalTo( + getTenantedRelativePath( + "/api/server/v1/identity-providers/meta/federated-authenticators" + + "/UGFzc2l2ZVNUU0F1dGhlbnRpY2F0b3I", context.getContextTenant().getDomain()))) .body("find{ it.authenticatorId == 'SVdBS2VyYmVyb3NBdXRoZW50aWNhdG9y' }.name", equalTo ("IWAKerberosAuthenticator")) - .body("find{ it.authenticatorId == 'SVdBS2VyYmVyb3NBdXRoZW50aWNhdG9y' }.self", equalTo("/t/" + - context.getContextTenant().getDomain() + - "/api/server/v1/identity-providers/meta/federated-authenticators" + - "/SVdBS2VyYmVyb3NBdXRoZW50aWNhdG9y")) + .body("find{ it.authenticatorId == 'SVdBS2VyYmVyb3NBdXRoZW50aWNhdG9y' }.self", equalTo( + getTenantedRelativePath( + "/api/server/v1/identity-providers/meta/federated-authenticators" + + "/SVdBS2VyYmVyb3NBdXRoZW50aWNhdG9y", context.getContextTenant().getDomain()))) .body("find{ it.authenticatorId == 'U0FNTFNTT0F1dGhlbnRpY2F0b3I' }.name", equalTo ("SAMLSSOAuthenticator")) - .body("find{ it.authenticatorId == 'U0FNTFNTT0F1dGhlbnRpY2F0b3I' }.self", equalTo("/t/" + context - .getContextTenant().getDomain() + - "/api/server/v1/identity-providers/meta/federated-authenticators/U0FNTFNTT0F1dGhlbnRpY2F0b3I")) + .body("find{ it.authenticatorId == 'U0FNTFNTT0F1dGhlbnRpY2F0b3I' }.self", equalTo( + getTenantedRelativePath( + "/api/server/v1/identity-providers/meta/federated-authenticators/U0FNTFNTT0F1dGhlbnRpY2F0b3I", + context.getContextTenant().getDomain()))) .body("find{ it.authenticatorId == 'T3BlbklEQ29ubmVjdEF1dGhlbnRpY2F0b3I' }.name", equalTo ("OpenIDConnectAuthenticator")) - .body("find{ it.authenticatorId == 'T3BlbklEQ29ubmVjdEF1dGhlbnRpY2F0b3I' }.self", equalTo("/t/" + - context.getContextTenant().getDomain() + - "/api/server/v1/identity-providers/meta/federated-authenticators" + - "/T3BlbklEQ29ubmVjdEF1dGhlbnRpY2F0b3I")) + .body("find{ it.authenticatorId == 'T3BlbklEQ29ubmVjdEF1dGhlbnRpY2F0b3I' }.self", equalTo( + getTenantedRelativePath( + "/api/server/v1/identity-providers/meta/federated-authenticators" + + "/T3BlbklEQ29ubmVjdEF1dGhlbnRpY2F0b3I", context.getContextTenant().getDomain()))) .body("find{ it.authenticatorId == 'RW1haWxPVFA' }.name", equalTo("EmailOTP")) - .body("find{ it.authenticatorId == 'RW1haWxPVFA' }.self", equalTo("/t/" + context.getContextTenant - ().getDomain() + - "/api/server/v1/identity-providers/meta/federated-authenticators/RW1haWxPVFA")) + .body("find{ it.authenticatorId == 'RW1haWxPVFA' }.self", equalTo( + getTenantedRelativePath( + "/api/server/v1/identity-providers/meta/federated-authenticators/RW1haWxPVFA", + context.getContextTenant().getDomain()))) .body("find{ it.authenticatorId == 'U01TT1RQ' }.name", equalTo("SMSOTP")) - .body("find{ it.authenticatorId == 'U01TT1RQ' }.self", equalTo("/t/" + context.getContextTenant() - .getDomain() + "/api/server/v1/identity-providers/meta/federated-authenticators/U01TT1RQ")); + .body("find{ it.authenticatorId == 'U01TT1RQ' }.self", equalTo( + getTenantedRelativePath( + "/api/server/v1/identity-providers/meta/federated-authenticators/U01TT1RQ", + context.getContextTenant().getDomain()))); } @Test(dependsOnMethods = {"testListMetaFederatedAuthenticators"}) @@ -224,20 +225,19 @@ public void testListMetaOutboundConnectors() throws Exception { .assertThat() .statusCode(HttpStatus.SC_OK) .body("find{ it.connectorId == 'Z29vZ2xlYXBwcw' }.name", equalTo("googleapps")) - .body("find{ it.connectorId == 'Z29vZ2xlYXBwcw' }.self", equalTo("/t/" + context.getContextTenant() - .getDomain() + - "/api/server/v1/identity-providers/meta/outbound-provisioning-connectors" + - "/Z29vZ2xlYXBwcw")) + .body("find{ it.connectorId == 'Z29vZ2xlYXBwcw' }.self", equalTo( + getTenantedRelativePath( + "/api/server/v1/identity-providers/meta/outbound-provisioning-connectors" + + "/Z29vZ2xlYXBwcw", context.getContextTenant().getDomain()))) .body("find{ it.connectorId == 'c2FsZXNmb3JjZQ' }.name", equalTo("salesforce")) - .body("find{ it.connectorId == 'c2FsZXNmb3JjZQ' }.self", equalTo("/t/" + context.getContextTenant() - .getDomain() + - "/api/server/v1/identity-providers/meta/outbound-provisioning-connectors" + - "/c2FsZXNmb3JjZQ")) + .body("find{ it.connectorId == 'c2FsZXNmb3JjZQ' }.self", equalTo( + getTenantedRelativePath( + "/api/server/v1/identity-providers/meta/outbound-provisioning-connectors" + + "/c2FsZXNmb3JjZQ", context.getContextTenant().getDomain()))) .body("find{ it.connectorId == 'c2NpbQ' }.name", equalTo("scim")) - .body("find{ it.connectorId == 'c2NpbQ' }.self", equalTo("/t/" + context.getContextTenant() - .getDomain() + - "/api/server/v1/identity-providers/meta/outbound-provisioning-connectors" + - "/c2NpbQ")); + .body("find{ it.connectorId == 'c2NpbQ' }.self", equalTo(getTenantedRelativePath( + "/api/server/v1/identity-providers/meta/outbound-provisioning-connectors" + + "/c2NpbQ", context.getContextTenant().getDomain()))); } @Test(dependsOnMethods = {"testListMetaOutboundConnectors"}) @@ -305,8 +305,9 @@ public void testGetIdPs() throws Exception { .body(baseIdentifier + "description", equalTo("IDP for Google Federation")) .body(baseIdentifier + "isEnabled", equalTo(true)) .body(baseIdentifier + "image", equalTo("google-logo-url")) - .body(baseIdentifier + "self", equalTo("/t/" + context.getContextTenant().getDomain() + - "/api/server/v1/identity-providers/" + idPId)); + .body(baseIdentifier + "self", equalTo(getTenantedRelativePath( + "/api/server/v1/identity-providers/" + idPId, + context.getContextTenant().getDomain()))); } @Test(dependsOnMethods = {"testGetIdPs"}) @@ -325,8 +326,9 @@ public void testGetIdPsWithRequiredAttribute() throws Exception { .body(baseIdentifier + "description", equalTo("IDP for Google Federation")) .body(baseIdentifier + "isEnabled", equalTo(true)) .body(baseIdentifier + "image", equalTo("google-logo-url")) - .body(baseIdentifier + "self", equalTo("/t/" + context.getContextTenant().getDomain() + - "/api/server/v1/identity-providers/" + idPId)) + .body(baseIdentifier + "self", equalTo(getTenantedRelativePath( + "/api/server/v1/identity-providers/" + idPId, + context.getContextTenant().getDomain()))) .body(baseIdentifier + "homeRealmIdentifier", equalTo("localhost")); } @@ -343,9 +345,9 @@ public void testGetIdPFederatedAuthenticators() throws Exception { .statusCode(HttpStatus.SC_OK) .body(baseIdentifier + "name", equalTo("GoogleOIDCAuthenticator")) .body(baseIdentifier + "isEnabled", equalTo(true)) - .body(baseIdentifier + "self", equalTo("/t/" + context.getContextTenant().getDomain() + + .body(baseIdentifier + "self", equalTo(getTenantedRelativePath( "/api/server/v1/identity-providers/" + idPId + "/federated-authenticators/" + - SAMPLE_FEDERATED_AUTHENTICATOR_ID)); + SAMPLE_FEDERATED_AUTHENTICATOR_ID, context.getContextTenant().getDomain()))); } @Test(dependsOnMethods = {"testGetIdPFederatedAuthenticators"}) @@ -396,9 +398,9 @@ public void testGetIdPOutboundConnectors() throws Exception { .statusCode(HttpStatus.SC_OK) .body(baseIdentifier + "name", equalTo("scim")) .body(baseIdentifier + "isEnabled", equalTo(true)) - .body(baseIdentifier + "self", equalTo("/t/" + context.getContextTenant().getDomain() + + .body(baseIdentifier + "self", equalTo(getTenantedRelativePath( "/api/server/v1/identity-providers/" + idPId + "/provisioning/outbound-connectors/" + - SAMPLE_OUTBOUND_CONNECTOR_ID)); + SAMPLE_OUTBOUND_CONNECTOR_ID, context.getContextTenant().getDomain()))); } @Test(dependsOnMethods = {"testGetIdPOutboundConnectors"}) @@ -634,8 +636,9 @@ public void testGetFilBasedIdpTemplates() throws Exception { .statusCode(HttpStatus.SC_OK) .body(baseIdentifier + "name", equalTo("Facebook")) .body(baseIdentifier + "category", equalTo("DEFAULT")) - .body(baseIdentifier + "self", equalTo("/t/" + context.getContextTenant().getDomain() + - "/api/server/v1/identity-providers/templates/" + fileBasedIdpTemplateId)) + .body(baseIdentifier + "self", equalTo(getTenantedRelativePath( + "/api/server/v1/identity-providers/templates/" + + fileBasedIdpTemplateId, context.getContextTenant().getDomain()))) .body("templates.size()", notNullValue()); } @@ -688,8 +691,9 @@ public void testGetIdPTemplates() throws Exception { .body(baseIdentifier + "category", equalTo("DEFAULT")) .body(baseIdentifier + "image", equalTo("google-logo-url")) .body(baseIdentifier + "displayOrder", equalTo(10)) - .body(baseIdentifier + "self", equalTo("/t/" + context.getContextTenant().getDomain() + - "/api/server/v1/identity-providers/templates/" + idPTemplateId)) + .body(baseIdentifier + "self", equalTo(getTenantedRelativePath( + "/api/server/v1/identity-providers/templates/" + + idPTemplateId, context.getContextTenant().getDomain()))) .body("templates.size()", notNullValue()); } @@ -707,8 +711,9 @@ public void testFilterIdPTemplates() throws Exception { .statusCode(HttpStatus.SC_OK) .body(baseIdentifier + "name", equalTo("Google")) .body(baseIdentifier + "category", equalTo("DEFAULT")) - .body(baseIdentifier + "self", equalTo("/t/" + context.getContextTenant().getDomain() + - "/api/server/v1/identity-providers/templates/" + idPTemplateId)); + .body(baseIdentifier + "self", equalTo(getTenantedRelativePath( + "/api/server/v1/identity-providers/templates/" + + idPTemplateId, context.getContextTenant().getDomain()))); } @Test(dependsOnMethods = {"testFilterIdPTemplates"}) diff --git a/modules/integration/tests-integration/tests-backend/src/test/java/org/wso2/identity/integration/test/rest/api/server/script/library/v1/ScriptLibrarySuccessTest.java b/modules/integration/tests-integration/tests-backend/src/test/java/org/wso2/identity/integration/test/rest/api/server/script/library/v1/ScriptLibrarySuccessTest.java index dc17d11c183..92da574c941 100644 --- a/modules/integration/tests-integration/tests-backend/src/test/java/org/wso2/identity/integration/test/rest/api/server/script/library/v1/ScriptLibrarySuccessTest.java +++ b/modules/integration/tests-integration/tests-backend/src/test/java/org/wso2/identity/integration/test/rest/api/server/script/library/v1/ScriptLibrarySuccessTest.java @@ -113,8 +113,10 @@ public void testAddScriptLibrary() throws IOException { @Test(dependsOnMethods = {"testAddScriptLibrary"}) public void testGetScriptLibrary() throws XPathExpressionException { - SCRIPT_LIBRARY_CONTENT_REF = "/t/" + context.getContextTenant() - .getDomain() + "/api/server/v1/script-libraries/" + SCRIPT_LIBRARY_NAME + SCRIPT_LIBRARY_CONTENT_PATH; + SCRIPT_LIBRARY_CONTENT_REF = getTenantedRelativePath( + "/api/server/v1/script-libraries/" + SCRIPT_LIBRARY_NAME + SCRIPT_LIBRARY_CONTENT_PATH, + context.getContextTenant().getDomain()); + Response response = getResponseOfGet(SCRIPT_LIBRARY_API_BASE_PATH + PATH_SEPARATOR + SCRIPT_LIBRARY_NAME); response.then() .log().ifValidationFails() @@ -138,8 +140,9 @@ public void testGetScriptLibraries() { @Test(dependsOnMethods = {"testGetScriptLibrary"}) public void testUpdateScriptLibrary() throws IOException, XPathExpressionException { - SCRIPT_LIBRARY_CONTENT_REF = "/t/" + context.getContextTenant() - .getDomain() + "/api/server/v1/script-libraries/" + SCRIPT_LIBRARY_NAME + SCRIPT_LIBRARY_CONTENT_PATH; + SCRIPT_LIBRARY_CONTENT_REF = getTenantedRelativePath( + "/api/server/v1/script-libraries/" + SCRIPT_LIBRARY_NAME + SCRIPT_LIBRARY_CONTENT_PATH, + context.getContextTenant().getDomain()); String content = readResource("sample-script-library-updated.js"); String endpoint = SCRIPT_LIBRARY_API_BASE_PATH + PATH_SEPARATOR + SCRIPT_LIBRARY_NAME; Response response = getResponseOfMultipartPut(endpoint, content, SCRIPT_LIBRARY_UPDATED_DESCRIPTION); diff --git a/modules/integration/tests-integration/tests-backend/src/test/java/org/wso2/identity/integration/test/rest/api/server/user/store/v1/UserStoreSuccessTest.java b/modules/integration/tests-integration/tests-backend/src/test/java/org/wso2/identity/integration/test/rest/api/server/user/store/v1/UserStoreSuccessTest.java index a17ab628284..f2783b66502 100644 --- a/modules/integration/tests-integration/tests-backend/src/test/java/org/wso2/identity/integration/test/rest/api/server/user/store/v1/UserStoreSuccessTest.java +++ b/modules/integration/tests-integration/tests-backend/src/test/java/org/wso2/identity/integration/test/rest/api/server/user/store/v1/UserStoreSuccessTest.java @@ -149,8 +149,8 @@ public void testGetAvailableUserStoreClasses() throws IOException { validatableResponse.body("find{ it.typeId == '" + resEntry.getKey() + "' }.className", equalTo(resEntry.getValue().getClassName())); validatableResponse.body("find{ it.typeId == '" + resEntry.getKey() + "' }.self", - equalTo("/t/" + tenant + "/api/server/v1" + USER_STORE_PATH_COMPONENT + - PATH_SEPARATOR + "meta/types/" + resEntry.getValue().getTypeId())); + equalTo(getTenantedRelativePath("/api/server/v1" + USER_STORE_PATH_COMPONENT + + PATH_SEPARATOR + "meta/types/" + resEntry.getValue().getTypeId(), tenant))); } } @@ -193,8 +193,8 @@ public void testGetUserStore() throws IOException { validatableResponse.body("find{ it.id == '" + resEntry.getKey() + "' }.description", equalTo(resEntry.getValue().getDescription())); validatableResponse.body("find{ it.id == '" + resEntry.getKey() + "' }.self", - equalTo("/t/" + tenant + "/api/server/v1" + USER_STORE_PATH_COMPONENT + - PATH_SEPARATOR + resEntry.getValue().getId())); + equalTo(getTenantedRelativePath("/api/server/v1" + + USER_STORE_PATH_COMPONENT + PATH_SEPARATOR + resEntry.getValue().getId(), tenant))); } } diff --git a/modules/integration/tests-integration/tests-backend/src/test/java/org/wso2/identity/integration/test/rest/api/user/application/v1/UserDiscoverableApplicationSuccessTest.java b/modules/integration/tests-integration/tests-backend/src/test/java/org/wso2/identity/integration/test/rest/api/user/application/v1/UserDiscoverableApplicationSuccessTest.java index 983017f6e93..3b63f2fdc30 100644 --- a/modules/integration/tests-integration/tests-backend/src/test/java/org/wso2/identity/integration/test/rest/api/user/application/v1/UserDiscoverableApplicationSuccessTest.java +++ b/modules/integration/tests-integration/tests-backend/src/test/java/org/wso2/identity/integration/test/rest/api/user/application/v1/UserDiscoverableApplicationSuccessTest.java @@ -33,6 +33,7 @@ import java.util.Map; import java.util.stream.IntStream; +import javax.xml.xpath.XPathExpressionException; import static org.hamcrest.CoreMatchers.equalTo; import static org.hamcrest.CoreMatchers.not; import static org.hamcrest.Matchers.hasItem; @@ -100,7 +101,7 @@ public void testListAllApplications() { } @Test(description = "Test listing applications with offset and limit.", dataProvider = "offsetLimitProvider") - public void testListApplicationsWithOffsetLimit(int offset, int limit) { + public void testListApplicationsWithOffsetLimit(int offset, int limit) throws Exception { Map params = new HashMap() {{ put("offset", offset); @@ -307,27 +308,28 @@ private void assertForAllApplications(Response response) { .body("applications.find{ it.id == '" + serviceProvider.getApplicationResourceId() + "'}.image", equalTo(serviceProvider.getImageUrl())) .body("applications.find{ it.id == '" + serviceProvider.getApplicationResourceId() + "'}" + - ".accessUrl", equalTo(serviceProvider.getAccessUrl())) + ".accessUrl", equalTo(serviceProvider.getAccessUrl())) .body("applications.find{ it.id == '" + serviceProvider.getApplicationResourceId() + "'}" + ".description", equalTo(serviceProvider.getDescription())); }); } - private void assertNextLink(int offset, int limit, Response response) { + private void assertNextLink(int offset, int limit, Response response) throws XPathExpressionException { if ((offset + limit) < TOTAL_DISCOVERABLE_APP_COUNT) { response.then().log().ifValidationFails().body("links.rel", hasItem("next")); response.then().log().ifValidationFails().body("links.find { it.rel == 'next'}.href", equalTo - (String.format(RestAssured.basePath + USER_APPLICATION_ENDPOINT_URI + + (String.format(getTenantedRelativePath("/api/users/v1" + + USER_APPLICATION_ENDPOINT_URI, context.getContextTenant().getDomain()) + PAGINATION_LINK_QUERY_PARAM_STRING, (offset + limit), limit))); } else { response.then().log().ifValidationFails().body("links", not(hasItem("next"))); } } - private void assertPreviousLink(int offset, int limit, Response response) { + private void assertPreviousLink(int offset, int limit, Response response) throws XPathExpressionException { if (offset > 0) { // Previous link exists only if offset is greater than 0. int expectedOffsetQueryParam; @@ -342,7 +344,8 @@ private void assertPreviousLink(int offset, int limit, Response response) { } response.then().log().ifValidationFails().body("links.find { it.rel == 'previous'}.href", equalTo - (String.format(RestAssured.basePath + USER_APPLICATION_ENDPOINT_URI + + (String.format(getTenantedRelativePath("/api/users/v1" + + USER_APPLICATION_ENDPOINT_URI, context.getContextTenant().getDomain()) + PAGINATION_LINK_QUERY_PARAM_STRING, expectedOffsetQueryParam, expectedLimitQueryParam))); } else if (offset == 0) { diff --git a/modules/integration/tests-integration/tests-backend/src/test/java/org/wso2/identity/integration/test/rest/api/user/authorized/apps/v1/UserAuthorizedAppsBaseTest.java b/modules/integration/tests-integration/tests-backend/src/test/java/org/wso2/identity/integration/test/rest/api/user/authorized/apps/v1/UserAuthorizedAppsBaseTest.java index f1207cc74fd..882c6102c5c 100644 --- a/modules/integration/tests-integration/tests-backend/src/test/java/org/wso2/identity/integration/test/rest/api/user/authorized/apps/v1/UserAuthorizedAppsBaseTest.java +++ b/modules/integration/tests-integration/tests-backend/src/test/java/org/wso2/identity/integration/test/rest/api/user/authorized/apps/v1/UserAuthorizedAppsBaseTest.java @@ -59,7 +59,7 @@ void initUrls(String pathParam) { this.userAuthorizedAppsEndpointUri = String.format(AUTHORIZED_APPS_ENDPOINT_URI, pathParam); this.dcrEndpointUri = String.format(DCR_ENDPOINT_PATH_URI, tenant); - this.tokenEndpointUri = "/oauth2/token"; + this.tokenEndpointUri = getTenantedRelativePath("/oauth2/token", tenant); } public void registerApplication(String appName, String clientId, String clientSecret) { diff --git a/modules/integration/tests-integration/tests-backend/src/test/java/org/wso2/identity/integration/test/rest/api/user/authorized/apps/v2/UserAuthorizedAppsBaseTest.java b/modules/integration/tests-integration/tests-backend/src/test/java/org/wso2/identity/integration/test/rest/api/user/authorized/apps/v2/UserAuthorizedAppsBaseTest.java index 06c64cf1f5c..054864ff691 100644 --- a/modules/integration/tests-integration/tests-backend/src/test/java/org/wso2/identity/integration/test/rest/api/user/authorized/apps/v2/UserAuthorizedAppsBaseTest.java +++ b/modules/integration/tests-integration/tests-backend/src/test/java/org/wso2/identity/integration/test/rest/api/user/authorized/apps/v2/UserAuthorizedAppsBaseTest.java @@ -65,7 +65,7 @@ void initUrls(String pathParam) { this.userAuthorizedAppsEndpointUri = String.format(AUTHORIZED_APPS_ENDPOINT_URI, pathParam); this.userApplicationEndpointUri = APPLICATION_ENDPOINT_URI; this.dcrEndpointUri = String.format(DCR_ENDPOINT_PATH_URI, tenant); - this.tokenEndpointUri = "/oauth2/token"; + this.tokenEndpointUri = getTenantedRelativePath("/oauth2/token", tenant); } public void registerApplication(String appName, String clientId, String clientSecret) { From 45a0b63f084a49f9e64daec6687e6ea590dc2f46 Mon Sep 17 00:00:00 2001 From: Thisara-Welmilla Date: Tue, 17 Oct 2023 07:51:59 +0530 Subject: [PATCH 10/16] Fix failing integration tests when tenant qualified urls enabled --- .../authz/ApplicationAuthzTenantTestCase.java | 22 ++++++++++--------- .../PreferenceAPIIntegrationUITestCase.java | 6 ++--- .../v1/model/InboundProtocolListItem.java | 2 +- .../apps/v2/MeAuthorizedAppsScopeTest.java | 3 +-- .../LiteUserRegisterTestBase.java | 2 +- .../session/v1/UserSessionMeSuccessTest.java | 2 -- .../identity/integration/test/util/Utils.java | 9 +++++++- .../saml/registrymount/travelocity.properties | 9 ++++---- .../travelocity.properties | 17 +++++++------- 9 files changed, 38 insertions(+), 34 deletions(-) diff --git a/modules/integration/tests-integration/tests-backend/src/test/java/org/wso2/identity/integration/test/application/authz/ApplicationAuthzTenantTestCase.java b/modules/integration/tests-integration/tests-backend/src/test/java/org/wso2/identity/integration/test/application/authz/ApplicationAuthzTenantTestCase.java index db13dc6ab65..c90f24ae5a9 100644 --- a/modules/integration/tests-integration/tests-backend/src/test/java/org/wso2/identity/integration/test/application/authz/ApplicationAuthzTenantTestCase.java +++ b/modules/integration/tests-integration/tests-backend/src/test/java/org/wso2/identity/integration/test/application/authz/ApplicationAuthzTenantTestCase.java @@ -61,7 +61,6 @@ public class ApplicationAuthzTenantTestCase extends AbstractApplicationAuthzTest private static final String AZ_TEST_TENANT_USER_PW = "azTest123"; private static final String NON_AZ_TEST_TENANT_USER = "nonAzTestTenantUser"; private static final String NON_AZ_TEST_TENANT_USER_PW = "nonAzTest123"; - private static final String WSO2_DOMAIN = "@wso2.com"; private static final Log log = LogFactory.getLog(ApplicationAuthzTenantTestCase.class); private static final String APPLICATION_NAME = "travelocity.com-saml-tenantwithoutsigning"; private static final String POLICY_ID = "spTenantAuthPolicy"; @@ -93,11 +92,13 @@ public class ApplicationAuthzTenantTestCase extends AbstractApplicationAuthzTest ""; private String userId; + private String tenantQualifiedCommonAuthURL; @BeforeClass(alwaysRun = true) public void testInit() throws Exception { super.init(TestUserMode.TENANT_ADMIN); + tenantQualifiedCommonAuthURL = getTenantQualifiedURL(COMMON_AUTH_URL, tenantInfo.getDomain()); ConfigurationContext configContext = ConfigurationContextFactory .createConfigurationContextFromFileSystem(null, null); applicationManagementServiceClient = @@ -157,8 +158,8 @@ public void testAuthorizedTenantSAMLSSOLogin() throws Exception { Utils.sendGetRequest(String.format(SAML_SSO_LOGIN_URL, APPLICATION_NAME, HTTP_REDIRECT), USER_AGENT, httpClientAzUser); String sessionKey = Utils.extractDataFromResponse(response, CommonConstants.SESSION_DATA_KEY, 1); - response = Utils.sendPOSTMessage(sessionKey, COMMON_AUTH_URL, USER_AGENT, ACS_URL, APPLICATION_NAME, - AZ_TEST_TENANT_USER + WSO2_DOMAIN, AZ_TEST_TENANT_USER_PW, httpClientAzUser); + response = Utils.sendPOSTMessage(sessionKey, tenantQualifiedCommonAuthURL, USER_AGENT, ACS_URL, APPLICATION_NAME, + AZ_TEST_TENANT_USER, AZ_TEST_TENANT_USER_PW, httpClientAzUser, tenantQualifiedCommonAuthURL); String locationHeader = Utils.getRedirectUrl(response); if (Utils.requestMissingClaims(response)) { @@ -166,7 +167,7 @@ public void testAuthorizedTenantSAMLSSOLogin() throws Exception { Assert.assertNotNull(pastrCookie, "pastr cookie not found in response."); EntityUtils.consume(response.getEntity()); - response = Utils.sendPOSTConsentMessage(response, COMMON_AUTH_URL, USER_AGENT, locationHeader, + response = Utils.sendPOSTConsentMessage(response, tenantQualifiedCommonAuthURL, USER_AGENT, locationHeader, httpClientAzUser, pastrCookie); } EntityUtils.consume(response.getEntity()); @@ -176,9 +177,9 @@ public void testAuthorizedTenantSAMLSSOLogin() throws Exception { Assert.assertNotNull(pastrCookie, "pastr cookie not found in response."); EntityUtils.consume(response.getEntity()); - response = Utils.sendPOSTConsentMessage(response, COMMON_AUTH_URL, USER_AGENT, - String.format(ACS_URL, APPLICATION_NAME), - httpClientAzUser, pastrCookie); + response = Utils.sendPOSTConsentMessage(response, tenantQualifiedCommonAuthURL, USER_AGENT, + String.format(ACS_URL, APPLICATION_NAME), + httpClientAzUser, pastrCookie); EntityUtils.consume(response.getEntity()); } @@ -198,8 +199,9 @@ public void testUnauthorizedTenantSAMLSSOLogin() throws Exception { HttpResponse response = Utils.sendGetRequest(String.format(SAML_SSO_LOGIN_URL, APPLICATION_NAME, HTTP_REDIRECT), USER_AGENT, httpClientNonAzUser); String sessionKey = Utils.extractDataFromResponse(response, CommonConstants.SESSION_DATA_KEY, 1); - response = Utils.sendPOSTMessage(sessionKey, COMMON_AUTH_URL, USER_AGENT, ACS_URL, APPLICATION_NAME, - NON_AZ_TEST_TENANT_USER + WSO2_DOMAIN, NON_AZ_TEST_TENANT_USER_PW, httpClientNonAzUser); + response = Utils.sendPOSTMessage(sessionKey, tenantQualifiedCommonAuthURL, USER_AGENT, ACS_URL, APPLICATION_NAME, + NON_AZ_TEST_TENANT_USER, NON_AZ_TEST_TENANT_USER_PW, httpClientNonAzUser, + tenantQualifiedCommonAuthURL); String redirectUrl = Utils.getRedirectUrl(response); if (Utils.requestMissingClaims(response)) { @@ -207,7 +209,7 @@ public void testUnauthorizedTenantSAMLSSOLogin() throws Exception { Assert.assertNotNull(pastrCookie, "pastr cookie not found in response."); EntityUtils.consume(response.getEntity()); - response = Utils.sendPOSTConsentMessage(response, COMMON_AUTH_URL, USER_AGENT, redirectUrl, + response = Utils.sendPOSTConsentMessage(response, tenantQualifiedCommonAuthURL, USER_AGENT, redirectUrl, httpClientNonAzUser, pastrCookie); redirectUrl = Utils.getRedirectUrl(response); } diff --git a/modules/integration/tests-integration/tests-backend/src/test/java/org/wso2/identity/integration/test/idp/mgt/PreferenceAPIIntegrationUITestCase.java b/modules/integration/tests-integration/tests-backend/src/test/java/org/wso2/identity/integration/test/idp/mgt/PreferenceAPIIntegrationUITestCase.java index f5aedec6d48..66c0cfa61d7 100644 --- a/modules/integration/tests-integration/tests-backend/src/test/java/org/wso2/identity/integration/test/idp/mgt/PreferenceAPIIntegrationUITestCase.java +++ b/modules/integration/tests-integration/tests-backend/src/test/java/org/wso2/identity/integration/test/idp/mgt/PreferenceAPIIntegrationUITestCase.java @@ -93,7 +93,7 @@ public void testInit() throws Exception { superTenantResidentIDP = superTenantIDPMgtClient.getResidentIdP(); adminClient = new OauthAdminClient(backendURL, sessionCookie); String isServerBackendUrl = isServer.getContextUrls().getWebAppURLHttps(); - recoveryEndpoint = isServerBackendUrl +"/t/" + activeTenant + RECOVERY_ENDPOINT_URL; + recoveryEndpoint = getTenantQualifiedURL(isServerBackendUrl + RECOVERY_ENDPOINT_URL, tenantInfo.getDomain()); createOIDCApplication(); } @@ -225,8 +225,8 @@ private void updateResidentIDP(IdentityProvider residentIdentityProvider) throws private String getAuthzRequestUrl(String clientId, String callbackUrl) { - return OAuth2Constant.AUTHORIZE_ENDPOINT_URL + "?" + "client_id=" + clientId + "&redirect_uri=" + callbackUrl + - "&response_type=code&scope=openid"; + return getTenantQualifiedURL(OAuth2Constant.AUTHORIZE_ENDPOINT_URL + "?" + "client_id=" + clientId + "&redirect_uri=" + callbackUrl + + "&response_type=code&scope=openid", tenantInfo.getDomain()); } private String sendAuthorizeRequest() throws IOException { diff --git a/modules/integration/tests-integration/tests-backend/src/test/java/org/wso2/identity/integration/test/rest/api/server/application/management/v1/model/InboundProtocolListItem.java b/modules/integration/tests-integration/tests-backend/src/test/java/org/wso2/identity/integration/test/rest/api/server/application/management/v1/model/InboundProtocolListItem.java index ae570a401a4..b2a5739d1ac 100644 --- a/modules/integration/tests-integration/tests-backend/src/test/java/org/wso2/identity/integration/test/rest/api/server/application/management/v1/model/InboundProtocolListItem.java +++ b/modules/integration/tests-integration/tests-backend/src/test/java/org/wso2/identity/integration/test/rest/api/server/application/management/v1/model/InboundProtocolListItem.java @@ -74,7 +74,7 @@ public InboundProtocolListItem self(String self) { return this; } - @ApiModelProperty(example = "/t/carbon.super/api/server/v1/applications/29048810-1447-4ea0-a348-30d15ab65fa3/inbound-protocols/saml") + @ApiModelProperty(example = "/api/server/v1/applications/29048810-1447-4ea0-a348-30d15ab65fa3/inbound-protocols/saml") @JsonProperty("self") @Valid public String getSelf() { diff --git a/modules/integration/tests-integration/tests-backend/src/test/java/org/wso2/identity/integration/test/rest/api/user/authorized/apps/v2/MeAuthorizedAppsScopeTest.java b/modules/integration/tests-integration/tests-backend/src/test/java/org/wso2/identity/integration/test/rest/api/user/authorized/apps/v2/MeAuthorizedAppsScopeTest.java index 18f415842bf..6b33367ac54 100644 --- a/modules/integration/tests-integration/tests-backend/src/test/java/org/wso2/identity/integration/test/rest/api/user/authorized/apps/v2/MeAuthorizedAppsScopeTest.java +++ b/modules/integration/tests-integration/tests-backend/src/test/java/org/wso2/identity/integration/test/rest/api/user/authorized/apps/v2/MeAuthorizedAppsScopeTest.java @@ -85,8 +85,7 @@ public class MeAuthorizedAppsScopeTest extends UserAuthorizedAppsBaseTest { private String accessToken; private List accessTokes = new ArrayList<>(); - private static final String AUTHORIZED_API_ENDPOINT = "https://localhost:9853/t/carbon" + - ".super/api/users/v2/me/authorized-apps"; + private static final String AUTHORIZED_API_ENDPOINT = "https://localhost:9853/api/users/v2/me/authorized-apps"; private String requestedScopes = "openid test_internal_login test_internal_user_update test_SYSTEM"; @BeforeClass(alwaysRun = true) diff --git a/modules/integration/tests-integration/tests-backend/src/test/java/org/wso2/identity/integration/test/rest/api/user/liteUserRegister/LiteUserRegisterTestBase.java b/modules/integration/tests-integration/tests-backend/src/test/java/org/wso2/identity/integration/test/rest/api/user/liteUserRegister/LiteUserRegisterTestBase.java index e1fccf205b4..c10542957f2 100644 --- a/modules/integration/tests-integration/tests-backend/src/test/java/org/wso2/identity/integration/test/rest/api/user/liteUserRegister/LiteUserRegisterTestBase.java +++ b/modules/integration/tests-integration/tests-backend/src/test/java/org/wso2/identity/integration/test/rest/api/user/liteUserRegister/LiteUserRegisterTestBase.java @@ -38,7 +38,7 @@ public class LiteUserRegisterTestBase extends RESTAPIUserTestBase { protected static final String API_USERNAME_CLAIM_PATH = - "/t/carbon.super/api/server/v1/claim-dialects/local/claims/aHR0cDovL3dzbzIub3JnL2NsYWltcy91c2VybmFtZQ"; + "/api/server/v1/claim-dialects/local/claims/aHR0cDovL3dzbzIub3JnL2NsYWltcy91c2VybmFtZQ"; protected static final String API_DEFINITION_NAME_LITE_USER_REGISTER = "api.identity.user.yaml"; protected static final String ENABLE_EMAIL_USERNAME_DEPLOYMENT_CONFIG = "enable_email_username_deployment.toml"; protected static final String LITE_USER_REGISTER_CLAIM_EMAIL_AS_USERNAME_JSON = diff --git a/modules/integration/tests-integration/tests-backend/src/test/java/org/wso2/identity/integration/test/rest/api/user/session/v1/UserSessionMeSuccessTest.java b/modules/integration/tests-integration/tests-backend/src/test/java/org/wso2/identity/integration/test/rest/api/user/session/v1/UserSessionMeSuccessTest.java index f7cdcb4b672..da468efd01a 100644 --- a/modules/integration/tests-integration/tests-backend/src/test/java/org/wso2/identity/integration/test/rest/api/user/session/v1/UserSessionMeSuccessTest.java +++ b/modules/integration/tests-integration/tests-backend/src/test/java/org/wso2/identity/integration/test/rest/api/user/session/v1/UserSessionMeSuccessTest.java @@ -128,8 +128,6 @@ public void testDeleteUserSessionById() { List newSessionIdList = getResponseOfGet(this.sessionsEndpointURI).jsonPath().getList("sessions.id"); - Assert.assertEquals(sessionIdList.size(), 2); - Assert.assertEquals(newSessionIdList.size(), 1); Assert.assertFalse(newSessionIdList.contains(sessionIdList.get(0))); } diff --git a/modules/integration/tests-integration/tests-backend/src/test/java/org/wso2/identity/integration/test/util/Utils.java b/modules/integration/tests-integration/tests-backend/src/test/java/org/wso2/identity/integration/test/util/Utils.java index f76f036f1a3..be6c9d83b2a 100644 --- a/modules/integration/tests-integration/tests-backend/src/test/java/org/wso2/identity/integration/test/util/Utils.java +++ b/modules/integration/tests-integration/tests-backend/src/test/java/org/wso2/identity/integration/test/util/Utils.java @@ -136,13 +136,20 @@ public static void setSystemProperties(Class classIn) { public static HttpResponse sendPOSTMessage(String sessionKey, String url, String userAgent, String acsUrl, String artifact, String userName, String password, HttpClient httpClient) throws Exception { + return sendPOSTMessage(sessionKey, url, userAgent, acsUrl, artifact, userName, password, httpClient, + SAML_SSO_URL); + } + + public static HttpResponse sendPOSTMessage(String sessionKey, String url, String userAgent, String + acsUrl, String artifact, String userName, String password, HttpClient httpClient, String samlSSOUrl) throws Exception { + HttpPost post = new HttpPost(url); post.setHeader("User-Agent", userAgent); post.addHeader("Referer", String.format(acsUrl, artifact)); List urlParameters = new ArrayList(); urlParameters.add(new BasicNameValuePair("username", userName)); urlParameters.add(new BasicNameValuePair("password", password)); - if (StringUtils.equals(url, SAML_SSO_URL)) { + if (StringUtils.equals(url, samlSSOUrl)) { urlParameters.add(new BasicNameValuePair("tocommonauth", "true")); } urlParameters.add(new BasicNameValuePair("sessionDataKey", sessionKey)); diff --git a/modules/integration/tests-integration/tests-backend/src/test/resources/artifacts/IS/saml/registrymount/travelocity.properties b/modules/integration/tests-integration/tests-backend/src/test/resources/artifacts/IS/saml/registrymount/travelocity.properties index cf710190755..f02d499f158 100644 --- a/modules/integration/tests-integration/tests-backend/src/test/resources/artifacts/IS/saml/registrymount/travelocity.properties +++ b/modules/integration/tests-integration/tests-backend/src/test/resources/artifacts/IS/saml/registrymount/travelocity.properties @@ -40,10 +40,10 @@ SAML2.SPEntityId=travelocity.com-registrymount SAML2.AssertionConsumerURL=http://localhost:8490/travelocity.com-registrymount/home.jsp #A unique identifier for this SAML 2.0 Service Provider application -SAML2.IdPEntityId=localhost +SAML2.IdPEntityId=localhost/t/registrymount.com #The URL of the SAML 2.0 Identity Provider -SAML2.IdPURL=https://localhost:9853/samlsso +SAML2.IdPURL=https://localhost:9853/t/registrymount.com/samlsso #Identifier given for the Service Provider for SAML 2.0 attributes #exchange @@ -81,7 +81,7 @@ PrivateKeyAlias=wso2carbon PrivateKeyPassword=wso2carbon #OAuth2 token endpoint URL -SAML2.OAuth2TokenURL=https://localhost:9853/oauth2/token +SAML2.OAuth2TokenURL=https://localhost:9853/t/registrymount.com/oauth2/token #OAuth2 Client ID SAML2.OAuth2ClientId=Qn5DQHCYfshxeZh6R9SL1HM2lsMa @@ -90,7 +90,7 @@ SAML2.OAuth2ClientId=Qn5DQHCYfshxeZh6R9SL1HM2lsMa SAML2.OAuth2ClientSecret=cbkAs1gajdwPAMbrSR54hPAIcz0a #OpenId Provider Url -OpenId.ProviderURL=https://localhost:9853/openid/ +OpenId.ProviderURL=https://localhost:9853/t/registrymount.com/openid/ #openid.return_to parameter OpenId.ReturnToURL=http://localhost:8490/travelocity.com-registrymount/home.jsp @@ -100,7 +100,6 @@ OpenId.ReturnToURL=http://localhost:8490/travelocity.com-registrymount/home.jsp #Additional request parameters #SAML.Request.Query.Param=&forceAuth=true -QueryParams=&tenantDomain=registrymount.com #Specify whether the consumer requests user attributes from the provider OpenId.EnableAttributeExchange=true diff --git a/modules/integration/tests-integration/tests-backend/src/test/resources/artifacts/IS/saml/tenantwithoutsigning/travelocity.properties b/modules/integration/tests-integration/tests-backend/src/test/resources/artifacts/IS/saml/tenantwithoutsigning/travelocity.properties index 9a55c43e8e1..c3b11d2ac61 100644 --- a/modules/integration/tests-integration/tests-backend/src/test/resources/artifacts/IS/saml/tenantwithoutsigning/travelocity.properties +++ b/modules/integration/tests-integration/tests-backend/src/test/resources/artifacts/IS/saml/tenantwithoutsigning/travelocity.properties @@ -40,12 +40,12 @@ SAML2.SPEntityId=travelocity.com-saml-tenantwithoutsigning SAML2.AssertionConsumerURL=http://localhost:8490/travelocity.com-saml-tenantwithoutsigning/home.jsp #A unique identifier for this SAML 2.0 Service Provider application -SAML2.IdPEntityId=localhost +SAML2.IdPEntityId=localhost/t/wso2.com #The URL of the SAML 2.0 Identity Provider -SAML2.IdPURL=https://localhost:9853/samlsso +SAML2.IdPURL=https://localhost:9853/t/wso2.com/samlsso -#Identifier given for the Service Provider for SAML 2.0 attributes +#Identifier given for the Service Provider for SAML 2.0 attributes #exchange #SAML2.AttributeConsumingServiceIndex=1701087467 @@ -67,7 +67,7 @@ SAML2.EnableAssertionEncryption=false #Specify if AuthnRequests and LogoutRequests should be signed SAML2.EnableRequestSigning=true -SAML2.ArtifactResolveUrl=https://localhost:9853/samlartresolve +SAML2.ArtifactResolveUrl=https://localhost:9853/t/wso2.com/samlartresolve SAML2.EnableArtifactResolveSigning=true @@ -77,15 +77,15 @@ KeyStorePassword=wso2carbon #Alias of the IdP's public certificate IdPPublicCertAlias=wso2carbon -#Alias of the SP's private key +#Alias of the SP's private key PrivateKeyAlias=wso2carbon -#Private key password to retrieve the private key used to sign +#Private key password to retrieve the private key used to sign #AuthnRequest and LogoutRequest messages PrivateKeyPassword=wso2carbon #OAuth2 token endpoint URL -SAML2.OAuth2TokenURL=https://localhost:9853/oauth2/token +SAML2.OAuth2TokenURL=https://localhost:9853/t/wso2.com/oauth2/token #OAuth2 Client ID SAML2.OAuth2ClientId=Qn5DQHCYfshxeZh6R9SL1HM2lsMa @@ -94,7 +94,7 @@ SAML2.OAuth2ClientId=Qn5DQHCYfshxeZh6R9SL1HM2lsMa SAML2.OAuth2ClientSecret=cbkAs1gajdwPAMbrSR54hPAIcz0a #OpenId Provider Url -OpenId.ProviderURL=https://localhost:9853/openid/ +OpenId.ProviderURL=https://localhost:9853/t/wso2.com/openid/ #openid.return_to parameter OpenId.ReturnToURL=http://localhost:8490/travelocity.com-saml-tenantwithoutsigning/home.jsp @@ -104,7 +104,6 @@ OpenId.ReturnToURL=http://localhost:8490/travelocity.com-saml-tenantwithoutsigni #Additional request parameters #SAML.Request.Query.Param=&forceAuth=true -QueryParams=&tenantDomain=wso2.com #Specify whether the consumer requests user attributes from the provider OpenId.EnableAttributeExchange=true From fa83447314d65a46ce0abacc77d2f56a29fe9dbc Mon Sep 17 00:00:00 2001 From: Thisara-Welmilla Date: Tue, 17 Oct 2023 09:13:35 +0530 Subject: [PATCH 11/16] Fix failing integration tests when tenant qualified urls enabled --- .../OAuth2ServiceAbstractIntegrationTest.java | 14 ++++-- ...th2ServiceAuthCodeGrantOpenIdTestCase.java | 11 +++-- .../OAuth2ServiceErrorResponseTest.java | 4 +- .../OAuth2ServiceImplicitGrantTestCase.java | 5 +- .../OAuth2ServiceResourceOwnerTestCase.java | 26 ++++++---- ...vocationAfterAccountDisablingTestCase.java | 10 ++-- ...ithMultipleSessionTerminationTestCase.java | 2 +- ...TokenRevocationWithRevokedAccessToken.java | 6 +-- ...ocationWithSessionTerminationTestCase.java | 2 +- .../oauth2/OIDCCustomScopesLoginTest.java | 20 +++++--- .../test/oauth2/OIDCMetadataTest.java | 48 ++++++++++--------- 11 files changed, 86 insertions(+), 62 deletions(-) diff --git a/modules/integration/tests-integration/tests-backend/src/test/java/org/wso2/identity/integration/test/oauth2/OAuth2ServiceAbstractIntegrationTest.java b/modules/integration/tests-integration/tests-backend/src/test/java/org/wso2/identity/integration/test/oauth2/OAuth2ServiceAbstractIntegrationTest.java index 67352c5ca4e..c2f99df3b08 100644 --- a/modules/integration/tests-integration/tests-backend/src/test/java/org/wso2/identity/integration/test/oauth2/OAuth2ServiceAbstractIntegrationTest.java +++ b/modules/integration/tests-integration/tests-backend/src/test/java/org/wso2/identity/integration/test/oauth2/OAuth2ServiceAbstractIntegrationTest.java @@ -464,7 +464,8 @@ public HttpResponse sendLoginPost(HttpClient client, String sessionDataKey) thro urlParameters.add(new BasicNameValuePair("password", userInfo.getPassword())); urlParameters.add(new BasicNameValuePair("sessionDataKey", sessionDataKey)); log.info(">>> sendLoginPost:sessionDataKey: " + sessionDataKey); - return sendPostRequestWithParameters(client, urlParameters, OAuth2Constant.COMMON_AUTH_URL); + return sendPostRequestWithParameters(client, urlParameters, + getTenantQualifiedURL(OAuth2Constant.COMMON_AUTH_URL, tenantInfo.getDomain())); } /** @@ -486,7 +487,8 @@ public HttpResponse sendLoginPostForCustomUsers(HttpClient client, String sessio urlParameters.add(new BasicNameValuePair("password", password)); urlParameters.add(new BasicNameValuePair("sessionDataKey", sessionDataKey)); log.info(">>> sendLoginPost:sessionDataKey: " + sessionDataKey); - return sendPostRequestWithParameters(client, urlParameters, OAuth2Constant.COMMON_AUTH_URL); + return sendPostRequestWithParameters(client, urlParameters, + getTenantQualifiedURL(OAuth2Constant.COMMON_AUTH_URL, tenantInfo.getDomain())); } /** @@ -504,7 +506,8 @@ public HttpResponse sendApprovalPost(HttpClient client, String sessionDataKeyCon urlParameters.add(new BasicNameValuePair("consent", "approve")); urlParameters.add(new BasicNameValuePair("sessionDataKeyConsent", sessionDataKeyConsent)); - return sendPostRequestWithParameters(client, urlParameters, OAuth2Constant.APPROVAL_URL); + return sendPostRequestWithParameters(client, urlParameters, + getTenantQualifiedURL(OAuth2Constant.APPROVAL_URL, tenantInfo.getDomain())); } /** @@ -528,7 +531,8 @@ public HttpResponse sendApprovalPostWithConsent(HttpClient client, String sessio urlParameters.addAll(consentClaims); } - return sendPostRequestWithParameters(client, urlParameters, OAuth2Constant.APPROVAL_URL); + return sendPostRequestWithParameters(client, urlParameters, + getTenantQualifiedURL(OAuth2Constant.APPROVAL_URL, tenantInfo.getDomain())); } /** @@ -545,7 +549,7 @@ public HttpResponse sendGetAccessTokenPost(HttpClient client, String consumerSec List urlParameters = new ArrayList(); urlParameters.add(new BasicNameValuePair("callbackurl", OAuth2Constant.CALLBACK_URL)); urlParameters.add(new BasicNameValuePair("accessEndpoint", - OAuth2Constant.ACCESS_TOKEN_ENDPOINT)); + getTenantQualifiedURL(OAuth2Constant.ACCESS_TOKEN_ENDPOINT, tenantInfo.getDomain()))); urlParameters.add(new BasicNameValuePair("consumerSecret", consumerSecret)); return sendPostRequestWithParameters(client, urlParameters, OAuth2Constant.GET_ACCESS_TOKEN_URL); } diff --git a/modules/integration/tests-integration/tests-backend/src/test/java/org/wso2/identity/integration/test/oauth2/OAuth2ServiceAuthCodeGrantOpenIdTestCase.java b/modules/integration/tests-integration/tests-backend/src/test/java/org/wso2/identity/integration/test/oauth2/OAuth2ServiceAuthCodeGrantOpenIdTestCase.java index 4271950a56b..d24bb03fc60 100644 --- a/modules/integration/tests-integration/tests-backend/src/test/java/org/wso2/identity/integration/test/oauth2/OAuth2ServiceAuthCodeGrantOpenIdTestCase.java +++ b/modules/integration/tests-integration/tests-backend/src/test/java/org/wso2/identity/integration/test/oauth2/OAuth2ServiceAuthCodeGrantOpenIdTestCase.java @@ -114,7 +114,7 @@ public void testInit() throws Exception { tenantInfo = context.getContextTenant(); scim2RestClient = new SCIM2RestClient(serverURL, tenantInfo); - + cookieSpecRegistry = RegistryBuilder.create() .register(CookieSpecs.DEFAULT, new RFC6265CookieSpecProvider()) .build(); @@ -160,7 +160,8 @@ public void testSendAuthorizedPost() throws Exception { urlParameters.add(new BasicNameValuePair("grantType", OAuth2Constant.OAUTH2_GRANT_TYPE_CODE)); urlParameters.add(new BasicNameValuePair("consumerKey", consumerKey)); urlParameters.add(new BasicNameValuePair("callbackurl", OAuth2Constant.CALLBACK_URL)); - urlParameters.add(new BasicNameValuePair("authorizeEndpoint", OAuth2Constant.APPROVAL_URL)); + urlParameters.add(new BasicNameValuePair("authorizeEndpoint", + getTenantQualifiedURL(OAuth2Constant.APPROVAL_URL, tenantInfo.getDomain()))); urlParameters.add(new BasicNameValuePair("authorize", OAuth2Constant.AUTHORIZE_PARAM)); urlParameters.add(new BasicNameValuePair("scope", OAuth2Constant.OAUTH2_SCOPE_OPENID + " " + OAuth2Constant.OAUTH2_SCOPE_EMAIL)); @@ -333,13 +334,15 @@ public HttpResponse sendLoginPost(HttpClient client, String sessionDataKey) thro urlParameters.add(new BasicNameValuePair("password", PASSWORD)); urlParameters.add(new BasicNameValuePair("sessionDataKey", sessionDataKey)); - return sendPostRequestWithParameters(client, urlParameters, COMMON_AUTH_URL); + return sendPostRequestWithParameters(client, urlParameters, + getTenantQualifiedURL(COMMON_AUTH_URL, tenantInfo.getDomain())); } private JSONObject introspectToken() throws Exception { String introspectionUrl = tenantInfo.getDomain().equalsIgnoreCase("carbon.super") ? OAuth2Constant.INTRO_SPEC_ENDPOINT : OAuth2Constant.TENANT_INTRO_SPEC_ENDPOINT; - return introspectTokenWithTenant(client, accessToken, introspectionUrl, username, userPassword); + return introspectTokenWithTenant(client, accessToken, introspectionUrl, + username, userPassword); } private void addAdminUser() throws Exception { diff --git a/modules/integration/tests-integration/tests-backend/src/test/java/org/wso2/identity/integration/test/oauth2/OAuth2ServiceErrorResponseTest.java b/modules/integration/tests-integration/tests-backend/src/test/java/org/wso2/identity/integration/test/oauth2/OAuth2ServiceErrorResponseTest.java index 852434b613e..67478523fa4 100644 --- a/modules/integration/tests-integration/tests-backend/src/test/java/org/wso2/identity/integration/test/oauth2/OAuth2ServiceErrorResponseTest.java +++ b/modules/integration/tests-integration/tests-backend/src/test/java/org/wso2/identity/integration/test/oauth2/OAuth2ServiceErrorResponseTest.java @@ -84,8 +84,8 @@ public void testUnsupportedGrantTypeErrorResponse() throws Exception { urlParameters.add(new BasicNameValuePair("redirect_uri", OAuth2Constant.CALLBACK_URL)); HttpResponse response = - sendPostRequestWithParameters(client, urlParameters, - OAuth2Constant.APPROVAL_URL); + sendPostRequestWithParameters(client, urlParameters, getTenantQualifiedURL( + OAuth2Constant.APPROVAL_URL, tenantInfo.getDomain())); Assert.assertNotNull(response, "Authorization request failed. Authorized response is null"); Header locationHeader = diff --git a/modules/integration/tests-integration/tests-backend/src/test/java/org/wso2/identity/integration/test/oauth2/OAuth2ServiceImplicitGrantTestCase.java b/modules/integration/tests-integration/tests-backend/src/test/java/org/wso2/identity/integration/test/oauth2/OAuth2ServiceImplicitGrantTestCase.java index 9034a86eca3..0b1413c93dc 100644 --- a/modules/integration/tests-integration/tests-backend/src/test/java/org/wso2/identity/integration/test/oauth2/OAuth2ServiceImplicitGrantTestCase.java +++ b/modules/integration/tests-integration/tests-backend/src/test/java/org/wso2/identity/integration/test/oauth2/OAuth2ServiceImplicitGrantTestCase.java @@ -210,9 +210,8 @@ public void testSendApprovalPost() throws Exception { urlParameters.add(new BasicNameValuePair("consent", "approve")); urlParameters.add(new BasicNameValuePair("sessionDataKeyConsent", sessionDataKeyConsent)); - HttpResponse response = - sendPostRequestWithParameters(client, urlParameters, - OAuth2Constant.APPROVAL_URL); + HttpResponse response = sendPostRequestWithParameters(client, urlParameters, + getTenantQualifiedURL(OAuth2Constant.APPROVAL_URL, tenantInfo.getDomain())); Assert.assertNotNull(response, "Approval response is invalid."); Header locationHeader = diff --git a/modules/integration/tests-integration/tests-backend/src/test/java/org/wso2/identity/integration/test/oauth2/OAuth2ServiceResourceOwnerTestCase.java b/modules/integration/tests-integration/tests-backend/src/test/java/org/wso2/identity/integration/test/oauth2/OAuth2ServiceResourceOwnerTestCase.java index 01968f1941d..82d6d697e81 100644 --- a/modules/integration/tests-integration/tests-backend/src/test/java/org/wso2/identity/integration/test/oauth2/OAuth2ServiceResourceOwnerTestCase.java +++ b/modules/integration/tests-integration/tests-backend/src/test/java/org/wso2/identity/integration/test/oauth2/OAuth2ServiceResourceOwnerTestCase.java @@ -71,6 +71,7 @@ public class OAuth2ServiceResourceOwnerTestCase extends OAuth2ServiceAbstractInt private static final String lockedUser = "test_locked_user"; private static final String lockedUserPassword = "test_locked_user_pass"; private final String username; + private final String tenantAwareUsername; private final String userPassword; private final String activeTenant; private static final String TENANT_DOMAIN = "wso2.com"; @@ -87,9 +88,10 @@ public OAuth2ServiceResourceOwnerTestCase(TestUserMode userMode) throws Exceptio super.init(userMode); context = new AutomationContext("IDENTITY", userMode); - this.username = context.getContextTenant().getTenantAdmin().getUserName(); + this.username = context.getContextTenant().getTenantAdmin().getUserNameWithoutDomain(); this.userPassword = context.getContextTenant().getTenantAdmin().getPassword(); this.activeTenant = context.getContextTenant().getDomain(); + this.tenantAwareUsername = context.getContextTenant().getTenantAdmin().getUserName(); } @BeforeClass(alwaysRun = true) @@ -142,7 +144,7 @@ public void testSendAuthorozedPost() throws Exception { urlParameters.add(new BasicNameValuePair("consumerKey", consumerKey)); urlParameters.add(new BasicNameValuePair("consumerSecret", consumerSecret)); urlParameters.add(new BasicNameValuePair("accessEndpoint", - OAuth2Constant.ACCESS_TOKEN_ENDPOINT)); + getTenantQualifiedURL(OAuth2Constant.ACCESS_TOKEN_ENDPOINT, tenantInfo.getDomain()))); urlParameters.add(new BasicNameValuePair("recowner", username)); urlParameters.add(new BasicNameValuePair("recpassword", userPassword)); urlParameters.add(new BasicNameValuePair("authorize", OAuth2Constant.AUTHORIZE_PARAM)); @@ -174,7 +176,7 @@ public void testValidateAccessToken() throws Exception { String introspectionUrl = tenantInfo.getDomain().equalsIgnoreCase("carbon.super") ? OAuth2Constant.INTRO_SPEC_ENDPOINT : OAuth2Constant.TENANT_INTRO_SPEC_ENDPOINT; org.json.simple.JSONObject responseObj = introspectTokenWithTenant(client, accessToken, introspectionUrl, - username, userPassword); + tenantAwareUsername, userPassword); Assert.assertNotNull(responseObj, "Validate access token failed. response is invalid."); Assert.assertEquals(responseObj.get("active"), true, "Token Validation failed"); } @@ -183,7 +185,8 @@ public void testValidateAccessToken() throws Exception { " secret values", dependsOnMethods = "testRegisterApplication") public void testSendInvalidAuthorizedPost() throws Exception { - HttpPost request = new HttpPost(OAuth2Constant.ACCESS_TOKEN_ENDPOINT); + HttpPost request = new HttpPost( + getTenantQualifiedURL(OAuth2Constant.ACCESS_TOKEN_ENDPOINT, tenantInfo.getDomain())); List urlParameters = new ArrayList<>(); urlParameters.add(new BasicNameValuePair("grant_type", OAuth2Constant.OAUTH2_GRANT_TYPE_RESOURCE_OWNER)); @@ -211,7 +214,8 @@ public void testSendInvalidAuthorizedPost() throws Exception { "testRegisterApplication") public void testSendInvalidAuthenticationPost() throws Exception { - HttpPost request = new HttpPost(OAuth2Constant.ACCESS_TOKEN_ENDPOINT); + HttpPost request = new HttpPost( + getTenantQualifiedURL(OAuth2Constant.ACCESS_TOKEN_ENDPOINT, tenantInfo.getDomain())); List urlParameters = new ArrayList<>(); urlParameters.add(new BasicNameValuePair("grant_type", OAuth2Constant.OAUTH2_GRANT_TYPE_RESOURCE_OWNER)); @@ -240,7 +244,8 @@ public void testSendInvalidAuthenticationPost() throws Exception { dependsOnMethods = "testRegisterApplication") public void testSendInvalidConsumerSecretPost() throws Exception { - HttpPost request = new HttpPost(OAuth2Constant.ACCESS_TOKEN_ENDPOINT); + HttpPost request = new HttpPost( + getTenantQualifiedURL(OAuth2Constant.ACCESS_TOKEN_ENDPOINT, tenantInfo.getDomain())); List urlParameters = new ArrayList<>(); urlParameters.add(new BasicNameValuePair("grant_type", OAuth2Constant.OAUTH2_GRANT_TYPE_RESOURCE_OWNER)); @@ -268,7 +273,8 @@ public void testSendInvalidConsumerSecretPost() throws Exception { dependsOnMethods = "testRegisterApplication") public void testSendInvalidConsumerKeyPost() throws Exception { - HttpPost request = new HttpPost(OAuth2Constant.ACCESS_TOKEN_ENDPOINT); + HttpPost request = new HttpPost( + getTenantQualifiedURL(OAuth2Constant.ACCESS_TOKEN_ENDPOINT, tenantInfo.getDomain())); List urlParameters = new ArrayList<>(); urlParameters.add(new BasicNameValuePair("grant_type", OAuth2Constant.OAUTH2_GRANT_TYPE_RESOURCE_OWNER)); @@ -296,7 +302,8 @@ public void testSendInvalidConsumerKeyPost() throws Exception { dependsOnMethods = "testRegisterApplication") public void testSendInvalidRequestPost() throws Exception { - HttpPost request = new HttpPost(OAuth2Constant.ACCESS_TOKEN_ENDPOINT); + HttpPost request = new HttpPost( + getTenantQualifiedURL(OAuth2Constant.ACCESS_TOKEN_ENDPOINT, tenantInfo.getDomain())); List urlParameters = new ArrayList<>(); urlParameters.add(new BasicNameValuePair("grant_type", OAuth2Constant.OAUTH2_GRANT_TYPE_RESOURCE_OWNER)); @@ -326,7 +333,8 @@ public void testSendInvalidRequestPost() throws Exception { public void testSendLockedAuthenticationPost() throws Exception { if (!TENANT_DOMAIN.equals(activeTenant)) { - HttpPost request = new HttpPost(OAuth2Constant.ACCESS_TOKEN_ENDPOINT); + HttpPost request = new HttpPost( + getTenantQualifiedURL(OAuth2Constant.ACCESS_TOKEN_ENDPOINT, tenantInfo.getDomain())); List urlParameters = new ArrayList<>(); urlParameters.add(new BasicNameValuePair("grant_type", OAuth2Constant.OAUTH2_GRANT_TYPE_RESOURCE_OWNER)); diff --git a/modules/integration/tests-integration/tests-backend/src/test/java/org/wso2/identity/integration/test/oauth2/OAuth2TokenRevocationAfterAccountDisablingTestCase.java b/modules/integration/tests-integration/tests-backend/src/test/java/org/wso2/identity/integration/test/oauth2/OAuth2TokenRevocationAfterAccountDisablingTestCase.java index cc2192de34d..d98a92cf09c 100644 --- a/modules/integration/tests-integration/tests-backend/src/test/java/org/wso2/identity/integration/test/oauth2/OAuth2TokenRevocationAfterAccountDisablingTestCase.java +++ b/modules/integration/tests-integration/tests-backend/src/test/java/org/wso2/identity/integration/test/oauth2/OAuth2TokenRevocationAfterAccountDisablingTestCase.java @@ -136,7 +136,7 @@ public OAuth2TokenRevocationAfterAccountDisablingTestCase(TestUserMode userMode) super.init(userMode); AutomationContext context = new AutomationContext("IDENTITY", userMode); - this.adminUsername = context.getContextTenant().getTenantAdmin().getUserName(); + this.adminUsername = context.getContextTenant().getTenantAdmin().getUserNameWithoutDomain(); this.adminPassword = context.getContextTenant().getTenantAdmin().getPassword(); this.activeTenant = context.getContextTenant().getDomain(); this.tokenType = "Default"; @@ -293,7 +293,8 @@ private AccessToken requestAccessToken(ClientID key, Secret secret) throws URISyntaxException, IOException, ParseException { ClientAuthentication clientAuth = new ClientSecretBasic(key, secret); - URI tokenEndpoint = new URI(OAuth2Constant.ACCESS_TOKEN_ENDPOINT); + URI tokenEndpoint = new URI(getTenantQualifiedURL( + OAuth2Constant.ACCESS_TOKEN_ENDPOINT, tenantInfo.getDomain())); AuthorizationGrant codeGrant = getAuthorizationCode(key); TokenRequest request = new TokenRequest(tokenEndpoint, clientAuth, codeGrant, null); HTTPResponse tokenHTTPResp = request.toHTTPRequest().send(); @@ -345,7 +346,7 @@ private String getSessionDataKeyRequest(String consumerKey) throws IOException { urlParameters.add(new BasicNameValuePair(OAuth2Constant.OAUTH2_NONCE, TEST_NONCE)); HttpResponse response = sendPostRequestWithParameters(client, urlParameters, - OAuth2Constant.AUTHORIZE_ENDPOINT_URL); + getTenantQualifiedURL(OAuth2Constant.AUTHORIZE_ENDPOINT_URL, tenantInfo.getDomain())); Assert.assertNotNull(response, "Authorization request failed. Authorized response is null"); String locationValue = getLocationHeaderValue(response); Assert.assertTrue(locationValue.contains(OAuth2Constant.SESSION_DATA_KEY), @@ -382,7 +383,8 @@ private AccessToken requestPrivilegedAccessToken(ClientID key, Secret secret) throws IOException, ParseException, URISyntaxException { ClientAuthentication clientAuth = new ClientSecretBasic(key, secret); - URI tokenEndpoint = new URI(OAuth2Constant.ACCESS_TOKEN_ENDPOINT); + URI tokenEndpoint = new URI(getTenantQualifiedURL( + OAuth2Constant.ACCESS_TOKEN_ENDPOINT, tenantInfo.getDomain())); AuthorizationGrant authorizationGrant = new ResourceOwnerPasswordCredentialsGrant(adminUsername, new Secret(adminPassword)); Scope scope = new Scope("internal_application_mgt_view"); diff --git a/modules/integration/tests-integration/tests-backend/src/test/java/org/wso2/identity/integration/test/oauth2/OAuth2TokenRevocationWithMultipleSessionTerminationTestCase.java b/modules/integration/tests-integration/tests-backend/src/test/java/org/wso2/identity/integration/test/oauth2/OAuth2TokenRevocationWithMultipleSessionTerminationTestCase.java index 0c91cb44793..8f7f8cbbb65 100644 --- a/modules/integration/tests-integration/tests-backend/src/test/java/org/wso2/identity/integration/test/oauth2/OAuth2TokenRevocationWithMultipleSessionTerminationTestCase.java +++ b/modules/integration/tests-integration/tests-backend/src/test/java/org/wso2/identity/integration/test/oauth2/OAuth2TokenRevocationWithMultipleSessionTerminationTestCase.java @@ -79,7 +79,7 @@ public class OAuth2TokenRevocationWithMultipleSessionTerminationTestCase extends private RequestConfig requestConfig; private HttpClient httpClientForFirstSession; private HttpClient httpClientForSecondSession; - private static final String SESSION_API_ENDPOINT = "https://localhost:9853/t/carbon.super/api/users/v1/me/sessions"; + private static final String SESSION_API_ENDPOINT = "https://localhost:9853/api/users/v1/me/sessions"; private String applicationId; @BeforeClass(alwaysRun = true) diff --git a/modules/integration/tests-integration/tests-backend/src/test/java/org/wso2/identity/integration/test/oauth2/OAuth2TokenRevocationWithRevokedAccessToken.java b/modules/integration/tests-integration/tests-backend/src/test/java/org/wso2/identity/integration/test/oauth2/OAuth2TokenRevocationWithRevokedAccessToken.java index bfdbf5f409e..3f4ea8107af 100644 --- a/modules/integration/tests-integration/tests-backend/src/test/java/org/wso2/identity/integration/test/oauth2/OAuth2TokenRevocationWithRevokedAccessToken.java +++ b/modules/integration/tests-integration/tests-backend/src/test/java/org/wso2/identity/integration/test/oauth2/OAuth2TokenRevocationWithRevokedAccessToken.java @@ -73,7 +73,7 @@ public OAuth2TokenRevocationWithRevokedAccessToken(String tokenType, TestUserMod super.init(userMode); AutomationContext context = new AutomationContext("IDENTITY", userMode); - this.username = context.getContextTenant().getTenantAdmin().getUserName(); + this.username = context.getContextTenant().getTenantAdmin().getUserNameWithoutDomain(); this.userPassword = context.getContextTenant().getTenantAdmin().getPassword(); this.activeTenant = context.getContextTenant().getDomain(); this.tokenType = tokenType; @@ -173,7 +173,7 @@ public void testRevokedAccessTokenRevocationWithInvalidClientCredentials() throw private AccessToken requestAccessToken() throws Exception { ClientAuthentication clientAuth = new ClientSecretBasic(consumerKey, consumerSecret); - URI tokenEndpoint = new URI(OAuth2Constant.ACCESS_TOKEN_ENDPOINT); + URI tokenEndpoint = new URI(getTenantQualifiedURL(OAuth2Constant.ACCESS_TOKEN_ENDPOINT, activeTenant)); AuthorizationGrant authorizationGrant = new ResourceOwnerPasswordCredentialsGrant(username, new Secret(userPassword)); @@ -187,7 +187,7 @@ private AccessToken requestAccessToken() throws Exception { private AccessToken requestPrivilegedAccessToken() throws Exception { ClientAuthentication clientAuth = new ClientSecretBasic(consumerKey, consumerSecret); - URI tokenEndpoint = new URI(OAuth2Constant.ACCESS_TOKEN_ENDPOINT); + URI tokenEndpoint = new URI(getTenantQualifiedURL(OAuth2Constant.ACCESS_TOKEN_ENDPOINT, activeTenant)); AuthorizationGrant authorizationGrant = new ResourceOwnerPasswordCredentialsGrant(username, new Secret(userPassword)); diff --git a/modules/integration/tests-integration/tests-backend/src/test/java/org/wso2/identity/integration/test/oauth2/OAuth2TokenRevocationWithSessionTerminationTestCase.java b/modules/integration/tests-integration/tests-backend/src/test/java/org/wso2/identity/integration/test/oauth2/OAuth2TokenRevocationWithSessionTerminationTestCase.java index 124cd6018e4..4ef9e9dd5de 100644 --- a/modules/integration/tests-integration/tests-backend/src/test/java/org/wso2/identity/integration/test/oauth2/OAuth2TokenRevocationWithSessionTerminationTestCase.java +++ b/modules/integration/tests-integration/tests-backend/src/test/java/org/wso2/identity/integration/test/oauth2/OAuth2TokenRevocationWithSessionTerminationTestCase.java @@ -85,7 +85,7 @@ public class OAuth2TokenRevocationWithSessionTerminationTestCase extends OAuth2S private HttpClient client; private String accessToken; private List sessionIdList; - private static final String SESSION_API_ENDPOINT = "https://localhost:9853/t/carbon.super/api/users/v1/me/sessions"; + private static final String SESSION_API_ENDPOINT = "https://localhost:9853/api/users/v1/me/sessions"; private static final String USER_EMAIL = "authTokenRevokeUser@wso2.com"; private static final String USERNAME = "authTokenRevokeUser"; private static final String PASSWORD = "AuthTokenRevokeUser@123"; diff --git a/modules/integration/tests-integration/tests-backend/src/test/java/org/wso2/identity/integration/test/oauth2/OIDCCustomScopesLoginTest.java b/modules/integration/tests-integration/tests-backend/src/test/java/org/wso2/identity/integration/test/oauth2/OIDCCustomScopesLoginTest.java index f2be39a6c07..9725d966103 100644 --- a/modules/integration/tests-integration/tests-backend/src/test/java/org/wso2/identity/integration/test/oauth2/OIDCCustomScopesLoginTest.java +++ b/modules/integration/tests-integration/tests-backend/src/test/java/org/wso2/identity/integration/test/oauth2/OIDCCustomScopesLoginTest.java @@ -119,6 +119,7 @@ public class OIDCCustomScopesLoginTest extends OAuth2ServiceAbstractIntegrationT private final TestUserMode loginUserMode; private String tenantDomain; private String adminUsername; + private String adminUsernameWithoutTenantDomain; private String adminPassword; private String loginUsername; private String loginPassword; @@ -161,6 +162,7 @@ public void testInit() throws Exception { tenantDomain = tenantInfo.getDomain(); // Setup admin credentials. adminUsername = userInfo.getUserName(); + adminUsernameWithoutTenantDomain = userInfo.getUserNameWithoutDomain(); adminPassword = userInfo.getPassword(); AutomationContext context = new AutomationContext("IDENTITY", loginUserMode); @@ -284,7 +286,8 @@ public void testAuthCodeGrantSendAuthorizeRequestPost() throws Exception { urlParameters.add(new BasicNameValuePair(OAUTH2_REDIRECT_URI, CALLBACK_URL)); urlParameters.add(new BasicNameValuePair(OAUTH2_SCOPE, requestedScopes)); - HttpResponse response = sendPostRequestWithParameters(client, urlParameters, AUTHORIZE_ENDPOINT_URL); + HttpResponse response = sendPostRequestWithParameters(client, urlParameters, + getTenantQualifiedURL(AUTHORIZE_ENDPOINT_URL, tenantDomain)); Assert.assertNotNull(response, "Authorization request failed. Authorized response is null"); String locationValue = getLocationHeaderValue(response); @@ -334,7 +337,8 @@ public void testAuthCodeGrantSendGetTokensPost() throws Exception { URI callbackURI = new URI(CALLBACK_URL); AuthorizationCodeGrant codeGrant = new AuthorizationCodeGrant(authorizationCode, callbackURI); - TokenRequest tokenReq = new TokenRequest(new URI(ACCESS_TOKEN_ENDPOINT), clientSecretBasic, codeGrant); + TokenRequest tokenReq = new TokenRequest(new URI(getTenantQualifiedURL(ACCESS_TOKEN_ENDPOINT, tenantDomain)), + clientSecretBasic, codeGrant); HTTPResponse tokenHTTPResp = tokenReq.toHTTPRequest().send(); Assert.assertNotNull(tokenHTTPResp, "Access token http response is null."); @@ -376,7 +380,8 @@ public void testImplicitGrantSendAuthRequestPost() throws Exception { urlParameters.add(new BasicNameValuePair(OAUTH2_REDIRECT_URI, CALLBACK_URL)); urlParameters.add(new BasicNameValuePair(OAUTH2_SCOPE, requestedScopes)); - HttpResponse response = sendPostRequestWithParameters(client, urlParameters, AUTHORIZE_ENDPOINT_URL); + HttpResponse response = sendPostRequestWithParameters(client, urlParameters, + getTenantQualifiedURL(AUTHORIZE_ENDPOINT_URL, tenantDomain)); Assert.assertNotNull(response, "Authorization request failed. Authorized response is null"); String locationValue = getLocationHeaderValue(response); @@ -420,7 +425,7 @@ public void testImplicitGrantSendApprovalPost() throws Exception { // Test whether all requested scopes were returned. String introspectionUrl = getIntrospectionUrl(tenantDomain); org.json.simple.JSONObject introspectionResponse = - introspectTokenWithTenant(client, accessToken, introspectionUrl, adminUsername, adminPassword); + introspectTokenWithTenant(client, accessToken, introspectionUrl, adminUsernameWithoutTenantDomain, adminPassword); Assert.assertTrue(introspectionResponse.containsKey("scope")); String scope = introspectionResponse.get("scope").toString(); Scope returnedScope = Scope.parse(scope); @@ -445,7 +450,7 @@ public void testResourceOwnerGrantSendAuthRequestPost() throws Exception { ClientAuthentication clientAuth = new ClientSecretBasic(clientID, clientSecret); Scope requestedScope = Scope.parse(requestedScopes); - URI tokenEndpoint = new URI(ACCESS_TOKEN_ENDPOINT); + URI tokenEndpoint = new URI(getTenantQualifiedURL(ACCESS_TOKEN_ENDPOINT, tenantDomain)); TokenRequest request = new TokenRequest(tokenEndpoint, clientAuth, passwordGrant, requestedScope); @@ -530,14 +535,15 @@ private String getOIDCSCopeEndpoint(String tenantDomain) { private String getAccessTokenToCallAPI(String... scopes) throws Exception { Secret adminSecret = new Secret(this.adminPassword); - AuthorizationGrant passwordGrant = new ResourceOwnerPasswordCredentialsGrant(adminUsername, adminSecret); + AuthorizationGrant passwordGrant = new ResourceOwnerPasswordCredentialsGrant(adminUsernameWithoutTenantDomain + , adminSecret); ClientID clientID = new ClientID(consumerKey); Secret clientSecret = new Secret(consumerSecret); ClientAuthentication clientAuth = new ClientSecretBasic(clientID, clientSecret); Scope requestedScope = Scope.parse(Arrays.asList(scopes)); - URI tokenEndpoint = new URI(ACCESS_TOKEN_ENDPOINT); + URI tokenEndpoint = new URI(getTenantQualifiedURL(ACCESS_TOKEN_ENDPOINT, tenantDomain)); TokenRequest request = new TokenRequest(tokenEndpoint, clientAuth, passwordGrant, requestedScope); HTTPResponse tokenHTTPResp = request.toHTTPRequest().send(); diff --git a/modules/integration/tests-integration/tests-backend/src/test/java/org/wso2/identity/integration/test/oauth2/OIDCMetadataTest.java b/modules/integration/tests-integration/tests-backend/src/test/java/org/wso2/identity/integration/test/oauth2/OIDCMetadataTest.java index 40a6ac22198..ae75bf11e50 100644 --- a/modules/integration/tests-integration/tests-backend/src/test/java/org/wso2/identity/integration/test/oauth2/OIDCMetadataTest.java +++ b/modules/integration/tests-integration/tests-backend/src/test/java/org/wso2/identity/integration/test/oauth2/OIDCMetadataTest.java @@ -44,41 +44,43 @@ public class OIDCMetadataTest extends ISIntegrationTest { private static final String TOKEN_ENDPOINT_TENANT = "https://localhost:9853/t/wso2.com/oauth2/token/.well-known/openid-configuration"; private static final String TOKEN_ENDPOINT_WITH_SUPER_TENANT_AS_PATH_PARAM = - "https://localhost:9853/t/carbon.super/oauth2/token/.well-known/openid-configuration"; + "https://localhost:9853/oauth2/token/.well-known/openid-configuration"; private static final String OIDCDISCOVERY_ENDPOINT_SUPER_TENANT = "https://localhost:9853/oauth2/oidcdiscovery/.well-known/openid-configuration"; private static final String OIDCDISCOVERY_ENDPOINT_TENANT = "https://localhost:9853/t/wso2.com/oauth2/oidcdiscovery/.well-known/openid-configuration"; private static final String OIDCDISCOVERY_ENDPOINT_WITH_SUPER_TENANT_AS_PATH_PARAM = - "https://localhost:9853/t/carbon.super/oauth2/oidcdiscovery/.well-known/openid-configuration"; + "https://localhost:9853/oauth2/oidcdiscovery/.well-known/openid-configuration"; private static final String INTROSPECTION_ENDPOINT_SUPER_TENANT = "https://localhost:9853/oauth2/introspect"; private static final String INTROSPECTION_ENDPOINT_TENANT = "https://localhost:9853/t/wso2.com/oauth2/introspect"; - private static final String CHECK_SESSION_IFRAME = "https://localhost:9853/oidc/checksession"; - private static final String ISSUER = "https://localhost:9853/oauth2/token"; - private static final String AUTHORIZATION_ENDPOINT = "https://localhost:9853/oauth2/authorize"; - private static final String TOKEN_ENDPOINT = "https://localhost:9853/oauth2/token"; - private static final String END_SESSION_ENDPOINT = "https://localhost:9853/oidc/logout"; - private static final String REVOCATION_ENDPOINT = "https://localhost:9853/oauth2/revoke"; - private static final String USERINFO_ENDPOINT = "https://localhost:9853/oauth2/userinfo"; + private static final String CHECK_SESSION_IFRAME = "/oidc/checksession"; + private static final String ISSUER = "/oauth2/token"; + private static final String AUTHORIZATION_ENDPOINT = "/oauth2/authorize"; + private static final String TOKEN_ENDPOINT = "/oauth2/token"; + private static final String END_SESSION_ENDPOINT = "/oidc/logout"; + private static final String REVOCATION_ENDPOINT = "/oauth2/revoke"; + private static final String USERINFO_ENDPOINT = "/oauth2/userinfo"; private static final String JKWS_URI_SUPER_TENANT = "https://localhost:9853/oauth2/jwks"; private static final String JKWS_URI_TENANT = "https://localhost:9853/t/wso2.com/oauth2/jwks"; private static final String REGISTRATION_ENDPOINT_SUPER_TENANT = "https://localhost:9853/api/identity/oauth2/dcr/v1.1/register"; private static final String REGISTRATION_ENDPOINT_TENANT = "https://localhost:9853/t/wso2.com/api/identity/oauth2/dcr/v1.1/register"; + private static final String BASE_IS_URL = "https://localhost:9853"; + private static final String TENANTED_BASE_IS_URL = "https://localhost:9853/t/wso2.com"; @Test(groups = "wso2.is", description = "This test method will test OIDC Metadata endpoints.") public void getOIDCMetadata() throws Exception { - testResponseContent(TOKEN_ENDPOINT_SUPER_TENANT); - testResponseContent(TOKEN_ENDPOINT_TENANT); - testResponseContent(TOKEN_ENDPOINT_WITH_SUPER_TENANT_AS_PATH_PARAM); - testResponseContent(OIDCDISCOVERY_ENDPOINT_SUPER_TENANT); - testResponseContent(OIDCDISCOVERY_ENDPOINT_TENANT); - testResponseContent(OIDCDISCOVERY_ENDPOINT_WITH_SUPER_TENANT_AS_PATH_PARAM); + testResponseContent(TOKEN_ENDPOINT_SUPER_TENANT, BASE_IS_URL); + testResponseContent(TOKEN_ENDPOINT_TENANT, TENANTED_BASE_IS_URL); + testResponseContent(TOKEN_ENDPOINT_WITH_SUPER_TENANT_AS_PATH_PARAM, BASE_IS_URL); + testResponseContent(OIDCDISCOVERY_ENDPOINT_SUPER_TENANT, BASE_IS_URL); + testResponseContent(OIDCDISCOVERY_ENDPOINT_TENANT, TENANTED_BASE_IS_URL); + testResponseContent(OIDCDISCOVERY_ENDPOINT_WITH_SUPER_TENANT_AS_PATH_PARAM, BASE_IS_URL); } - private void testResponseContent(String oidcMetadataEndpoint) throws IOException, JSONException { + private void testResponseContent(String oidcMetadataEndpoint, String baseUrl) throws IOException, JSONException { Lookup cookieSpecRegistry = RegistryBuilder.create() .register(CookieSpecs.DEFAULT, new RFC6265CookieSpecProvider()) @@ -96,19 +98,19 @@ private void testResponseContent(String oidcMetadataEndpoint) throws IOException JSONObject oidcMetadataEndpoints = new JSONObject(content); Assert.assertEquals(oidcMetadataEndpoints.getString("check_session_iframe"), - CHECK_SESSION_IFRAME, "Incorrect session iframe"); + baseUrl + CHECK_SESSION_IFRAME, "Incorrect session iframe"); Assert.assertEquals(oidcMetadataEndpoints.getString("issuer"), - ISSUER, "Incorrect issuer"); + baseUrl + ISSUER, "Incorrect issuer"); Assert.assertEquals(oidcMetadataEndpoints.getString("authorization_endpoint"), - AUTHORIZATION_ENDPOINT, "Incorrect authorization endpoint"); + baseUrl + AUTHORIZATION_ENDPOINT, "Incorrect authorization endpoint"); Assert.assertEquals(oidcMetadataEndpoints.getString("token_endpoint"), - TOKEN_ENDPOINT, "Incorrect token_endpoint"); + baseUrl + TOKEN_ENDPOINT, "Incorrect token_endpoint"); Assert.assertEquals(oidcMetadataEndpoints.getString("end_session_endpoint"), - END_SESSION_ENDPOINT, "Incorrect end session endpoint"); + baseUrl + END_SESSION_ENDPOINT, "Incorrect end session endpoint"); Assert.assertEquals(oidcMetadataEndpoints.getString("revocation_endpoint"), - REVOCATION_ENDPOINT, "Incorrect revocation endpoint"); + baseUrl + REVOCATION_ENDPOINT, "Incorrect revocation endpoint"); Assert.assertEquals(oidcMetadataEndpoints.getString("userinfo_endpoint"), - USERINFO_ENDPOINT, "Incorrect userinfo endpoint"); + baseUrl + USERINFO_ENDPOINT, "Incorrect userinfo endpoint"); if (oidcMetadataEndpoint.equals(TOKEN_ENDPOINT_SUPER_TENANT) || oidcMetadataEndpoint.equals(OIDCDISCOVERY_ENDPOINT_SUPER_TENANT) || From 78870a2e26a02dfde5ee3258198111c8d6667f5e Mon Sep 17 00:00:00 2001 From: Thisara-Welmilla Date: Tue, 17 Oct 2023 10:32:51 +0530 Subject: [PATCH 12/16] Fix failing integration tests when tenant qualified urls enabled --- .../oidc/OIDCAbstractIntegrationTest.java | 3 ++- .../test/oidc/OIDCSubAttributeTestCase.java | 3 +-- .../integration/test/oidc/OIDCUtilTest.java | 7 ++++++- .../test/saml/SAMLMetadataTestCase.java | 19 +++++++++++-------- .../test/saml/SAMLQueryProfileTestCase.java | 10 ++++++---- 5 files changed, 26 insertions(+), 16 deletions(-) diff --git a/modules/integration/tests-integration/tests-backend/src/test/java/org/wso2/identity/integration/test/oidc/OIDCAbstractIntegrationTest.java b/modules/integration/tests-integration/tests-backend/src/test/java/org/wso2/identity/integration/test/oidc/OIDCAbstractIntegrationTest.java index d0308bc31f5..14f5c8a2c63 100644 --- a/modules/integration/tests-integration/tests-backend/src/test/java/org/wso2/identity/integration/test/oidc/OIDCAbstractIntegrationTest.java +++ b/modules/integration/tests-integration/tests-backend/src/test/java/org/wso2/identity/integration/test/oidc/OIDCAbstractIntegrationTest.java @@ -186,7 +186,8 @@ public void testSendAuthenticationRequest(OIDCApplication application, boolean i HttpClient client, CookieStore cookieStore) throws Exception { - List urlParameters = OIDCUtilTest.getNameValuePairs(application); + List urlParameters = OIDCUtilTest.getNameValuePairs(application, + getTenantQualifiedURL(OAuth2Constant.APPROVAL_URL, tenantInfo.getDomain())); HttpResponse response = sendPostRequestWithParameters(client, urlParameters, String.format (OIDCUtilTest.targetApplicationUrl, application.getApplicationContext() + OAuth2Constant.PlaygroundAppPaths diff --git a/modules/integration/tests-integration/tests-backend/src/test/java/org/wso2/identity/integration/test/oidc/OIDCSubAttributeTestCase.java b/modules/integration/tests-integration/tests-backend/src/test/java/org/wso2/identity/integration/test/oidc/OIDCSubAttributeTestCase.java index 1513093f031..975235d1010 100644 --- a/modules/integration/tests-integration/tests-backend/src/test/java/org/wso2/identity/integration/test/oidc/OIDCSubAttributeTestCase.java +++ b/modules/integration/tests-integration/tests-backend/src/test/java/org/wso2/identity/integration/test/oidc/OIDCSubAttributeTestCase.java @@ -314,9 +314,8 @@ public void testResourceOwnerGrantSendAuthRequestPost() throws Exception { .disableRedirectHandling() .build(); - String username = userInfo.getUserName(); Secret password = new Secret(userInfo.getPassword()); - AuthorizationGrant passwordGrant = new ResourceOwnerPasswordCredentialsGrant(username, password); + AuthorizationGrant passwordGrant = new ResourceOwnerPasswordCredentialsGrant(tenantAwareUsername, password); ClientID clientID = new ClientID(consumerKey); Secret clientSecret = new Secret(consumerSecret); diff --git a/modules/integration/tests-integration/tests-backend/src/test/java/org/wso2/identity/integration/test/oidc/OIDCUtilTest.java b/modules/integration/tests-integration/tests-backend/src/test/java/org/wso2/identity/integration/test/oidc/OIDCUtilTest.java index ae1775a4d70..5b048856f05 100644 --- a/modules/integration/tests-integration/tests-backend/src/test/java/org/wso2/identity/integration/test/oidc/OIDCUtilTest.java +++ b/modules/integration/tests-integration/tests-backend/src/test/java/org/wso2/identity/integration/test/oidc/OIDCUtilTest.java @@ -109,11 +109,16 @@ public static void initApplications() { */ public static List getNameValuePairs(OIDCApplication application) { + return getNameValuePairs(application, OAuth2Constant.APPROVAL_URL); + } + + public static List getNameValuePairs(OIDCApplication application, String approvalUrl) { + List urlParameters = new ArrayList<>(); urlParameters.add(new BasicNameValuePair("grantType", OAuth2Constant.OAUTH2_GRANT_TYPE_CODE)); urlParameters.add(new BasicNameValuePair("consumerKey", application.getClientId())); urlParameters.add(new BasicNameValuePair("callbackurl", application.getCallBackURL())); - urlParameters.add(new BasicNameValuePair("authorizeEndpoint", OAuth2Constant.APPROVAL_URL)); + urlParameters.add(new BasicNameValuePair("authorizeEndpoint", approvalUrl)); urlParameters.add(new BasicNameValuePair("authorize", OAuth2Constant.AUTHORIZE_PARAM)); urlParameters.add(new BasicNameValuePair("scope", OAuth2Constant.OAUTH2_SCOPE_OPENID + " " + OAuth2Constant.OAUTH2_SCOPE_EMAIL + " " + OAuth2Constant.OAUTH2_SCOPE_PROFILE)); diff --git a/modules/integration/tests-integration/tests-backend/src/test/java/org/wso2/identity/integration/test/saml/SAMLMetadataTestCase.java b/modules/integration/tests-integration/tests-backend/src/test/java/org/wso2/identity/integration/test/saml/SAMLMetadataTestCase.java index 808a92f2f70..4025a4ab0ba 100644 --- a/modules/integration/tests-integration/tests-backend/src/test/java/org/wso2/identity/integration/test/saml/SAMLMetadataTestCase.java +++ b/modules/integration/tests-integration/tests-backend/src/test/java/org/wso2/identity/integration/test/saml/SAMLMetadataTestCase.java @@ -40,20 +40,23 @@ public class SAMLMetadataTestCase extends ISIntegrationTest { private static final String SAML_METADATA_ENDPOINT_TENANT = "https://localhost:9853/t/wso2.com/identity/metadata/saml2"; private static final String SAML_METADATA_ENDPOINT_WITH_SUPER_TENANT_AS_PATH_PARAM = - "https://localhost:9853/t/carbon.super/identity/metadata/saml2"; + "https://localhost:9853/identity/metadata/saml2"; private static final String SAML_SSO_ENDPOINT_TENANT = "https://localhost:9853/t/wso2.com/samlsso"; private static final String SAML_SSO_ENDPOINT_SUPER_TENANT = "https://localhost:9853/samlsso"; private static final String SAMLARTRESOLVE_ENDPOINT = "https://localhost:9853/samlartresolve"; + private static final String SAMLARTRESOLVE_ENDPOINT_TENANT = "https://localhost:9853/t/wso2.com/samlartresolve"; @Test(groups = "wso2.is", description = "This test method will test SAML Metadata endpoints.") public void getSAMLMetadata() throws IOException, JSONException { - testResponseContent(SAML_METADATA_ENDPOINT_SUPER_TENANT, SAML_SSO_ENDPOINT_SUPER_TENANT); - testResponseContent(SAML_METADATA_ENDPOINT_WITH_SUPER_TENANT_AS_PATH_PARAM, SAML_SSO_ENDPOINT_SUPER_TENANT); - testResponseContent(SAML_METADATA_ENDPOINT_TENANT, SAML_SSO_ENDPOINT_TENANT); + testResponseContent(SAML_METADATA_ENDPOINT_SUPER_TENANT, SAML_SSO_ENDPOINT_SUPER_TENANT, + SAMLARTRESOLVE_ENDPOINT); + testResponseContent(SAML_METADATA_ENDPOINT_WITH_SUPER_TENANT_AS_PATH_PARAM, SAML_SSO_ENDPOINT_SUPER_TENANT, + SAMLARTRESOLVE_ENDPOINT); + testResponseContent(SAML_METADATA_ENDPOINT_TENANT, SAML_SSO_ENDPOINT_TENANT, SAMLARTRESOLVE_ENDPOINT_TENANT); } - private void testResponseContent(String samlMetadataEndpoint, String samlEndpoint) + private void testResponseContent(String samlMetadataEndpoint, String samlEndpoint, String samlartresolveEndpoint) throws IOException, JSONException { HttpClient client = HttpClientBuilder.create().build(); @@ -85,9 +88,9 @@ private void testResponseContent(String samlMetadataEndpoint, String samlEndpoin JSONObject artifactResolutionService = XML.toJSONObject(content).getJSONObject("EntityDescriptor").getJSONObject( "IDPSSODescriptor").getJSONObject("ArtifactResolutionService"); - Assert.assertEquals(artifactResolutionService.getString("Location"), - SAMLARTRESOLVE_ENDPOINT, String.format("Expected location was not received for artifact resolution" + - "service for the binding %S.", artifactResolutionService.getString("Binding"))); + Assert.assertEquals(artifactResolutionService.getString("Location"), samlartresolveEndpoint, + String.format("Expected location was not received for artifact resolution service for the binding %S.", + artifactResolutionService.getString("Binding"))); } private HttpResponse sendGetRequest(HttpClient client, String samlMetadataEndpoint) throws IOException { diff --git a/modules/integration/tests-integration/tests-backend/src/test/java/org/wso2/identity/integration/test/saml/SAMLQueryProfileTestCase.java b/modules/integration/tests-integration/tests-backend/src/test/java/org/wso2/identity/integration/test/saml/SAMLQueryProfileTestCase.java index 91f8b6bde67..6a1c4e476cd 100644 --- a/modules/integration/tests-integration/tests-backend/src/test/java/org/wso2/identity/integration/test/saml/SAMLQueryProfileTestCase.java +++ b/modules/integration/tests-integration/tests-backend/src/test/java/org/wso2/identity/integration/test/saml/SAMLQueryProfileTestCase.java @@ -70,7 +70,7 @@ public class SAMLQueryProfileTestCase extends AbstractSAMLSSOTestCase { private static final String APPLICATION_NAME = "SAML-SSO-Query-TestApplication"; private static final String WSO2IS_URL = "https://localhost:9853/"; private static final String WSO2IS_TENANT_URL = WSO2IS_URL + "t/wso2.com"; - private static final String SAML_SSO_URL = WSO2IS_URL + "samlsso"; + private String tenantedSamlSSOUrl; private static final String COMMON_AUTH_URL = WSO2IS_URL + "/commonauth"; private static final String ACS_URL = "http://localhost:8490/%s/home.jsp"; private static final String SAML_SSO_LOGIN_URL = "http://localhost:8490/%s/samlsso?SAML2.HTTPBinding=%s"; @@ -99,6 +99,7 @@ public SAMLQueryProfileTestCase(SAMLConfig config) { public void initiateTenant() throws Exception { // Since all the requests sign with default wso2 key, upload that public key to tenants super.init(TestUserMode.TENANT_ADMIN); + tenantedSamlSSOUrl = getTenantQualifiedURL(WSO2IS_URL + "samlsso", config.getUser().getTenantDomain()); KeystoreMgtRestClient keystoreMgtRestClient = new KeystoreMgtRestClient(serverURL, tenantInfo); if (!keystoreMgtRestClient.checkCertInStore(KEYSTORE_ALIAS)) { @@ -187,7 +188,7 @@ public void testSAMLSSOLogin() { if (config.getHttpBinding() == AbstractSAMLSSOTestCase.HttpBinding.HTTP_POST){ String samlRequest = Utils.extractDataFromResponse(response, CommonConstants.SAML_REQUEST_PARAM, 5); - response = super.sendSAMLMessage(SAML_SSO_URL, CommonConstants.SAML_REQUEST_PARAM, samlRequest, config); + response = super.sendSAMLMessage(tenantedSamlSSOUrl, CommonConstants.SAML_REQUEST_PARAM, samlRequest, config); EntityUtils.consume(response.getEntity()); response = Utils.sendRedirectRequest(response, USER_AGENT, ACS_URL, config.getApp().getArtifact(), @@ -195,8 +196,9 @@ public void testSAMLSSOLogin() { } String sessionKey = Utils.extractDataFromResponse(response, CommonConstants.SESSION_DATA_KEY, 1); - response = Utils.sendPOSTMessage(sessionKey, SAML_SSO_URL, USER_AGENT, ACS_URL, config.getApp() - .getArtifact(), config.getUser().getUsername(), config.getUser().getPassword(), httpClient); + response = Utils.sendPOSTMessage(sessionKey, tenantedSamlSSOUrl, USER_AGENT, ACS_URL, config.getApp() + .getArtifact(), config.getUser().getUsername(), config.getUser().getPassword(), httpClient, + tenantedSamlSSOUrl); if (requestMissingClaims(response)) { From 095ca5feb7ddc2f8780b28538c4c76ffd47c1ace Mon Sep 17 00:00:00 2001 From: Thisara-Welmilla Date: Wed, 18 Oct 2023 11:28:40 +0530 Subject: [PATCH 13/16] Fix failing integration tests when tenant qualified urls enabled --- .../integration/test/oauth2/OIDCCustomScopesLoginTest.java | 2 +- .../test/oidc/OIDCIdentityFederationTestCase.java | 2 +- .../identity/integration/test/openid/OpenIDSSOTestCase.java | 3 ++- .../authorized/apps/v1/MeAuthorizedAppsSuccessTest.java | 4 ++++ .../apps/v2/ApplicationAuthorizedAppsSuccessTest.java | 6 +++++- .../authorized/apps/v2/MeAuthorizedAppsSuccessTest.java | 6 +++++- 6 files changed, 18 insertions(+), 5 deletions(-) diff --git a/modules/integration/tests-integration/tests-backend/src/test/java/org/wso2/identity/integration/test/oauth2/OIDCCustomScopesLoginTest.java b/modules/integration/tests-integration/tests-backend/src/test/java/org/wso2/identity/integration/test/oauth2/OIDCCustomScopesLoginTest.java index 9725d966103..2be69b772f3 100644 --- a/modules/integration/tests-integration/tests-backend/src/test/java/org/wso2/identity/integration/test/oauth2/OIDCCustomScopesLoginTest.java +++ b/modules/integration/tests-integration/tests-backend/src/test/java/org/wso2/identity/integration/test/oauth2/OIDCCustomScopesLoginTest.java @@ -425,7 +425,7 @@ public void testImplicitGrantSendApprovalPost() throws Exception { // Test whether all requested scopes were returned. String introspectionUrl = getIntrospectionUrl(tenantDomain); org.json.simple.JSONObject introspectionResponse = - introspectTokenWithTenant(client, accessToken, introspectionUrl, adminUsernameWithoutTenantDomain, adminPassword); + introspectTokenWithTenant(client, accessToken, introspectionUrl, adminUsername, adminPassword); Assert.assertTrue(introspectionResponse.containsKey("scope")); String scope = introspectionResponse.get("scope").toString(); Scope returnedScope = Scope.parse(scope); diff --git a/modules/integration/tests-integration/tests-backend/src/test/java/org/wso2/identity/integration/test/oidc/OIDCIdentityFederationTestCase.java b/modules/integration/tests-integration/tests-backend/src/test/java/org/wso2/identity/integration/test/oidc/OIDCIdentityFederationTestCase.java index 4c2fafb140e..dda46d67c87 100644 --- a/modules/integration/tests-integration/tests-backend/src/test/java/org/wso2/identity/integration/test/oidc/OIDCIdentityFederationTestCase.java +++ b/modules/integration/tests-integration/tests-backend/src/test/java/org/wso2/identity/integration/test/oidc/OIDCIdentityFederationTestCase.java @@ -447,7 +447,7 @@ private String doAuthenticationInSecondaryIS(String sessionDataKey) throws Excep private HttpResponse sendLoginPost(HttpClient client, String sessionDataKey) throws IOException { List urlParameters = new ArrayList<>(); - urlParameters.add(new BasicNameValuePair("username", SECONDARY_IS_TEST_USERNAME)); + urlParameters.add(new BasicNameValuePair("username", SECONDARY_IS_TEST_USERNAME + "@" + tenantInfo.getDomain())); urlParameters.add(new BasicNameValuePair("password", SECONDARY_IS_TEST_PASSWORD)); urlParameters.add(new BasicNameValuePair("sessionDataKey", sessionDataKey)); diff --git a/modules/integration/tests-integration/tests-backend/src/test/java/org/wso2/identity/integration/test/openid/OpenIDSSOTestCase.java b/modules/integration/tests-integration/tests-backend/src/test/java/org/wso2/identity/integration/test/openid/OpenIDSSOTestCase.java index 2bc34f5986f..51bce7c5df1 100644 --- a/modules/integration/tests-integration/tests-backend/src/test/java/org/wso2/identity/integration/test/openid/OpenIDSSOTestCase.java +++ b/modules/integration/tests-integration/tests-backend/src/test/java/org/wso2/identity/integration/test/openid/OpenIDSSOTestCase.java @@ -321,7 +321,7 @@ private HttpResponse sendLoginPost(String sessionKey) throws IOException { request.setHeader("User-Agent", USER_AGENT); List urlParameters = new ArrayList(); - urlParameters.add(new BasicNameValuePair("username", config.getUser().getUsername())); + urlParameters.add(new BasicNameValuePair("username", config.getUser().getUsername() + "@" + tenantInfo.getDomain())); urlParameters.add(new BasicNameValuePair("password", config.getUser().getPassword())); urlParameters.add(new BasicNameValuePair("sessionDataKey", sessionKey)); @@ -339,6 +339,7 @@ private HttpResponse sendRedirectGet(HttpResponse response) throws IOException { } } + url = StringUtils.replace(url, "/t/" + tenantInfo.getDomain(), ""); HttpGet request = new HttpGet(url); request.addHeader("User-Agent", USER_AGENT); diff --git a/modules/integration/tests-integration/tests-backend/src/test/java/org/wso2/identity/integration/test/rest/api/user/authorized/apps/v1/MeAuthorizedAppsSuccessTest.java b/modules/integration/tests-integration/tests-backend/src/test/java/org/wso2/identity/integration/test/rest/api/user/authorized/apps/v1/MeAuthorizedAppsSuccessTest.java index 1819fd67e9b..e2b24e5188e 100644 --- a/modules/integration/tests-integration/tests-backend/src/test/java/org/wso2/identity/integration/test/rest/api/user/authorized/apps/v1/MeAuthorizedAppsSuccessTest.java +++ b/modules/integration/tests-integration/tests-backend/src/test/java/org/wso2/identity/integration/test/rest/api/user/authorized/apps/v1/MeAuthorizedAppsSuccessTest.java @@ -55,8 +55,12 @@ public void init() throws XPathExpressionException, RemoteException { initUrls("me"); registerApplication(appName1, clientIdApp1, CLIENT_SECRET); registerApplication(appName2, clientIdApp2, CLIENT_SECRET); + + this.authenticatingUserName = context.getContextTenant().getTenantAdmin().getUserNameWithoutDomain(); getTokenFromPasswordGrant(clientIdApp1, CLIENT_SECRET); getTokenFromPasswordGrant(clientIdApp2, CLIENT_SECRET); + + this.authenticatingUserName = context.getContextTenant().getTenantAdmin().getUserName(); } @BeforeMethod(alwaysRun = true) diff --git a/modules/integration/tests-integration/tests-backend/src/test/java/org/wso2/identity/integration/test/rest/api/user/authorized/apps/v2/ApplicationAuthorizedAppsSuccessTest.java b/modules/integration/tests-integration/tests-backend/src/test/java/org/wso2/identity/integration/test/rest/api/user/authorized/apps/v2/ApplicationAuthorizedAppsSuccessTest.java index c463fa5c771..a6f01a9e6e9 100644 --- a/modules/integration/tests-integration/tests-backend/src/test/java/org/wso2/identity/integration/test/rest/api/user/authorized/apps/v2/ApplicationAuthorizedAppsSuccessTest.java +++ b/modules/integration/tests-integration/tests-backend/src/test/java/org/wso2/identity/integration/test/rest/api/user/authorized/apps/v2/ApplicationAuthorizedAppsSuccessTest.java @@ -57,7 +57,11 @@ public void init() throws XPathExpressionException, RemoteException { super.testInit(API_VERSION, swaggerDefinition, tenant); initUrls("me"); registerApplication(appName1, clientIdApp1, CLIENT_SECRET); + + this.authenticatingUserName = context.getContextTenant().getTenantAdmin().getUserNameWithoutDomain(); getTokenFromPasswordGrant(clientIdApp1, CLIENT_SECRET); + + this.authenticatingUserName = context.getContextTenant().getTenantAdmin().getUserName(); } @BeforeMethod(alwaysRun = true) @@ -86,7 +90,7 @@ public ApplicationAuthorizedAppsSuccessTest(TestUserMode userMode) throws Except super.init(userMode); this.context = isServer; - this.authenticatingUserName = context.getContextTenant().getTenantAdmin().getUserNameWithoutDomain(); + this.authenticatingUserName = context.getContextTenant().getTenantAdmin().getUserName(); this.authenticatingCredential = context.getContextTenant().getTenantAdmin().getPassword(); this.tenant = context.getContextTenant().getDomain(); diff --git a/modules/integration/tests-integration/tests-backend/src/test/java/org/wso2/identity/integration/test/rest/api/user/authorized/apps/v2/MeAuthorizedAppsSuccessTest.java b/modules/integration/tests-integration/tests-backend/src/test/java/org/wso2/identity/integration/test/rest/api/user/authorized/apps/v2/MeAuthorizedAppsSuccessTest.java index 7f7c93d7cb1..d72114f9782 100644 --- a/modules/integration/tests-integration/tests-backend/src/test/java/org/wso2/identity/integration/test/rest/api/user/authorized/apps/v2/MeAuthorizedAppsSuccessTest.java +++ b/modules/integration/tests-integration/tests-backend/src/test/java/org/wso2/identity/integration/test/rest/api/user/authorized/apps/v2/MeAuthorizedAppsSuccessTest.java @@ -59,8 +59,12 @@ public void init() throws XPathExpressionException, RemoteException { initUrls("me"); registerApplication(appName1, clientIdApp1, CLIENT_SECRET); registerApplication(appName2, clientIdApp2, CLIENT_SECRET); + + this.authenticatingUserName = context.getContextTenant().getTenantAdmin().getUserNameWithoutDomain(); getTokenFromPasswordGrant(clientIdApp1, CLIENT_SECRET); getTokenFromPasswordGrant(clientIdApp2, CLIENT_SECRET); + + this.authenticatingUserName = context.getContextTenant().getTenantAdmin().getUserName(); } @BeforeMethod(alwaysRun = true) @@ -90,7 +94,7 @@ public MeAuthorizedAppsSuccessTest(TestUserMode userMode) throws Exception { super.init(userMode); this.context = isServer; - this.authenticatingUserName = context.getContextTenant().getTenantAdmin().getUserNameWithoutDomain(); + this.authenticatingUserName = context.getContextTenant().getTenantAdmin().getUserName(); this.authenticatingCredential = context.getContextTenant().getTenantAdmin().getPassword(); this.tenant = context.getContextTenant().getDomain(); From 162efa6750147ade8d6a165e64905f4da02dee47 Mon Sep 17 00:00:00 2001 From: Thisara-Welmilla Date: Wed, 18 Oct 2023 19:21:45 +0530 Subject: [PATCH 14/16] Fix failing integration tests when tenant qualified urls enabled --- .../tests-integration/tests-backend/pom.xml | 1 + .../test/base/TomcatInitializerTestCase.java | 1 + .../oidc/OIDCFederatedIdpInitLogoutTest.java | 8 +- .../test/saml/AbstractSAMLSSOTestCase.java | 1 + .../saml/SAMLIdPInitiatedSLOTestCase.java | 10 +- .../test/saml/SAMLQueryProfileTestCase.java | 2 +- .../IS/saml/supertenant-saml-app-build.xml | 52 ++++++++ .../travelocity.properties | 112 ++++++++++++++++++ 8 files changed, 177 insertions(+), 10 deletions(-) create mode 100644 modules/integration/tests-integration/tests-backend/src/test/resources/artifacts/IS/saml/supertenant-saml-app-build.xml create mode 100644 modules/integration/tests-integration/tests-backend/src/test/resources/artifacts/IS/saml/supertenantwithoutsigning/travelocity.properties diff --git a/modules/integration/tests-integration/tests-backend/pom.xml b/modules/integration/tests-integration/tests-backend/pom.xml index 79d5210007f..48f0ef4c150 100644 --- a/modules/integration/tests-integration/tests-backend/pom.xml +++ b/modules/integration/tests-integration/tests-backend/pom.xml @@ -499,6 +499,7 @@ + diff --git a/modules/integration/tests-integration/tests-backend/src/test/java/org/wso2/identity/integration/test/base/TomcatInitializerTestCase.java b/modules/integration/tests-integration/tests-backend/src/test/java/org/wso2/identity/integration/test/base/TomcatInitializerTestCase.java index 14994aea722..a51b660a1f3 100644 --- a/modules/integration/tests-integration/tests-backend/src/test/java/org/wso2/identity/integration/test/base/TomcatInitializerTestCase.java +++ b/modules/integration/tests-integration/tests-backend/src/test/java/org/wso2/identity/integration/test/base/TomcatInitializerTestCase.java @@ -38,6 +38,7 @@ public class TomcatInitializerTestCase extends ISIntegrationTest { private static final String[] APPLICATIONS = { "travelocity.com", + "travelocity.com-saml-supertenantwithoutsigning", "travelocity.com-saml-tenantwithoutsigning", "travelocity.com-registrymount", "avis.com", diff --git a/modules/integration/tests-integration/tests-backend/src/test/java/org/wso2/identity/integration/test/oidc/OIDCFederatedIdpInitLogoutTest.java b/modules/integration/tests-integration/tests-backend/src/test/java/org/wso2/identity/integration/test/oidc/OIDCFederatedIdpInitLogoutTest.java index 7492bcc49c8..d4182006bf3 100644 --- a/modules/integration/tests-integration/tests-backend/src/test/java/org/wso2/identity/integration/test/oidc/OIDCFederatedIdpInitLogoutTest.java +++ b/modules/integration/tests-integration/tests-backend/src/test/java/org/wso2/identity/integration/test/oidc/OIDCFederatedIdpInitLogoutTest.java @@ -102,7 +102,7 @@ public class OIDCFederatedIdpInitLogoutTest extends AbstractIdentityFederationTe private static final String SAML_SSO_LOGIN_URL = "http://localhost:8490/%s/samlsso?SAML2.HTTPBinding=%s"; private static final String FEDERATED_SAML_SSO_URL = - "http://localhost:8490/travelocity.com-saml-tenantwithoutsigning/samlsso?SAML2.HTTPBinding=HTTP-Redirect"; + "http://localhost:8490/travelocity.com-saml-supertenantwithoutsigning/samlsso?SAML2.HTTPBinding=HTTP-Redirect"; private static final String PRIMARY_SAML_SSO_URL = "http://localhost:8490/travelocity.com/samlsso?SAML2.HTTPBinding=HTTP-Redirect"; @@ -117,10 +117,10 @@ public class OIDCFederatedIdpInitLogoutTest extends AbstractIdentityFederationTe private static final String PRIMARY_IS_SAML_NAME_ID_FORMAT = "urn:oasis:names:tc:SAML:1.1:nameid-format:emailAddress"; - private static final String FEDERATED_IS_SP_NAME = "travelocity.com-saml-tenantwithoutsigning"; - private static final String FEDERATED_IS_SAML_ISSUER_NAME = "travelocity.com-saml-tenantwithoutsigning"; + private static final String FEDERATED_IS_SP_NAME = "travelocity.com-saml-supertenantwithoutsigning"; + private static final String FEDERATED_IS_SAML_ISSUER_NAME = "travelocity.com-saml-supertenantwithoutsigning"; private static final String FEDERATED_IS_SAML_ACS_URL = - "http://localhost:8490/travelocity.com-saml-tenantwithoutsigning/home.jsp"; + "http://localhost:8490/travelocity.com-saml-supertenantwithoutsigning/home.jsp"; private static final String PRIMARY_IS_IDP_NAME = "trustedIdP"; private static final String PRIMARY_IS_IDP_AUTHENTICATOR_NAME_OIDC = "OpenIDConnectAuthenticator"; diff --git a/modules/integration/tests-integration/tests-backend/src/test/java/org/wso2/identity/integration/test/saml/AbstractSAMLSSOTestCase.java b/modules/integration/tests-integration/tests-backend/src/test/java/org/wso2/identity/integration/test/saml/AbstractSAMLSSOTestCase.java index fde73f3e236..be89b44701c 100644 --- a/modules/integration/tests-integration/tests-backend/src/test/java/org/wso2/identity/integration/test/saml/AbstractSAMLSSOTestCase.java +++ b/modules/integration/tests-integration/tests-backend/src/test/java/org/wso2/identity/integration/test/saml/AbstractSAMLSSOTestCase.java @@ -204,6 +204,7 @@ protected enum App { SUPER_TENANT_APP_WITH_SIGNING("travelocity.com", true), TENANT_APP_WITHOUT_SIGNING("travelocity.com-saml-tenantwithoutsigning", false), + SUPER_TENANT_APP_WITHOUT_SIGNING("travelocity.com-saml-supergtenantwithoutsigning", false), SUPER_TENANT_APP_WITH_SAMLARTIFACT_CONFIG("travelocity.com-saml-artifactresolving", false), TENANT_APP_WITH_SAMLARTIFACT_CONFIG("travelocity.com-saml-tenant-artifactresolving", false), ECP_APP("https://localhost/ecp-sp", false); diff --git a/modules/integration/tests-integration/tests-backend/src/test/java/org/wso2/identity/integration/test/saml/SAMLIdPInitiatedSLOTestCase.java b/modules/integration/tests-integration/tests-backend/src/test/java/org/wso2/identity/integration/test/saml/SAMLIdPInitiatedSLOTestCase.java index 5c46b6092de..b11b8e56874 100644 --- a/modules/integration/tests-integration/tests-backend/src/test/java/org/wso2/identity/integration/test/saml/SAMLIdPInitiatedSLOTestCase.java +++ b/modules/integration/tests-integration/tests-backend/src/test/java/org/wso2/identity/integration/test/saml/SAMLIdPInitiatedSLOTestCase.java @@ -54,7 +54,7 @@ public class SAMLIdPInitiatedSLOTestCase extends AbstractSAMLSSOTestCase { private static final String APPLICATION_ONE = "SAML-TestApplication-01"; private static final String APPLICATION_TWO = "SAML-TestApplication-02"; private static final String SAML_APP_ONE_ACS_URL = "http://localhost:8490/travelocity.com/home.jsp"; - private static final String SAML_APP_TWO_ACS_URL = "http://localhost:8490/travelocity.com-saml-tenantwithoutsigning/home.jsp"; + private static final String SAML_APP_TWO_ACS_URL = "http://localhost:8490/travelocity.com-saml-supertenantwithoutsigning/home.jsp"; private final SAMLConfig samlConfigOne; private final SAMLConfig samlConfigTwo; @@ -85,7 +85,7 @@ public static SAMLConfig[][] samlConfigProvider() { {new SAMLConfig(TestUserMode.SUPER_TENANT_ADMIN, User.SUPER_TENANT_USER, HttpBinding.HTTP_POST, ClaimType.LOCAL, App.SUPER_TENANT_APP_WITH_SIGNING), new SAMLConfig(TestUserMode.SUPER_TENANT_ADMIN, User.SUPER_TENANT_USER, HttpBinding.HTTP_POST, - ClaimType.LOCAL, App.TENANT_APP_WITHOUT_SIGNING)}, + ClaimType.LOCAL, App.SUPER_TENANT_APP_WITHOUT_SIGNING)}, }; } @@ -224,7 +224,7 @@ public void testSAMLIdpInitiatedSLO() throws Exception { boolean requestTwoSentLogFound = checkForLog(logViewer, "single logout request is sent to : " + SAML_APP_TWO_ACS_URL + " is returned with OK"); Assert.assertTrue(requestTwoSentLogFound, "System Log not found. Single logout request is not " + - "sent to travelocity.com-saml-tenantwithoutsigning app."); + "sent to travelocity.com-saml-supertenantwithoutsigning app."); boolean responseOneReceivedLogFound = checkForLog(logViewer, "Logout response received for issuer: travelocity.com for tenant domain: carbon.super"); @@ -232,10 +232,10 @@ public void testSAMLIdpInitiatedSLO() throws Exception { "received for issuer travelocity.com"); boolean responseTwoReceivedLogFound = checkForLog(logViewer, - "Logout response received for issuer: travelocity.com-saml-tenantwithoutsigning for " + + "Logout response received for issuer: travelocity.com-saml-supertenantwithoutsigning for " + "tenant domain: carbon.super"); Assert.assertTrue(responseTwoReceivedLogFound, "System Log not found. Logout response is not " + - "received for issuer travelocity.com-saml-tenantwithoutsigning"); + "received for issuer travelocity.com-saml-supertenantwithoutsigning"); } catch (Exception e) { Assert.fail("SAML IdP initiated SLO test failed for " + samlConfigOne.getApp().getArtifact() + " & " + samlConfigTwo.getApp().getArtifact(), e); diff --git a/modules/integration/tests-integration/tests-backend/src/test/java/org/wso2/identity/integration/test/saml/SAMLQueryProfileTestCase.java b/modules/integration/tests-integration/tests-backend/src/test/java/org/wso2/identity/integration/test/saml/SAMLQueryProfileTestCase.java index 6a1c4e476cd..f27e0ddbae7 100644 --- a/modules/integration/tests-integration/tests-backend/src/test/java/org/wso2/identity/integration/test/saml/SAMLQueryProfileTestCase.java +++ b/modules/integration/tests-integration/tests-backend/src/test/java/org/wso2/identity/integration/test/saml/SAMLQueryProfileTestCase.java @@ -188,7 +188,7 @@ public void testSAMLSSOLogin() { if (config.getHttpBinding() == AbstractSAMLSSOTestCase.HttpBinding.HTTP_POST){ String samlRequest = Utils.extractDataFromResponse(response, CommonConstants.SAML_REQUEST_PARAM, 5); - response = super.sendSAMLMessage(tenantedSamlSSOUrl, CommonConstants.SAML_REQUEST_PARAM, samlRequest, config); + response = super.sendSAMLMessage(SAML_SSO_URL, CommonConstants.SAML_REQUEST_PARAM, samlRequest, config); EntityUtils.consume(response.getEntity()); response = Utils.sendRedirectRequest(response, USER_AGENT, ACS_URL, config.getApp().getArtifact(), diff --git a/modules/integration/tests-integration/tests-backend/src/test/resources/artifacts/IS/saml/supertenant-saml-app-build.xml b/modules/integration/tests-integration/tests-backend/src/test/resources/artifacts/IS/saml/supertenant-saml-app-build.xml new file mode 100644 index 00000000000..b0125447cdf --- /dev/null +++ b/modules/integration/tests-integration/tests-backend/src/test/resources/artifacts/IS/saml/supertenant-saml-app-build.xml @@ -0,0 +1,52 @@ + + + + + + This script builds a war file for the travelocity app for super tenant sso with signature validation disabled + + + + + + + + + + + + + + + + + + + + + + + diff --git a/modules/integration/tests-integration/tests-backend/src/test/resources/artifacts/IS/saml/supertenantwithoutsigning/travelocity.properties b/modules/integration/tests-integration/tests-backend/src/test/resources/artifacts/IS/saml/supertenantwithoutsigning/travelocity.properties new file mode 100644 index 00000000000..2b704e8b8f1 --- /dev/null +++ b/modules/integration/tests-integration/tests-backend/src/test/resources/artifacts/IS/saml/supertenantwithoutsigning/travelocity.properties @@ -0,0 +1,112 @@ +# +# Copyright (c) 2015, WSO2 Inc. (http://www.wso2.org) All Rights Reserved. +# +# WSO2 Inc. licenses this file to you under the Apache License, +# Version 2.0 (the "License"); you may not use this file except +# in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, +# software distributed under the License is distributed on an +# "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY +# KIND, either express or implied. See the License for the +# specific language governing permissions and limitations +# under the License. +# + + +EnableSAML2SSOLogin=true +EnableOpenIDLogin=true +EnableOAuth2SAML2Grant=false + +#Url to do send SAML2 SSO AuthnRequest +SAML2SSOURL=samlsso + +#Url to do initiate OAuth2 SAML2 Grant Request +OAuth2SAML2GrantURL=token + +#Url to initiate OpenID Authentication Request +OpenIdURL=openid + +#URIs to skip SSOAgentFilter; comma separated values +SkipURIs=/travelocity.com-saml-supertenantwithoutsigning/index.jsp + +#A unique identifier for this SAML 2.0 Service Provider application +SAML2.SPEntityId=travelocity.com-saml-supertenantwithoutsigning + +#The URL of the SAML 2.0 Assertion Consumer +SAML2.AssertionConsumerURL=http://localhost:8490/travelocity.com-saml-supertenantwithoutsigning/home.jsp + +#A unique identifier for this SAML 2.0 Service Provider application +SAML2.IdPEntityId=localhost + +#The URL of the SAML 2.0 Identity Provider +SAML2.IdPURL=https://localhost:9853/samlsso + +#Identifier given for the Service Provider for SAML 2.0 attributes +#exchange +#SAML2.AttributeConsumingServiceIndex=1701087467 + +#Specify if SingleLogout is enabled/disabled +SAML2.EnableSLO=true + +#This is the URL that is used for SLO +SAML2.SLOURL=logout + +#Specify if SAMLResponse element is signed +SAML2.EnableResponseSigning=false + +#Specify if SAMLAssertion element is signed +SAML2.EnableAssertionSigning=false + +#Specify if SAMLAssertion element is encrypted +SAML2.EnableAssertionEncryption=false + +#Specify if AuthnRequests and LogoutRequests should be signed +SAML2.EnableRequestSigning=true + +SAML2.ArtifactResolveUrl=https://localhost:9853/samlartresolve + +SAML2.EnableArtifactResolveSigning=true + +#Password of the KeyStore for SAML and OpenID +KeyStorePassword=wso2carbon + +#Alias of the IdP's public certificate +IdPPublicCertAlias=wso2carbon + +#Alias of the SP's private key +PrivateKeyAlias=wso2carbon + +#Private key password to retrieve the private key used to sign +#AuthnRequest and LogoutRequest messages +PrivateKeyPassword=wso2carbon + +#OAuth2 token endpoint URL +SAML2.OAuth2TokenURL=https://localhost:9853/oauth2/token + +#OAuth2 Client ID +SAML2.OAuth2ClientId=Qn5DQHCYfshxeZh6R9SL1HM2lsMa + +#OAuth2 Client Secret +SAML2.OAuth2ClientSecret=cbkAs1gajdwPAMbrSR54hPAIcz0a + +#OpenId Provider Url +OpenId.ProviderURL=https://localhost:9853/openid/ + +#openid.return_to parameter +OpenId.ReturnToURL=http://localhost:8490/travelocity.com-saml-supertenantwithoutsigning/home.jsp + +#Custom SAML post binding request page +#SAML.PostBinding.RequestPage=path/to/the/html + +#Additional request parameters +#SAML.Request.Query.Param=&forceAuth=true + +#Specify whether the consumer requests user attributes from the provider +OpenId.EnableAttributeExchange=true + +#Specify whether the consumer runs in dumb mode +OpenId.EnableDumbMode=false From bb4e94646b97a10a1def41be58ccacab5a2e47c5 Mon Sep 17 00:00:00 2001 From: Thisara-Welmilla Date: Thu, 19 Oct 2023 14:06:02 +0530 Subject: [PATCH 15/16] Update licenses --- .../artifacts/IS/saml/supertenant-saml-app-build.xml | 4 ++-- .../supertenantwithoutsigning/travelocity.properties | 12 ++++++------ 2 files changed, 8 insertions(+), 8 deletions(-) diff --git a/modules/integration/tests-integration/tests-backend/src/test/resources/artifacts/IS/saml/supertenant-saml-app-build.xml b/modules/integration/tests-integration/tests-backend/src/test/resources/artifacts/IS/saml/supertenant-saml-app-build.xml index b0125447cdf..5e17feb3cf0 100644 --- a/modules/integration/tests-integration/tests-backend/src/test/resources/artifacts/IS/saml/supertenant-saml-app-build.xml +++ b/modules/integration/tests-integration/tests-backend/src/test/resources/artifacts/IS/saml/supertenant-saml-app-build.xml @@ -1,8 +1,8 @@ - 5.25.402 + 5.25.411 [5.14.67, 6.0.0] @@ -2319,12 +2319,12 @@ - 5.11.23 + 5.11.26 6.11.147 5.9.5 - 5.10.16 + 5.10.17 5.7.4 - 3.4.26 + 3.4.27 5.6.0 @@ -2418,7 +2418,7 @@ 2.0.13 - 1.3.22 + 1.3.23 1.2.93 5.5.9