You are viewing a plain text version of this content. The canonical link for it is here.
Posted to notifications@ignite.apache.org by GitBox <gi...@apache.org> on 2020/05/06 12:23:40 UTC

[GitHub] [ignite] oleg-ostanin commented on a change in pull request #7671: IGNITE-12891 Add userAttributes map to all GridClient messages

oleg-ostanin commented on a change in pull request #7671:
URL: https://github.com/apache/ignite/pull/7671#discussion_r420747728



##########
File path: modules/core/src/test/java/org/apache/ignite/internal/processors/security/client/AttributeSecurityCheckTest.java
##########
@@ -0,0 +1,102 @@
+/*
+ * 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.client;
+
+import java.util.Map;
+import java.util.function.Consumer;
+import org.apache.ignite.Ignite;
+import org.apache.ignite.cluster.ClusterState;
+import org.apache.ignite.internal.client.GridClient;
+import org.apache.ignite.internal.client.GridClientClusterState;
+import org.apache.ignite.internal.client.GridClientConfiguration;
+import org.apache.ignite.internal.client.GridClientFactory;
+import org.apache.ignite.internal.processors.security.UserAttributesFactory;
+import org.apache.ignite.internal.processors.security.impl.TestAttributeSecurityPluginProvider;
+import org.apache.ignite.plugin.PluginProvider;
+import org.junit.Test;
+import org.junit.runner.RunWith;
+import org.junit.runners.JUnit4;
+
+import static org.apache.ignite.plugin.security.SecurityPermissionSetBuilder.ALLOW_ALL;
+
+/**
+ * Security tests for thin client.
+ */
+@RunWith(JUnit4.class)
+public class AttributeSecurityCheckTest extends CommonSecurityCheckTest {
+    /** */
+    private static Map<String, Object> userAttrs;
+
+    /** */
+    private static final int TEST_KEY_CNT = 10;
+
+    /** {@inheritDoc} */
+    @Override protected PluginProvider<?> getPluginProvider(String name){
+        return new TestAttributeSecurityPluginProvider(name, null, ALLOW_ALL,
+            globalAuth, true, new Consumer<Map<String, Object>>() {
+            @Override public void accept(Map<String, Object> map) {
+                userAttrs = map;
+            }
+        }, clientData());
+    }
+
+    /** {@inheritDoc} */
+    @Override protected GridClientConfiguration getGridClientConfiguration() {
+        return super.getGridClientConfiguration()
+            .setUserAttributes(userAttributes());
+    }
+
+    /** */
+    @Test
+    public void testClientInfoGridClientNotFail() throws Exception {
+        Ignite ignite = startGrids(2);
+
+        assertEquals(2, ignite.cluster().topologyVersion());
+
+        ignite.cluster().state(ClusterState.ACTIVE);
+
+        try (GridClient client = GridClientFactory.start(getGridClientConfiguration())) {
+            assertTrue(client.connected());

Review comment:
       done

##########
File path: modules/core/src/test/java/org/apache/ignite/internal/processors/security/impl/TestAttributeSecurityPluginProvider.java
##########
@@ -0,0 +1,53 @@
+/*
+ * 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.impl;
+
+import java.security.Permissions;
+import java.util.Arrays;
+import java.util.Map;
+import java.util.function.Consumer;
+import org.apache.ignite.internal.GridKernalContext;
+import org.apache.ignite.internal.processors.security.GridSecurityProcessor;
+import org.apache.ignite.plugin.security.SecurityPermissionSet;
+
+/**
+ *
+ */
+public class TestAttributeSecurityPluginProvider extends TestAdditionalSecurityPluginProvider {
+    /** Authentication handler. */
+    private Consumer<Map<String, Object>> hndlr;

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:
users@infra.apache.org