19
19
import static org .opensearch .security .dlic .rest .support .Utils .PLUGIN_RESOURCE_ROUTE_PREFIX ;
20
20
21
21
/**
22
- * These tests run with security enabled
22
+ * Abstract class for sample resource plugin tests. Provides common constants and utility methods for testing. This class is not intended to be
23
+ * instantiated directly. It is extended by {@link AbstractSampleResourcePluginFeatureEnabledTests}, {@link SampleResourcePluginFeatureDisabledTests}, {@link org.opensearch.sample.nonsystemindex.AbstractResourcePluginNonSystemIndexTests}
23
24
*/
24
25
@ RunWith (com .carrotsearch .randomizedtesting .RandomizedRunner .class )
25
26
@ ThreadLeakScope (ThreadLeakScope .Scope .NONE )
26
- public class AbstractSampleResourcePluginTests {
27
+ public abstract class AbstractSampleResourcePluginTests {
27
28
28
- final static TestSecurityConfig .User SHARED_WITH_USER = new TestSecurityConfig .User ("resource_sharing_test_user" ).roles (
29
+ protected final static TestSecurityConfig .User SHARED_WITH_USER = new TestSecurityConfig .User ("resource_sharing_test_user" ).roles (
29
30
new TestSecurityConfig .Role ("shared_role" ).indexPermissions ("*" ).on ("*" ).clusterPermissions ("*" )
30
31
);
31
32
32
- static final String SAMPLE_RESOURCE_CREATE_ENDPOINT = SAMPLE_RESOURCE_PLUGIN_PREFIX + "/create" ;
33
- static final String SAMPLE_RESOURCE_GET_ENDPOINT = SAMPLE_RESOURCE_PLUGIN_PREFIX + "/get" ;
34
- static final String SAMPLE_RESOURCE_UPDATE_ENDPOINT = SAMPLE_RESOURCE_PLUGIN_PREFIX + "/update" ;
35
- static final String SAMPLE_RESOURCE_DELETE_ENDPOINT = SAMPLE_RESOURCE_PLUGIN_PREFIX + "/delete" ;
36
- static final String SAMPLE_RESOURCE_SHARE_ENDPOINT = SAMPLE_RESOURCE_PLUGIN_PREFIX + "/share" ;
37
- static final String SAMPLE_RESOURCE_REVOKE_ENDPOINT = SAMPLE_RESOURCE_PLUGIN_PREFIX + "/revoke" ;
33
+ protected final static TestSecurityConfig .User SHARED_WITH_USER_LIMITED_PERMISSIONS = new TestSecurityConfig .User (
34
+ "resource_sharing_test_user"
35
+ ).roles (new TestSecurityConfig .Role ("shared_role" ).indexPermissions ("*" ).on (RESOURCE_INDEX_NAME ));
36
+
37
+ protected static final String SAMPLE_RESOURCE_CREATE_ENDPOINT = SAMPLE_RESOURCE_PLUGIN_PREFIX + "/create" ;
38
+ protected static final String SAMPLE_RESOURCE_GET_ENDPOINT = SAMPLE_RESOURCE_PLUGIN_PREFIX + "/get" ;
39
+ protected static final String SAMPLE_RESOURCE_UPDATE_ENDPOINT = SAMPLE_RESOURCE_PLUGIN_PREFIX + "/update" ;
40
+ protected static final String SAMPLE_RESOURCE_DELETE_ENDPOINT = SAMPLE_RESOURCE_PLUGIN_PREFIX + "/delete" ;
41
+ protected static final String SAMPLE_RESOURCE_SHARE_ENDPOINT = SAMPLE_RESOURCE_PLUGIN_PREFIX + "/share" ;
42
+ protected static final String SAMPLE_RESOURCE_REVOKE_ENDPOINT = SAMPLE_RESOURCE_PLUGIN_PREFIX + "/revoke" ;
38
43
private static final String PLUGIN_RESOURCE_ROUTE_PREFIX_NO_LEADING_SLASH = PLUGIN_RESOURCE_ROUTE_PREFIX .replaceFirst ("/" , "" );
39
- static final String SECURITY_RESOURCE_LIST_ENDPOINT = PLUGIN_RESOURCE_ROUTE_PREFIX_NO_LEADING_SLASH + "/list" ;
40
- static final String SECURITY_RESOURCE_SHARE_ENDPOINT = PLUGIN_RESOURCE_ROUTE_PREFIX_NO_LEADING_SLASH + "/share" ;
41
- static final String SECURITY_RESOURCE_VERIFY_ENDPOINT = PLUGIN_RESOURCE_ROUTE_PREFIX_NO_LEADING_SLASH + "/verify_access" ;
42
- static final String SECURITY_RESOURCE_REVOKE_ENDPOINT = PLUGIN_RESOURCE_ROUTE_PREFIX_NO_LEADING_SLASH + "/revoke" ;
44
+ protected static final String SECURITY_RESOURCE_LIST_ENDPOINT = PLUGIN_RESOURCE_ROUTE_PREFIX_NO_LEADING_SLASH + "/list" ;
45
+ protected static final String SECURITY_RESOURCE_SHARE_ENDPOINT = PLUGIN_RESOURCE_ROUTE_PREFIX_NO_LEADING_SLASH + "/share" ;
46
+ protected static final String SECURITY_RESOURCE_VERIFY_ENDPOINT = PLUGIN_RESOURCE_ROUTE_PREFIX_NO_LEADING_SLASH + "/verify_access" ;
47
+ protected static final String SECURITY_RESOURCE_REVOKE_ENDPOINT = PLUGIN_RESOURCE_ROUTE_PREFIX_NO_LEADING_SLASH + "/revoke" ;
43
48
44
- static String shareWithPayloadSecurityApi (String resourceId ) {
49
+ protected static String shareWithPayloadSecurityApi (String resourceId ) {
45
50
return "{"
46
51
+ "\" resource_id\" :\" "
47
52
+ resourceId
@@ -61,7 +66,7 @@ static String shareWithPayloadSecurityApi(String resourceId) {
61
66
+ "}" ;
62
67
}
63
68
64
- static String shareWithPayload () {
69
+ protected static String shareWithPayload () {
65
70
return "{"
66
71
+ "\" share_with\" :{"
67
72
+ "\" "
@@ -75,7 +80,7 @@ static String shareWithPayload() {
75
80
+ "}" ;
76
81
}
77
82
78
- static String revokeAccessPayloadSecurityApi (String resourceId ) {
83
+ protected static String revokeAccessPayloadSecurityApi (String resourceId ) {
79
84
return "{"
80
85
+ "\" resource_id\" : \" "
81
86
+ resourceId
@@ -94,7 +99,7 @@ static String revokeAccessPayloadSecurityApi(String resourceId) {
94
99
+ "}" ;
95
100
}
96
101
97
- static String revokeAccessPayload () {
102
+ protected static String revokeAccessPayload () {
98
103
return "{"
99
104
+ "\" entities_to_revoke\" : {"
100
105
+ "\" users\" : [\" "
0 commit comments