[GitHub] [ignite] Sega76 commented on a change in pull request #6904: IGNITE-12220
Sega76 commented on a change in pull request #6904: IGNITE-12220 URL: https://github.com/apache/ignite/pull/6904#discussion_r397844693 ## File path: modules/clients/src/test/java/org/apache/ignite/internal/processors/rest/JettyRestProcessorSecurityCreateDestroyPermissionTest.java ## @@ -0,0 +1,306 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed with + * this work for additional information regarding copyright ownership. + * The ASF 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. + */ + +package org.apache.ignite.internal.processors.rest; + +import com.fasterxml.jackson.databind.ObjectMapper; +import java.io.IOException; +import java.io.InputStream; +import java.io.InputStreamReader; +import java.io.LineNumberReader; +import java.net.URL; +import org.apache.ignite.configuration.IgniteConfiguration; +import org.apache.ignite.internal.IgniteEx; +import org.apache.ignite.internal.processors.rest.protocols.http.jetty.GridJettyObjectMapper; +import org.apache.ignite.internal.processors.security.impl.TestSecurityData; +import org.apache.ignite.internal.processors.security.impl.TestSecurityPluginProvider; +import org.apache.ignite.internal.util.typedef.internal.SB; +import org.apache.ignite.plugin.security.SecurityPermission; +import org.apache.ignite.plugin.security.SecurityPermissionSetBuilder; +import org.junit.Test; + +import static org.apache.ignite.IgniteSystemProperties.IGNITE_JETTY_PORT; +import static org.apache.ignite.plugin.security.SecurityPermission.ADMIN_CACHE; +import static org.apache.ignite.plugin.security.SecurityPermission.CACHE_CREATE; +import static org.apache.ignite.plugin.security.SecurityPermission.CACHE_DESTROY; +import static org.apache.ignite.plugin.security.SecurityPermissionSetBuilder.ALLOW_ALL; + +/** */ +public class JettyRestProcessorSecurityCreateDestroyPermissionTest extends AbstractRestProcessorSelfTest { Review comment: done This is an automated message from the Apache Git Service. To respond to the message, please log on to GitHub and use the URL above to go to the specific comment. For queries about this service, please contact Infrastructure at: us...@infra.apache.org With regards, Apache Git Services
[GitHub] [ignite] Sega76 commented on a change in pull request #6904: IGNITE-12220
Sega76 commented on a change in pull request #6904: IGNITE-12220 URL: https://github.com/apache/ignite/pull/6904#discussion_r397844025 ## File path: modules/core/src/test/java/org/apache/ignite/internal/processors/security/rest/handlers/cache/CacheOperationPermissionRestCommandHandlerCheckTest.java ## @@ -0,0 +1,410 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed with + * this work for additional information regarding copyright ownership. + * The ASF 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. + */ + +package org.apache.ignite.internal.processors.security.rest.handlers.cache; + +import java.util.Arrays; +import java.util.HashMap; +import java.util.HashSet; +import java.util.Map; +import java.util.Set; +import org.apache.ignite.IgniteCheckedException; +import org.apache.ignite.configuration.IgniteConfiguration; +import org.apache.ignite.internal.IgniteEx; +import org.apache.ignite.internal.IgniteInternalFuture; +import org.apache.ignite.internal.processors.rest.GridRestCommand; +import org.apache.ignite.internal.processors.rest.GridRestResponse; +import org.apache.ignite.internal.processors.rest.handlers.GridRestCommandHandler; +import org.apache.ignite.internal.processors.rest.handlers.cache.GridCacheCommandHandler; +import org.apache.ignite.internal.processors.rest.request.GridRestCacheRequest; +import org.apache.ignite.internal.processors.rest.request.GridRestRequest; +import org.apache.ignite.internal.processors.security.impl.TestSecurityPluginProvider; +import org.apache.ignite.plugin.security.SecurityPermission; +import org.apache.ignite.plugin.security.SecurityPermissionSetBuilder; +import org.apache.ignite.spi.discovery.tcp.TcpDiscoverySpi; +import org.apache.ignite.spi.discovery.tcp.ipfinder.vm.TcpDiscoveryVmIpFinder; +import org.apache.ignite.testframework.junits.common.GridCommonAbstractTest; +import org.apache.ignite.plugin.security.SecurityException; +import org.junit.Test; + +import static java.util.Collections.singletonMap; +import static org.apache.ignite.plugin.security.SecurityPermission.*; +import static org.apache.ignite.testframework.GridTestUtils.assertThrowsWithCause; + +/** + * Test CRUD, create and destroy cache permissions with rest commands handler. + */ +public class CacheOperationPermissionRestCommandHandlerCheckTest extends GridCommonAbstractTest { +/** Empty permission. */ +private static final SecurityPermission[] EMPTY_PERMS = new SecurityPermission[0]; + +/** Cache name for tests. */ +private static final String CACHE_NAME = "TEST_CACHE"; + +/** Forbidden cache. */ +private static final String FORBIDDEN_CACHE_NAME = "FORBIDDEN_TEST_CACHE"; + +/** New cache. */ +private static final String NEW_TEST_CACHE = "NEW_TEST_CACHE"; + +/** Key. */ +private String key = "key"; + +/** Value. */ +private String val = "value"; + +/** New value. */ +private String newVal = "newValue"; + +/** Cache permissions. */ +private Map cachePerms = new HashMap<>(); + +/** Security permission set. */ +private Set sysPermSet = new HashSet<>(); + +/** Handler. */ +private GridRestCommandHandler hnd; + +/** {@inheritDoc} */ +@Override protected IgniteConfiguration getConfiguration() throws Exception { +TcpDiscoverySpi disco = new TcpDiscoverySpi(); Review comment: done, thanks This is an automated message from the Apache Git Service. To respond to the message, please log on to GitHub and use the URL above to go to the specific comment. For queries about this service, please contact Infrastructure at: us...@infra.apache.org With regards, Apache Git Services
[GitHub] [ignite] Sega76 commented on a change in pull request #6904: IGNITE-12220
Sega76 commented on a change in pull request #6904: IGNITE-12220 URL: https://github.com/apache/ignite/pull/6904#discussion_r397007082 ## File path: modules/clients/src/test/java/org/apache/ignite/internal/processors/rest/JettyRestProcessorSecurityCreateDestroyPermissionTest.java ## @@ -0,0 +1,306 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed with + * this work for additional information regarding copyright ownership. + * The ASF 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. + */ + +package org.apache.ignite.internal.processors.rest; + +import com.fasterxml.jackson.databind.ObjectMapper; +import java.io.IOException; +import java.io.InputStream; +import java.io.InputStreamReader; +import java.io.LineNumberReader; +import java.net.URL; +import org.apache.ignite.configuration.IgniteConfiguration; +import org.apache.ignite.internal.IgniteEx; +import org.apache.ignite.internal.processors.rest.protocols.http.jetty.GridJettyObjectMapper; +import org.apache.ignite.internal.processors.security.impl.TestSecurityData; +import org.apache.ignite.internal.processors.security.impl.TestSecurityPluginProvider; +import org.apache.ignite.internal.util.typedef.internal.SB; +import org.apache.ignite.plugin.security.SecurityPermission; +import org.apache.ignite.plugin.security.SecurityPermissionSetBuilder; +import org.junit.Test; + +import static org.apache.ignite.IgniteSystemProperties.IGNITE_JETTY_PORT; +import static org.apache.ignite.plugin.security.SecurityPermission.ADMIN_CACHE; +import static org.apache.ignite.plugin.security.SecurityPermission.CACHE_CREATE; +import static org.apache.ignite.plugin.security.SecurityPermission.CACHE_DESTROY; +import static org.apache.ignite.plugin.security.SecurityPermissionSetBuilder.ALLOW_ALL; + +/** */ +public class JettyRestProcessorSecurityCreateDestroyPermissionTest extends AbstractRestProcessorSelfTest { +/** */ +private static final String CLNT_ADMIN = "clnt_admin"; + +/** */ +private static final String ALLOWED_CLNT_CACHE = "allowed_clnt_cache"; + +/** */ +private static final String UNALLOWED_CLNT_CACHE = "unallowed_clnt_cache"; + +/** */ +private static final String ALLOWED_CLNT_SYSTEM = "allowed_clnt_system"; + +/** */ +private static final String UNALLOWED_CLNT_SYSTEM = "unallowed_clnt_system"; + +/** */ +protected static final ObjectMapper JSON_MAPPER = new GridJettyObjectMapper(); + +/** */ +private static final String STATUS_FLD = "successStatus"; + +/** */ +private static final String ERROR_FLD = "error"; + +/** */ +private static final String SUCCESS_STATUS = "0"; + +/** */ +private static final String ERROR_STATUS = "3"; + +/** */ +private static final String CACHE_NAME = "TEST_CACHE"; + +/** */ +private static final String UNDECLARED_CACHE = "UNDECLARED_CACHE"; + +/** */ +private static final SecurityPermission[] EMPTY_PERM = new SecurityPermission[0]; + +/** */ +private static final int DFLT_REST_PORT = 8091; + +/** */ +private static final String REST_URL ="http://"; + LOC_HOST +":" + DFLT_REST_PORT + "/ignite?"; + +/** {@inheritDoc} */ +@Override protected IgniteConfiguration getConfiguration(String igniteInstanceName) throws Exception { +TestSecurityData[] clientData = new TestSecurityData[] { +new TestSecurityData(CLNT_ADMIN, +SecurityPermissionSetBuilder.create().defaultAllowAll(false) +.appendSystemPermissions(ADMIN_CACHE) +.build() +), +new TestSecurityData(ALLOWED_CLNT_CACHE, +SecurityPermissionSetBuilder.create().defaultAllowAll(false) +.appendCachePermissions(CACHE_NAME, CACHE_CREATE, CACHE_DESTROY) +.build() +), +new TestSecurityData(UNALLOWED_CLNT_CACHE, +SecurityPermissionSetBuilder.create().defaultAllowAll(false) +.appendCachePermissions(CACHE_NAME, EMPTY_PERM) +.build() +), +new TestSecurityData(ALLOWED_CLNT_SYSTEM, +SecurityPermissionSetBuilder.create().defaultAllowAll(false) +.appendSystemPermissions(CACHE_CREATE, CACHE_DESTROY) +.build() +), +