[4/8] ambari git commit: AMBARI-18540: Unit test cases required for verifying Ambari username case sensitivity
AMBARI-18540: Unit test cases required for verifying Ambari username case sensitivity Project: http://git-wip-us.apache.org/repos/asf/ambari/repo Commit: http://git-wip-us.apache.org/repos/asf/ambari/commit/569020ca Tree: http://git-wip-us.apache.org/repos/asf/ambari/tree/569020ca Diff: http://git-wip-us.apache.org/repos/asf/ambari/diff/569020ca Branch: refs/heads/branch-dev-patch-upgrade Commit: 569020caf1c6f39765d7da9efb8c57b66293844e Parents: 8813b1f Author: Nahappan SomasundaramAuthored: Wed Oct 5 17:25:20 2016 -0700 Committer: Nahappan Somasundaram Committed: Fri Oct 7 14:22:27 2016 -0700 -- .../internal/UserResourceProviderDBTest.java| 280 +++ 1 file changed, 280 insertions(+) -- http://git-wip-us.apache.org/repos/asf/ambari/blob/569020ca/ambari-server/src/test/java/org/apache/ambari/server/controller/internal/UserResourceProviderDBTest.java -- diff --git a/ambari-server/src/test/java/org/apache/ambari/server/controller/internal/UserResourceProviderDBTest.java b/ambari-server/src/test/java/org/apache/ambari/server/controller/internal/UserResourceProviderDBTest.java new file mode 100644 index 000..1629b49 --- /dev/null +++ b/ambari-server/src/test/java/org/apache/ambari/server/controller/internal/UserResourceProviderDBTest.java @@ -0,0 +1,280 @@ +/** + * 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.ambari.server.controller.internal; + +import com.google.inject.Guice; +import com.google.inject.Injector; +import com.google.inject.persist.PersistService; +import org.apache.ambari.server.configuration.Configuration; +import org.apache.ambari.server.controller.AmbariManagementController; +import org.apache.ambari.server.controller.spi.Predicate; +import org.apache.ambari.server.controller.spi.Request; +import org.apache.ambari.server.controller.spi.RequestStatus; +import org.apache.ambari.server.controller.spi.Resource; +import org.apache.ambari.server.controller.utilities.PredicateBuilder; +import org.apache.ambari.server.controller.utilities.PropertyHelper; +import org.apache.ambari.server.orm.InMemoryDefaultTestModule; +import org.apache.ambari.server.security.TestAuthenticationFactory; +import org.apache.ambari.server.security.authorization.AuthorizationHelper; +import org.junit.AfterClass; +import org.junit.Before; +import org.junit.BeforeClass; +import org.junit.Test; +import org.powermock.core.classloader.annotations.PrepareForTest; +import org.springframework.security.core.Authentication; +import org.springframework.security.core.context.SecurityContextHolder; + +import java.util.Arrays; +import java.util.Collections; +import java.util.HashMap; +import java.util.HashSet; +import java.util.List; +import java.util.Map; +import java.util.Properties; +import java.util.Set; + +import static org.junit.Assert.assertNotNull; +import static org.junit.Assert.assertTrue; +import static org.junit.Assert.assertEquals; + +/** + * Tests creation, retrieval and deletion of users using an in-memory database. + * Also tests user creation and retrieval using usernames that differ only by case. + * Verifies that usernames are stored as provided. + */ +@PrepareForTest({AuthorizationHelper.class}) +public class UserResourceProviderDBTest { +private static Injector injector; +private static AmbariManagementController amc; +private static Resource.Type userType = Resource.Type.User; +private static UserResourceProvider userResourceProvider; +private static String JDBC_IN_MEMORY_URL_CREATE = +String.format("jdbc:derby:memory:myDB/%s;create=true", Configuration.DEFAULT_DERBY_SCHEMA); +private static String JDBC_IN_MEMORY_URL_DROP = +String.format("jdbc:derby:memory:myDB/%s;drop=true", Configuration.DEFAULT_DERBY_SCHEMA); + +/** + * Sets up the in-memory database for the test suite. + */ +@BeforeClass +public static void setupInMemoryDB() { +InMemoryDefaultTestModule
[1/3] ambari git commit: AMBARI-18540: Unit test cases required for verifying Ambari username case sensitivity
Repository: ambari Updated Branches: refs/heads/branch-feature-AMBARI-18456 0de69e10b -> 5cf5c8349 AMBARI-18540: Unit test cases required for verifying Ambari username case sensitivity Project: http://git-wip-us.apache.org/repos/asf/ambari/repo Commit: http://git-wip-us.apache.org/repos/asf/ambari/commit/569020ca Tree: http://git-wip-us.apache.org/repos/asf/ambari/tree/569020ca Diff: http://git-wip-us.apache.org/repos/asf/ambari/diff/569020ca Branch: refs/heads/branch-feature-AMBARI-18456 Commit: 569020caf1c6f39765d7da9efb8c57b66293844e Parents: 8813b1f Author: Nahappan SomasundaramAuthored: Wed Oct 5 17:25:20 2016 -0700 Committer: Nahappan Somasundaram Committed: Fri Oct 7 14:22:27 2016 -0700 -- .../internal/UserResourceProviderDBTest.java| 280 +++ 1 file changed, 280 insertions(+) -- http://git-wip-us.apache.org/repos/asf/ambari/blob/569020ca/ambari-server/src/test/java/org/apache/ambari/server/controller/internal/UserResourceProviderDBTest.java -- diff --git a/ambari-server/src/test/java/org/apache/ambari/server/controller/internal/UserResourceProviderDBTest.java b/ambari-server/src/test/java/org/apache/ambari/server/controller/internal/UserResourceProviderDBTest.java new file mode 100644 index 000..1629b49 --- /dev/null +++ b/ambari-server/src/test/java/org/apache/ambari/server/controller/internal/UserResourceProviderDBTest.java @@ -0,0 +1,280 @@ +/** + * 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.ambari.server.controller.internal; + +import com.google.inject.Guice; +import com.google.inject.Injector; +import com.google.inject.persist.PersistService; +import org.apache.ambari.server.configuration.Configuration; +import org.apache.ambari.server.controller.AmbariManagementController; +import org.apache.ambari.server.controller.spi.Predicate; +import org.apache.ambari.server.controller.spi.Request; +import org.apache.ambari.server.controller.spi.RequestStatus; +import org.apache.ambari.server.controller.spi.Resource; +import org.apache.ambari.server.controller.utilities.PredicateBuilder; +import org.apache.ambari.server.controller.utilities.PropertyHelper; +import org.apache.ambari.server.orm.InMemoryDefaultTestModule; +import org.apache.ambari.server.security.TestAuthenticationFactory; +import org.apache.ambari.server.security.authorization.AuthorizationHelper; +import org.junit.AfterClass; +import org.junit.Before; +import org.junit.BeforeClass; +import org.junit.Test; +import org.powermock.core.classloader.annotations.PrepareForTest; +import org.springframework.security.core.Authentication; +import org.springframework.security.core.context.SecurityContextHolder; + +import java.util.Arrays; +import java.util.Collections; +import java.util.HashMap; +import java.util.HashSet; +import java.util.List; +import java.util.Map; +import java.util.Properties; +import java.util.Set; + +import static org.junit.Assert.assertNotNull; +import static org.junit.Assert.assertTrue; +import static org.junit.Assert.assertEquals; + +/** + * Tests creation, retrieval and deletion of users using an in-memory database. + * Also tests user creation and retrieval using usernames that differ only by case. + * Verifies that usernames are stored as provided. + */ +@PrepareForTest({AuthorizationHelper.class}) +public class UserResourceProviderDBTest { +private static Injector injector; +private static AmbariManagementController amc; +private static Resource.Type userType = Resource.Type.User; +private static UserResourceProvider userResourceProvider; +private static String JDBC_IN_MEMORY_URL_CREATE = +String.format("jdbc:derby:memory:myDB/%s;create=true", Configuration.DEFAULT_DERBY_SCHEMA); +private static String JDBC_IN_MEMORY_URL_DROP = +String.format("jdbc:derby:memory:myDB/%s;drop=true", Configuration.DEFAULT_DERBY_SCHEMA); + +/** + * Sets up the in-memory database for the test suite. +
ambari git commit: AMBARI-18540: Unit test cases required for verifying Ambari username case sensitivity
Repository: ambari Updated Branches: refs/heads/trunk 8813b1f92 -> 569020caf AMBARI-18540: Unit test cases required for verifying Ambari username case sensitivity Project: http://git-wip-us.apache.org/repos/asf/ambari/repo Commit: http://git-wip-us.apache.org/repos/asf/ambari/commit/569020ca Tree: http://git-wip-us.apache.org/repos/asf/ambari/tree/569020ca Diff: http://git-wip-us.apache.org/repos/asf/ambari/diff/569020ca Branch: refs/heads/trunk Commit: 569020caf1c6f39765d7da9efb8c57b66293844e Parents: 8813b1f Author: Nahappan SomasundaramAuthored: Wed Oct 5 17:25:20 2016 -0700 Committer: Nahappan Somasundaram Committed: Fri Oct 7 14:22:27 2016 -0700 -- .../internal/UserResourceProviderDBTest.java| 280 +++ 1 file changed, 280 insertions(+) -- http://git-wip-us.apache.org/repos/asf/ambari/blob/569020ca/ambari-server/src/test/java/org/apache/ambari/server/controller/internal/UserResourceProviderDBTest.java -- diff --git a/ambari-server/src/test/java/org/apache/ambari/server/controller/internal/UserResourceProviderDBTest.java b/ambari-server/src/test/java/org/apache/ambari/server/controller/internal/UserResourceProviderDBTest.java new file mode 100644 index 000..1629b49 --- /dev/null +++ b/ambari-server/src/test/java/org/apache/ambari/server/controller/internal/UserResourceProviderDBTest.java @@ -0,0 +1,280 @@ +/** + * 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.ambari.server.controller.internal; + +import com.google.inject.Guice; +import com.google.inject.Injector; +import com.google.inject.persist.PersistService; +import org.apache.ambari.server.configuration.Configuration; +import org.apache.ambari.server.controller.AmbariManagementController; +import org.apache.ambari.server.controller.spi.Predicate; +import org.apache.ambari.server.controller.spi.Request; +import org.apache.ambari.server.controller.spi.RequestStatus; +import org.apache.ambari.server.controller.spi.Resource; +import org.apache.ambari.server.controller.utilities.PredicateBuilder; +import org.apache.ambari.server.controller.utilities.PropertyHelper; +import org.apache.ambari.server.orm.InMemoryDefaultTestModule; +import org.apache.ambari.server.security.TestAuthenticationFactory; +import org.apache.ambari.server.security.authorization.AuthorizationHelper; +import org.junit.AfterClass; +import org.junit.Before; +import org.junit.BeforeClass; +import org.junit.Test; +import org.powermock.core.classloader.annotations.PrepareForTest; +import org.springframework.security.core.Authentication; +import org.springframework.security.core.context.SecurityContextHolder; + +import java.util.Arrays; +import java.util.Collections; +import java.util.HashMap; +import java.util.HashSet; +import java.util.List; +import java.util.Map; +import java.util.Properties; +import java.util.Set; + +import static org.junit.Assert.assertNotNull; +import static org.junit.Assert.assertTrue; +import static org.junit.Assert.assertEquals; + +/** + * Tests creation, retrieval and deletion of users using an in-memory database. + * Also tests user creation and retrieval using usernames that differ only by case. + * Verifies that usernames are stored as provided. + */ +@PrepareForTest({AuthorizationHelper.class}) +public class UserResourceProviderDBTest { +private static Injector injector; +private static AmbariManagementController amc; +private static Resource.Type userType = Resource.Type.User; +private static UserResourceProvider userResourceProvider; +private static String JDBC_IN_MEMORY_URL_CREATE = +String.format("jdbc:derby:memory:myDB/%s;create=true", Configuration.DEFAULT_DERBY_SCHEMA); +private static String JDBC_IN_MEMORY_URL_DROP = +String.format("jdbc:derby:memory:myDB/%s;drop=true", Configuration.DEFAULT_DERBY_SCHEMA); + +/** + * Sets up the in-memory database for the test suite. + */ +@BeforeClass +public static
ambari git commit: AMBARI-18540: Unit test cases required for verifying Ambari username case sensitivity
Repository: ambari Updated Branches: refs/heads/branch-2.5 13d3b8b06 -> b5f74e059 AMBARI-18540: Unit test cases required for verifying Ambari username case sensitivity Project: http://git-wip-us.apache.org/repos/asf/ambari/repo Commit: http://git-wip-us.apache.org/repos/asf/ambari/commit/b5f74e05 Tree: http://git-wip-us.apache.org/repos/asf/ambari/tree/b5f74e05 Diff: http://git-wip-us.apache.org/repos/asf/ambari/diff/b5f74e05 Branch: refs/heads/branch-2.5 Commit: b5f74e059edec1d8fd4573d6a192eef53ed7b576 Parents: 13d3b8b Author: Nahappan SomasundaramAuthored: Wed Oct 5 17:25:20 2016 -0700 Committer: Nahappan Somasundaram Committed: Fri Oct 7 14:18:52 2016 -0700 -- .../internal/UserResourceProviderDBTest.java| 280 +++ 1 file changed, 280 insertions(+) -- http://git-wip-us.apache.org/repos/asf/ambari/blob/b5f74e05/ambari-server/src/test/java/org/apache/ambari/server/controller/internal/UserResourceProviderDBTest.java -- diff --git a/ambari-server/src/test/java/org/apache/ambari/server/controller/internal/UserResourceProviderDBTest.java b/ambari-server/src/test/java/org/apache/ambari/server/controller/internal/UserResourceProviderDBTest.java new file mode 100644 index 000..1629b49 --- /dev/null +++ b/ambari-server/src/test/java/org/apache/ambari/server/controller/internal/UserResourceProviderDBTest.java @@ -0,0 +1,280 @@ +/** + * 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.ambari.server.controller.internal; + +import com.google.inject.Guice; +import com.google.inject.Injector; +import com.google.inject.persist.PersistService; +import org.apache.ambari.server.configuration.Configuration; +import org.apache.ambari.server.controller.AmbariManagementController; +import org.apache.ambari.server.controller.spi.Predicate; +import org.apache.ambari.server.controller.spi.Request; +import org.apache.ambari.server.controller.spi.RequestStatus; +import org.apache.ambari.server.controller.spi.Resource; +import org.apache.ambari.server.controller.utilities.PredicateBuilder; +import org.apache.ambari.server.controller.utilities.PropertyHelper; +import org.apache.ambari.server.orm.InMemoryDefaultTestModule; +import org.apache.ambari.server.security.TestAuthenticationFactory; +import org.apache.ambari.server.security.authorization.AuthorizationHelper; +import org.junit.AfterClass; +import org.junit.Before; +import org.junit.BeforeClass; +import org.junit.Test; +import org.powermock.core.classloader.annotations.PrepareForTest; +import org.springframework.security.core.Authentication; +import org.springframework.security.core.context.SecurityContextHolder; + +import java.util.Arrays; +import java.util.Collections; +import java.util.HashMap; +import java.util.HashSet; +import java.util.List; +import java.util.Map; +import java.util.Properties; +import java.util.Set; + +import static org.junit.Assert.assertNotNull; +import static org.junit.Assert.assertTrue; +import static org.junit.Assert.assertEquals; + +/** + * Tests creation, retrieval and deletion of users using an in-memory database. + * Also tests user creation and retrieval using usernames that differ only by case. + * Verifies that usernames are stored as provided. + */ +@PrepareForTest({AuthorizationHelper.class}) +public class UserResourceProviderDBTest { +private static Injector injector; +private static AmbariManagementController amc; +private static Resource.Type userType = Resource.Type.User; +private static UserResourceProvider userResourceProvider; +private static String JDBC_IN_MEMORY_URL_CREATE = +String.format("jdbc:derby:memory:myDB/%s;create=true", Configuration.DEFAULT_DERBY_SCHEMA); +private static String JDBC_IN_MEMORY_URL_DROP = +String.format("jdbc:derby:memory:myDB/%s;drop=true", Configuration.DEFAULT_DERBY_SCHEMA); + +/** + * Sets up the in-memory database for the test suite. + */ +@BeforeClass +
ambari git commit: AMBARI-18540: Unit test cases required for verifying Ambari username case sensitivity
Repository: ambari Updated Branches: refs/heads/branch-2.4 ffa1bbf63 -> f51fdcc19 AMBARI-18540: Unit test cases required for verifying Ambari username case sensitivity Project: http://git-wip-us.apache.org/repos/asf/ambari/repo Commit: http://git-wip-us.apache.org/repos/asf/ambari/commit/f51fdcc1 Tree: http://git-wip-us.apache.org/repos/asf/ambari/tree/f51fdcc1 Diff: http://git-wip-us.apache.org/repos/asf/ambari/diff/f51fdcc1 Branch: refs/heads/branch-2.4 Commit: f51fdcc192d71f879cbe557aa5a3974853096213 Parents: ffa1bbf Author: Nahappan SomasundaramAuthored: Wed Oct 5 17:25:20 2016 -0700 Committer: Nahappan Somasundaram Committed: Thu Oct 6 11:44:08 2016 -0700 -- .../internal/UserResourceProviderDBTest.java| 280 +++ 1 file changed, 280 insertions(+) -- http://git-wip-us.apache.org/repos/asf/ambari/blob/f51fdcc1/ambari-server/src/test/java/org/apache/ambari/server/controller/internal/UserResourceProviderDBTest.java -- diff --git a/ambari-server/src/test/java/org/apache/ambari/server/controller/internal/UserResourceProviderDBTest.java b/ambari-server/src/test/java/org/apache/ambari/server/controller/internal/UserResourceProviderDBTest.java new file mode 100644 index 000..f3445d7 --- /dev/null +++ b/ambari-server/src/test/java/org/apache/ambari/server/controller/internal/UserResourceProviderDBTest.java @@ -0,0 +1,280 @@ +/** + * 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.ambari.server.controller.internal; + +import com.google.inject.Guice; +import com.google.inject.Injector; +import com.google.inject.persist.PersistService; +import org.apache.ambari.server.configuration.Configuration; +import org.apache.ambari.server.controller.AmbariManagementController; +import org.apache.ambari.server.controller.spi.Predicate; +import org.apache.ambari.server.controller.spi.Request; +import org.apache.ambari.server.controller.spi.RequestStatus; +import org.apache.ambari.server.controller.spi.Resource; +import org.apache.ambari.server.controller.utilities.PredicateBuilder; +import org.apache.ambari.server.controller.utilities.PropertyHelper; +import org.apache.ambari.server.orm.InMemoryDefaultTestModule; +import org.apache.ambari.server.security.TestAuthenticationFactory; +import org.apache.ambari.server.security.authorization.AuthorizationHelper; +import org.junit.AfterClass; +import org.junit.Before; +import org.junit.BeforeClass; +import org.junit.Test; +import org.powermock.core.classloader.annotations.PrepareForTest; +import org.springframework.security.core.Authentication; +import org.springframework.security.core.context.SecurityContextHolder; + +import java.util.Arrays; +import java.util.Collections; +import java.util.HashMap; +import java.util.HashSet; +import java.util.List; +import java.util.Map; +import java.util.Properties; +import java.util.Set; + +import static org.junit.Assert.assertNotNull; +import static org.junit.Assert.assertTrue; +import static org.junit.Assert.assertEquals; + +/** + * Tests creation, retrieval and deletion of users using an in-memory database. + * Also tests user creation and retrieval using usernames that differ only by case. + * Verifies that usernames are stored as provided. + */ +@PrepareForTest({AuthorizationHelper.class}) +public class UserResourceProviderDBTest { +private static Injector injector; +private static AmbariManagementController amc; +private static Resource.Type userType = Resource.Type.User; +private static UserResourceProvider userResourceProvider; +private static String JDBC_IN_MEMORY_URL_CREATE = +String.format("jdbc:derby:memory:myDB/%s;create=true", Configuration.DEFAULT_DERBY_SCHEMA); +private static String JDBC_IN_MEMORY_URL_DROP = +String.format("jdbc:derby:memory:myDB/%s;drop=true", Configuration.DEFAULT_DERBY_SCHEMA); + +/** + * Sets up the in-memory database for the test suite. + */ +@BeforeClass +