| <?xml version="1.0"?> |
| <!-- |
| 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 |
| |
| https://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. |
| --> |
| |
| <project name="get-test" default="antunit" xmlns:au="antlib:org.apache.ant.antunit"> |
| <import file="../antunit-base.xml" /> |
| |
| <property name="location" value="https://ant.apache.org/webtest/gettest" /> |
| <property name="unsecurelocation" value="http://ant.apache.org/webtest/gettest/http-to-https.txt" /> |
| |
| <target name="setUp"> |
| <mkdir dir="${output}" /> |
| </target> |
| |
| <target name="testSeeOtherRedirect"> |
| <sleep milliseconds="250"/> |
| <get src="${location}/other.txt" dest="${output}/other.tmp"/> |
| <au:assertTrue> |
| <resourcecount count="1"> |
| <restrict> |
| <file file="${output}/other.tmp" /> |
| <contains text="seeother redirect succeeded" /> |
| </restrict> |
| </resourcecount> |
| </au:assertTrue> |
| <au:assertLogContains text="other.txt moved to http" /> |
| </target> |
| |
| <target name="testPermanentRedirect"> |
| <sleep milliseconds="250"/> |
| <get src="${location}/permanent.txt" dest="${output}/permanent.tmp"/> |
| <au:assertTrue> |
| <resourcecount count="1"> |
| <restrict> |
| <file file="${output}/permanent.tmp" /> |
| <contains text="permanent redirect succeeded" /> |
| </restrict> |
| </resourcecount> |
| </au:assertTrue> |
| <au:assertLogContains text="permanent.txt permanently moved to http" /> |
| </target> |
| |
| <target name="testTemporaryRedirect"> |
| <sleep milliseconds="250"/> |
| <get src="${location}/temp.txt" dest="${output}/temp.txt"/> |
| <au:assertTrue> |
| <resourcecount count="1"> |
| <restrict> |
| <file file="${output}/temp.txt" /> |
| <contains text="temporary redirect succeeded" /> |
| </restrict> |
| </resourcecount> |
| </au:assertTrue> |
| <au:assertLogContains text="temp.txt moved to http" /> |
| </target> |
| |
| <target name="testStatusCode307Redirect"> |
| <sleep milliseconds="250"/> |
| <get src="${location}/307.txt" dest="${output}/307.txt"/> |
| <au:assertTrue> |
| <resourcecount count="1"> |
| <restrict> |
| <file file="${output}/307.txt" /> |
| <contains text="307 status code redirect succeeded" /> |
| </restrict> |
| </resourcecount> |
| </au:assertTrue> |
| <au:assertLogContains text="307.txt moved to http" /> |
| </target> |
| |
| <target name="test5LevelsOfRedirect"> |
| <sleep milliseconds="250"/> |
| <get src="${location}/redir5.txt" dest="${output}/redir5.tmp"/> |
| <au:assertTrue> |
| <resourcecount count="1"> |
| <restrict> |
| <file file="${output}/redir5.tmp" /> |
| <contains text="5 levels of redirect succeeded" /> |
| </restrict> |
| </resourcecount> |
| </au:assertTrue> |
| |
| <au:assertLogContains text="redir5.txt moved to http" /> |
| |
| <au:assertLogContains text="redir5-4.txt moved to http" /> |
| </target> |
| |
| |
| <target name="testInfiniteRedirect" unless="jenkins"> |
| <sleep milliseconds="250"/> |
| <au:expectfailure expectedmessage="More than 25 times redirected, giving up"> |
| <get src="${location}/infinite.txt" dest="${output}/infinite.tmp"/> |
| </au:expectfailure> |
| </target> |
| |
| |
| <target name="testNestedResources"> |
| <sleep milliseconds="250"/> |
| <get dest="${output}/downloads"> |
| <url url="https://ant.apache.org/index.html"/> |
| <url url="https://ant.apache.org/faq.html"/> |
| </get> |
| <au:assertFileExists file="${output}/downloads/index.html"/> |
| <au:assertFileExists file="${output}/downloads/faq.html"/> |
| </target> |
| |
| <target name="XtestRelativeRedirect"> |
| <sleep milliseconds="250"/> |
| <get src="${location}/local.cgi" dest="${output}/other.tmp"/> |
| <au:assertTrue> |
| <resourcecount count="1"> |
| <restrict> |
| <file file="${output}/other.tmp" /> |
| <contains text="local redirect succeeded"/> |
| </restrict> |
| </resourcecount> |
| </au:assertTrue> |
| <au:assertLogContains text="local.cgi moved to http" /> |
| </target> |
| |
| <target name="testHttpToHttpsRedirect" description="Tests that a resource that's redirected |
| from HTTP to HTTPS works without an error. See bugzilla-62499 for details"> |
| <sleep milliseconds="250"/> |
| <get src="${unsecurelocation}" dest="${output}/http-to-https-redirect.tmp"/> |
| <au:assertFileExists file="${output}/http-to-https-redirect.tmp"/> |
| <au:assertTrue> |
| <resourcecontains resource="${output}/http-to-https-redirect.tmp" substring="hello world"/> |
| </au:assertTrue> |
| </target> |
| </project> |