Repository: openmeetings Updated Branches: refs/heads/3.3.x c2ad3ac10 -> 15ce5da19
no jira: unused HTTP methods are disabled Project: http://git-wip-us.apache.org/repos/asf/openmeetings/repo Commit: http://git-wip-us.apache.org/repos/asf/openmeetings/commit/15ce5da1 Tree: http://git-wip-us.apache.org/repos/asf/openmeetings/tree/15ce5da1 Diff: http://git-wip-us.apache.org/repos/asf/openmeetings/diff/15ce5da1 Branch: refs/heads/3.3.x Commit: 15ce5da19e724e55851c4a079db30ba5faea73a8 Parents: c2ad3ac Author: Maxim Solodovnik <[email protected]> Authored: Tue Jun 20 17:08:48 2017 +0700 Committer: Maxim Solodovnik <[email protected]> Committed: Tue Jun 20 17:08:48 2017 +0700 ---------------------------------------------------------------------- .../src/main/webapp/WEB-INF/red5-web.xml | 13 +-- .../src/main/webapp/WEB-INF/web.xml | 14 ++++ .../test/webservice/AbstractWebServiceTest.java | 7 +- .../test/webservice/TestGroupService.java | 87 ++++++++++++++++++++ .../test/webservice/TestUserService.java | 7 ++ 5 files changed, 121 insertions(+), 7 deletions(-) ---------------------------------------------------------------------- http://git-wip-us.apache.org/repos/asf/openmeetings/blob/15ce5da1/openmeetings-web/src/main/webapp/WEB-INF/red5-web.xml ---------------------------------------------------------------------- diff --git a/openmeetings-web/src/main/webapp/WEB-INF/red5-web.xml b/openmeetings-web/src/main/webapp/WEB-INF/red5-web.xml index b265961..a3e0aa2 100644 --- a/openmeetings-web/src/main/webapp/WEB-INF/red5-web.xml +++ b/openmeetings-web/src/main/webapp/WEB-INF/red5-web.xml @@ -7,21 +7,22 @@ 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. - + --> <beans xmlns="http://www.springframework.org/schema/beans" - xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" - xsi:schemaLocation="http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans.xsd"> - + xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" + xsi:schemaLocation=" + http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans.xsd" + > <bean id="placeholderConfig" class="org.springframework.beans.factory.config.PropertyPlaceholderConfigurer"> <property name="location" value="/WEB-INF/red5-web.properties" /> </bean> http://git-wip-us.apache.org/repos/asf/openmeetings/blob/15ce5da1/openmeetings-web/src/main/webapp/WEB-INF/web.xml ---------------------------------------------------------------------- diff --git a/openmeetings-web/src/main/webapp/WEB-INF/web.xml b/openmeetings-web/src/main/webapp/WEB-INF/web.xml index 2871563..b29624c 100644 --- a/openmeetings-web/src/main/webapp/WEB-INF/web.xml +++ b/openmeetings-web/src/main/webapp/WEB-INF/web.xml @@ -119,6 +119,20 @@ <web-resource-name>Forbidden</web-resource-name> <url-pattern>/uploadtemp/*</url-pattern> </web-resource-collection> + <web-resource-collection> + <web-resource-name>Forbidden</web-resource-name> + <url-pattern>/*</url-pattern> + <http-method>PUT</http-method> + <http-method>HEAD</http-method> + <http-method>PATCH</http-method> + <http-method>DELETE</http-method> + <http-method>TRACE</http-method> + </web-resource-collection> + <web-resource-collection> + <web-resource-name>Forbidden</web-resource-name> + <url-pattern>/services/*</url-pattern> + <http-method>TRACE</http-method> + </web-resource-collection> <auth-constraint/> </security-constraint> </web-app> http://git-wip-us.apache.org/repos/asf/openmeetings/blob/15ce5da1/openmeetings-web/src/test/java/org/apache/openmeetings/test/webservice/AbstractWebServiceTest.java ---------------------------------------------------------------------- diff --git a/openmeetings-web/src/test/java/org/apache/openmeetings/test/webservice/AbstractWebServiceTest.java b/openmeetings-web/src/test/java/org/apache/openmeetings/test/webservice/AbstractWebServiceTest.java index 3fcf5b0..b649613 100644 --- a/openmeetings-web/src/test/java/org/apache/openmeetings/test/webservice/AbstractWebServiceTest.java +++ b/openmeetings-web/src/test/java/org/apache/openmeetings/test/webservice/AbstractWebServiceTest.java @@ -51,9 +51,14 @@ public class AbstractWebServiceTest extends AbstractJUnitDefaults { return login(username, userpass); } - public static ServiceResult login(String user, String pass) { + public static ServiceResult loginNoCheck(String user, String pass) { ServiceResult sr = getClient(USER_SERVICE_URL).path("/login").query("user", user).query("pass", pass) .get(ServiceResult.class); + return sr; + } + + public static ServiceResult login(String user, String pass) { + ServiceResult sr = loginNoCheck(user, pass); assertEquals("Login should be successful", Type.SUCCESS.name(), sr.getType()); return sr; } http://git-wip-us.apache.org/repos/asf/openmeetings/blob/15ce5da1/openmeetings-web/src/test/java/org/apache/openmeetings/test/webservice/TestGroupService.java ---------------------------------------------------------------------- diff --git a/openmeetings-web/src/test/java/org/apache/openmeetings/test/webservice/TestGroupService.java b/openmeetings-web/src/test/java/org/apache/openmeetings/test/webservice/TestGroupService.java new file mode 100644 index 0000000..c96356c --- /dev/null +++ b/openmeetings-web/src/test/java/org/apache/openmeetings/test/webservice/TestGroupService.java @@ -0,0 +1,87 @@ +/* + * 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.openmeetings.test.webservice; + +import static org.apache.openmeetings.db.util.ApplicationHelper.getWicketTester; +import static org.junit.Assert.assertEquals; +import static org.junit.Assert.assertNotNull; + +import javax.ws.rs.core.Response; + +import org.apache.openmeetings.db.dto.basic.ServiceResult; +import org.apache.openmeetings.db.dto.basic.ServiceResult.Type; +import org.apache.openmeetings.web.app.WebSession; +import org.apache.wicket.util.tester.WicketTester; +import org.junit.After; +import org.junit.Test; + +public class TestGroupService extends AbstractWebServiceTest { + protected WicketTester tester; + public final static String GROUP_SERVICE_URL = BASE_SERVICES_URL + "/group"; + + @Override + public void setUp() throws Exception { + super.setUp(); + tester = getWicketTester(); + assertNotNull("Web session should not be null", WebSession.get()); + } + + @Test + public void putTest() { + ServiceResult r = login(); + Response resp = getClient(GROUP_SERVICE_URL) + .path("/") + .query("sid", r.getMessage()).put(""); + assertEquals("Call should NOT be successful", Response.Status.METHOD_NOT_ALLOWED.getStatusCode(), resp.getStatus()); + } + + @Test + public void addRemoveTest() { + ServiceResult r = login(); + long groupId = -1; + { + Response resp = getClient(GROUP_SERVICE_URL) + .path("/") + .query("sid", r.getMessage()).query("name", "Test Group").post(""); + assertNotNull("Valid ServiceResult should be returned", resp); + assertEquals("Call should be successful", Response.Status.OK.getStatusCode(), resp.getStatus()); + ServiceResult r1 = resp.readEntity(ServiceResult.class); + assertEquals("OM Call should be successful", r1.getType(), Type.SUCCESS.name()); + groupId = r1.getCode(); + } + //delete group created + { + Response resp = getClient(GROUP_SERVICE_URL) + .path("/" + groupId) + .query("sid", r.getMessage()).delete(); + assertNotNull("Valid ServiceResult should be returned", resp); + assertEquals("Call should be successful", Response.Status.OK.getStatusCode(), resp.getStatus()); + ServiceResult r1 = resp.readEntity(ServiceResult.class); + assertEquals("OM Call should be successful", r1.getType(), Type.SUCCESS.name()); + } + } + + @After + public void tearDown() { + if (tester != null) { + //can be null in case exception on initialization + tester.destroy(); + } + } +} http://git-wip-us.apache.org/repos/asf/openmeetings/blob/15ce5da1/openmeetings-web/src/test/java/org/apache/openmeetings/test/webservice/TestUserService.java ---------------------------------------------------------------------- diff --git a/openmeetings-web/src/test/java/org/apache/openmeetings/test/webservice/TestUserService.java b/openmeetings-web/src/test/java/org/apache/openmeetings/test/webservice/TestUserService.java index d5ac453..f1ee5b1 100644 --- a/openmeetings-web/src/test/java/org/apache/openmeetings/test/webservice/TestUserService.java +++ b/openmeetings-web/src/test/java/org/apache/openmeetings/test/webservice/TestUserService.java @@ -47,6 +47,13 @@ public class TestUserService extends AbstractWebServiceTest { } @Test + public void invalidLoginTest() { + ServiceResult r = loginNoCheck("invalid-user", "bad pass"); + assertNotNull("Valid ServiceResult should be returned", r); + assertEquals("Login should NOT be successful", Type.ERROR.name(), r.getType()); + } + + @Test public void loginTest() { ServiceResult r = login(); assertNotNull("Valid ServiceResult should be returned", r);
