Skip to content

Commit aedf3ed

Browse files
willyborankindlin2028
authored andcommitted
Misc changes for tests (opensearch-project#4171)
Signed-off-by: Andrey Pleskach <ples@aiven.io>
1 parent a06cafe commit aedf3ed

13 files changed

+311
-148
lines changed

src/integrationTest/java/org/opensearch/security/http/AnonymousAuthenticationTest.java

+3-4
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,6 @@
1717
import org.junit.Test;
1818
import org.junit.runner.RunWith;
1919

20-
import org.opensearch.test.framework.RolesMapping;
2120
import org.opensearch.test.framework.TestSecurityConfig;
2221
import org.opensearch.test.framework.cluster.ClusterManager;
2322
import org.opensearch.test.framework.cluster.LocalCluster;
@@ -45,9 +44,9 @@ public class AnonymousAuthenticationTest {
4544
/**
4645
* Maps {@link #ANONYMOUS_USER_CUSTOM_ROLE} to {@link #DEFAULT_ANONYMOUS_USER_BACKEND_ROLE_NAME}
4746
*/
48-
private static final RolesMapping ANONYMOUS_USER_CUSTOM_ROLE_MAPPING = new RolesMapping(ANONYMOUS_USER_CUSTOM_ROLE).backendRoles(
49-
DEFAULT_ANONYMOUS_USER_BACKEND_ROLE_NAME
50-
);
47+
private static final TestSecurityConfig.RoleMapping ANONYMOUS_USER_CUSTOM_ROLE_MAPPING = new TestSecurityConfig.RoleMapping(
48+
ANONYMOUS_USER_CUSTOM_ROLE.getName()
49+
).backendRoles(DEFAULT_ANONYMOUS_USER_BACKEND_ROLE_NAME);
5150

5251
/**
5352
* User who is stored in the internal user database and can authenticate

src/integrationTest/java/org/opensearch/security/http/AsyncTests.java

+1-2
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,6 @@
2626
import org.opensearch.security.IndexOperationsHelper;
2727
import org.opensearch.security.support.ConfigConstants;
2828
import org.opensearch.test.framework.AsyncActions;
29-
import org.opensearch.test.framework.RolesMapping;
3029
import org.opensearch.test.framework.TestSecurityConfig;
3130
import org.opensearch.test.framework.cluster.LocalCluster;
3231
import org.opensearch.test.framework.cluster.TestRestClient;
@@ -44,7 +43,7 @@ public class AsyncTests {
4443
public static LocalCluster cluster = new LocalCluster.Builder().singleNode()
4544
.authc(AUTHC_HTTPBASIC_INTERNAL)
4645
.users(ADMIN_USER)
47-
.rolesMapping(new RolesMapping(ALL_ACCESS).backendRoles("admin"))
46+
.rolesMapping(new TestSecurityConfig.RoleMapping(ALL_ACCESS.getName()).backendRoles("admin"))
4847
.anonymousAuth(false)
4948
.nodeSettings(Map.of(ConfigConstants.SECURITY_RESTAPI_ROLES_ENABLED, List.of(ALL_ACCESS.getName())))
5049
.build();

src/integrationTest/java/org/opensearch/security/http/CertificateAuthenticationTest.java

+2-2
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@
1717
import org.junit.Test;
1818
import org.junit.runner.RunWith;
1919

20-
import org.opensearch.test.framework.RolesMapping;
20+
import org.opensearch.test.framework.TestSecurityConfig;
2121
import org.opensearch.test.framework.TestSecurityConfig.AuthcDomain;
2222
import org.opensearch.test.framework.TestSecurityConfig.AuthcDomain.HttpAuthenticator;
2323
import org.opensearch.test.framework.TestSecurityConfig.Role;
@@ -69,7 +69,7 @@ public class CertificateAuthenticationTest {
6969
.authc(AUTHC_HTTPBASIC_INTERNAL)
7070
.roles(ROLE_ALL_INDEX_SEARCH)
7171
.users(USER_ADMIN)
72-
.rolesMapping(new RolesMapping(ROLE_ALL_INDEX_SEARCH).backendRoles(BACKEND_ROLE_BRIDGE))
72+
.rolesMapping(new TestSecurityConfig.RoleMapping(ROLE_ALL_INDEX_SEARCH.getName()).backendRoles(BACKEND_ROLE_BRIDGE))
7373
.build();
7474

7575
private static final TestCertificates TEST_CERTIFICATES = cluster.getTestCertificates();

src/integrationTest/java/org/opensearch/security/http/CommonProxyAuthenticationTests.java

+6-7
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,6 @@
1313
import java.net.InetAddress;
1414
import java.util.List;
1515

16-
import org.opensearch.test.framework.RolesMapping;
1716
import org.opensearch.test.framework.TestSecurityConfig;
1817
import org.opensearch.test.framework.cluster.LocalCluster;
1918
import org.opensearch.test.framework.cluster.TestRestClient;
@@ -84,13 +83,13 @@ abstract class CommonProxyAuthenticationTests {
8483
.indexPermissions("indices:data/read/search")
8584
.on(PERSONAL_INDEX_NAME_PATTERN);
8685

87-
protected static final RolesMapping ROLES_MAPPING_CAPTAIN = new RolesMapping(ROLE_PERSONAL_INDEX_SEARCH).backendRoles(
88-
BACKEND_ROLE_CAPTAIN
89-
);
86+
protected static final TestSecurityConfig.RoleMapping ROLES_MAPPING_CAPTAIN = new TestSecurityConfig.RoleMapping(
87+
ROLE_PERSONAL_INDEX_SEARCH.getName()
88+
).backendRoles(BACKEND_ROLE_CAPTAIN);
9089

91-
protected static final RolesMapping ROLES_MAPPING_FIRST_MATE = new RolesMapping(ROLE_ALL_INDEX_SEARCH).backendRoles(
92-
BACKEND_ROLE_FIRST_MATE
93-
);
90+
protected static final TestSecurityConfig.RoleMapping ROLES_MAPPING_FIRST_MATE = new TestSecurityConfig.RoleMapping(
91+
ROLE_ALL_INDEX_SEARCH.getName()
92+
).backendRoles(BACKEND_ROLE_FIRST_MATE);
9493

9594
protected abstract LocalCluster getCluster();
9695

src/integrationTest/java/org/opensearch/security/http/LdapAuthenticationTest.java

+1-2
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,6 @@
2727
import org.opensearch.test.framework.AuthzDomain;
2828
import org.opensearch.test.framework.LdapAuthenticationConfigBuilder;
2929
import org.opensearch.test.framework.LdapAuthorizationConfigBuilder;
30-
import org.opensearch.test.framework.RolesMapping;
3130
import org.opensearch.test.framework.TestSecurityConfig;
3231
import org.opensearch.test.framework.TestSecurityConfig.AuthcDomain;
3332
import org.opensearch.test.framework.TestSecurityConfig.AuthcDomain.AuthenticationBackend;
@@ -118,7 +117,7 @@ public class LdapAuthenticationTest {
118117
)
119118
.authc(AUTHC_HTTPBASIC_INTERNAL)
120119
.users(ADMIN_USER)
121-
.rolesMapping(new RolesMapping(ALL_ACCESS).backendRoles(CN_GROUP_ADMIN))
120+
.rolesMapping(new TestSecurityConfig.RoleMapping(ALL_ACCESS.getName()).backendRoles(CN_GROUP_ADMIN))
122121
.authz(
123122
new AuthzDomain("ldap_roles").httpEnabled(true)
124123
.authorizationBackend(

src/integrationTest/java/org/opensearch/security/http/LdapTlsAuthenticationTest.java

+3-3
Original file line numberDiff line numberDiff line change
@@ -30,7 +30,7 @@
3030
import org.opensearch.test.framework.AuthzDomain;
3131
import org.opensearch.test.framework.LdapAuthenticationConfigBuilder;
3232
import org.opensearch.test.framework.LdapAuthorizationConfigBuilder;
33-
import org.opensearch.test.framework.RolesMapping;
33+
import org.opensearch.test.framework.TestSecurityConfig;
3434
import org.opensearch.test.framework.TestSecurityConfig.AuthcDomain;
3535
import org.opensearch.test.framework.TestSecurityConfig.AuthcDomain.AuthenticationBackend;
3636
import org.opensearch.test.framework.TestSecurityConfig.AuthcDomain.HttpAuthenticator;
@@ -151,8 +151,8 @@ public class LdapTlsAuthenticationTest {
151151
.users(ADMIN_USER)
152152
.roles(ROLE_INDEX_ADMINISTRATOR, ROLE_PERSONAL_INDEX_ACCESS)
153153
.rolesMapping(
154-
new RolesMapping(ROLE_INDEX_ADMINISTRATOR).backendRoles(CN_GROUP_ADMIN),
155-
new RolesMapping(ROLE_PERSONAL_INDEX_ACCESS).backendRoles(CN_GROUP_CREW)
154+
new TestSecurityConfig.RoleMapping(ROLE_INDEX_ADMINISTRATOR.getName()).backendRoles(CN_GROUP_ADMIN),
155+
new TestSecurityConfig.RoleMapping(ROLE_PERSONAL_INDEX_ACCESS.getName()).backendRoles(CN_GROUP_CREW)
156156
)
157157
.authz(
158158
new AuthzDomain("ldap_roles").httpEnabled(true)

src/integrationTest/java/org/opensearch/security/http/OnBehalfOfJwtAuthenticationTest.java

+1-2
Original file line numberDiff line numberDiff line change
@@ -33,7 +33,6 @@
3333
import org.opensearch.core.xcontent.XContentBuilder;
3434
import org.opensearch.security.authtoken.jwt.EncryptionDecryptionUtil;
3535
import org.opensearch.test.framework.OnBehalfOfConfig;
36-
import org.opensearch.test.framework.RolesMapping;
3736
import org.opensearch.test.framework.TestSecurityConfig;
3837
import org.opensearch.test.framework.cluster.ClusterManager;
3938
import org.opensearch.test.framework.cluster.LocalCluster;
@@ -139,7 +138,7 @@ private static OnBehalfOfConfig defaultOnBehalfOfConfig() {
139138
)
140139
)
141140
.authc(AUTHC_HTTPBASIC_INTERNAL)
142-
.rolesMapping(new RolesMapping(HOST_MAPPING_ROLE).hostIPs(HOST_MAPPING_IP))
141+
.rolesMapping(new TestSecurityConfig.RoleMapping(HOST_MAPPING_ROLE.getName()).hosts(HOST_MAPPING_IP))
143142
.onBehalfOf(defaultOnBehalfOfConfig())
144143
.build();
145144

src/integrationTest/java/org/opensearch/security/http/RolesMappingTests.java

+4-2
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,6 @@
1616
import org.junit.Test;
1717
import org.junit.runner.RunWith;
1818

19-
import org.opensearch.test.framework.RolesMapping;
2019
import org.opensearch.test.framework.TestSecurityConfig;
2120
import org.opensearch.test.framework.cluster.ClusterManager;
2221
import org.opensearch.test.framework.cluster.LocalCluster;
@@ -48,7 +47,10 @@ public class RolesMappingTests {
4847
.anonymousAuth(false)
4948
.authc(AUTHC_DOMAIN)
5049
.roles(ROLE_A, ROLE_B)
51-
.rolesMapping(new RolesMapping(ROLE_A).backendRoles("mapsToRoleA"), new RolesMapping(ROLE_B).backendRoles("mapsToRoleB"))
50+
.rolesMapping(
51+
new TestSecurityConfig.RoleMapping(ROLE_A.getName()).backendRoles("mapsToRoleA"),
52+
new TestSecurityConfig.RoleMapping(ROLE_B.getName()).backendRoles("mapsToRoleB")
53+
)
5254
.users(USER_A, USER_B)
5355
.build();
5456

src/integrationTest/java/org/opensearch/test/framework/RolesMapping.java

-108
This file was deleted.

0 commit comments

Comments
 (0)