1 package org.apache.archiva.web.test;
4 * Licensed to the Apache Software Foundation (ASF) under one
5 * or more contributor license agreements. See the NOTICE file
6 * distributed with this work for additional information
7 * regarding copyright ownership. The ASF licenses this file
8 * to you under the Apache License, Version 2.0 (the
9 * "License"); you may not use this file except in compliance
10 * with the License. You may obtain a copy of the License at
12 * http://www.apache.org/licenses/LICENSE-2.0
14 * Unless required by applicable law or agreed to in writing,
15 * software distributed under the License is distributed on an
16 * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
17 * KIND, either express or implied. See the License for the
18 * specific language governing permissions and limitations
22 import org.apache.archiva.web.test.parent.AbstractRepositoryTest;
23 import org.testng.annotations.Test;
25 @Test( groups = { "networkproxies" }, dependsOnMethods = { "testWithCorrectUsernamePassword" } )
26 public class NetworkProxiesTest
27 extends AbstractRepositoryTest
29 @Test( dependsOnMethods = { "testDeleteRepositoryGroup" } )
30 public void testAddNetworkProxyNullValues()
32 goToNetworkProxiesPage();
33 addNetworkProxy( "", "", "", "", "", "" );
34 assertTextPresent( "You must enter an identifier." );
35 assertTextPresent( "You must enter a protocol." );
36 assertTextPresent( "You must enter a host." );
39 @Test( dependsOnMethods = { "testAddNetworkProxyNullValues" } )
40 public void testAddNetworkProxyNullIdentifier()
42 goToNetworkProxiesPage();
43 addNetworkProxy( "", "http", "localhost", "8080", "", "" );
44 assertTextPresent( "You must enter an identifier." );
47 @Test( dependsOnMethods = { "testAddNetworkProxyNullIdentifier" } )
48 public void testAddNetworkProxyNullProtocol()
50 goToNetworkProxiesPage();
51 addNetworkProxy( "testing123", "", "localhost", "8080", "", "" );
52 assertTextPresent( "You must enter a protocol." );
55 @Test( dependsOnMethods = { "testAddNetworkProxyNullProtocol" } )
56 public void testAddNetworkProxiesNullHostname()
58 goToNetworkProxiesPage();
59 addNetworkProxy( "testing123", "http", "", "8080", "", "" );
60 assertTextPresent( "You must enter a host." );
63 @Test (dependsOnMethods = { "testAddNetworkProxiesNullHostname" } )
64 public void testAddNetworkProxiesInvalidValues()
66 goToNetworkProxiesPage();
67 addNetworkProxy( "<> \\/~+[ ]'\"", "<> ~+[ ]'\"", "<> ~+[ ]'\"", "0", "<> ~+[ ]'\"", "");
68 assertTextPresent( "Proxy id must only contain alphanumeric characters, underscores(_), dots(.), and dashes(-)." );
69 assertTextPresent( "Protocol must only contain alphanumeric characters, forward-slashes(/), back-slashes(\\), dots(.), colons(:), and dashes(-)." );
70 assertTextPresent( "Host must only contain alphanumeric characters, equals(=), question-marks(?), exclamation-points(!), ampersands(&), forward-slashes(/), back-slashes(\\), underscores(_), dots(.), colons(:), tildes(~), and dashes(-)." );
71 assertTextPresent( "Port needs to be larger than 1" );
72 assertTextPresent( "Username must only contain alphanumeric characters, at's(@), forward-slashes(/), back-slashes(\\), underscores(_), dots(.), and dashes(-)." );
75 @Test (dependsOnMethods = { "testAddNetworkProxiesInvalidValues" } )
76 public void testAddNetworkProxiesInvalidIdentifier()
78 goToNetworkProxiesPage();
79 addNetworkProxy( "<> \\/~+[ ]'\"", "http", "localhost", "8080", "", "");
80 assertTextPresent( "Proxy id must only contain alphanumeric characters, underscores(_), dots(.), and dashes(-)." );
83 @Test (dependsOnMethods = { "testAddNetworkProxiesInvalidIdentifier" } )
84 public void testAddNetworkProxiesInvalidProtocol()
86 goToNetworkProxiesPage();
87 addNetworkProxy( "testing123", "<> ~+[ ]'\"", "localhost", "8080", "", "");
88 assertTextPresent( "Protocol must only contain alphanumeric characters, forward-slashes(/), back-slashes(\\), dots(.), colons(:), and dashes(-)." );
91 @Test (dependsOnMethods = { "testAddNetworkProxiesInvalidProtocol" } )
92 public void testAddNetworkProxiesInvalidHostname()
94 goToNetworkProxiesPage();
95 addNetworkProxy( "testing123", "http", "<> ~+[ ]'\"", "8080", "", "");
96 assertTextPresent( "Host must only contain alphanumeric characters, equals(=), question-marks(?), exclamation-points(!), ampersands(&), forward-slashes(/), back-slashes(\\), underscores(_), dots(.), colons(:), tildes(~), and dashes(-)." );
99 @Test (dependsOnMethods = { "testAddNetworkProxiesInvalidHostname" } )
100 public void testAddNetworkProxiesInvalidPort()
102 goToNetworkProxiesPage();
103 addNetworkProxy( "testing123", "http", "localhost", "0", "", "");
104 assertTextPresent( "Port needs to be larger than 1" );
107 @Test (dependsOnMethods = { "testAddNetworkProxiesInvalidPort" } )
108 public void testAddNetworkProxiesInvalidUsername()
110 goToNetworkProxiesPage();
111 addNetworkProxy( "testing123", "http", "localhost", "8080", "<> ~+[ ]'\"", "");
112 assertTextPresent( "Username must only contain alphanumeric characters, at's(@), forward-slashes(/), back-slashes(\\), underscores(_), dots(.), and dashes(-)." );
115 @Test (dependsOnMethods = { "testAddNetworkProxiesInvalidUsername" } )
116 public void testAddNetworkProxiesValidValues()
118 goToNetworkProxiesPage();
119 addNetworkProxy( "testing123", "http", "localhost", "8080", "", "" );
120 assertPage( "Apache Archiva \\ Administration - Network Proxies" );
121 assertTextPresent( "testing123" );
124 @Test( dependsOnMethods = { "testAddNetworkProxiesValidValues" } )
125 public void testEditNetworkProxy()
127 editNetworkProxies( "proxy.host", "localhost" );
128 assertPage( "Apache Archiva \\ Administration - Network Proxies" );
129 assertTextPresent( "localhost" );
132 @Test( dependsOnMethods = { "testEditNetworkProxy" } )
133 public void testDeleteNetworkProxy()
135 deleteNetworkProxy();
136 assertPage( "Apache Archiva \\ Administration - Network Proxies" );
137 assertTextPresent( "There are no network proxies configured yet." );
140 @Test( dependsOnMethods = { "testDeleteNetworkProxy" } )
141 public void testAddNetworkProxyAfterDelete()
143 addNetworkProxy( "testing123", "http", "localhost", "8080", "", "" );
144 assertPage( "Apache Archiva \\ Administration - Network Proxies" );
145 assertTextPresent( "testing123" );