incubator-ftpserver-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From n..@apache.org
Subject svn commit: r550082 - in /incubator/ftpserver/trunk/core/src/test/org/apache/ftpserver/clienttests: ConcatedCommandsTest.java CustomMaxLoginTest.java DefaultMaxLoginTest.java UnlimitedMaxLoginTest.java
Date Sat, 23 Jun 2007 18:35:51 GMT
Author: ngn
Date: Sat Jun 23 11:35:50 2007
New Revision: 550082

URL: http://svn.apache.org/viewvc?view=rev&rev=550082
Log:
Forgot the tests. Adding a setting to disconnect a user after a certain amount of failure
login attempts (FTPSERVER-94). Also added a configurable delay after a failed login to make
brute force attacks harder (FTPSERVER-99).


Added:
    incubator/ftpserver/trunk/core/src/test/org/apache/ftpserver/clienttests/ConcatedCommandsTest.java
  (with props)
    incubator/ftpserver/trunk/core/src/test/org/apache/ftpserver/clienttests/CustomMaxLoginTest.java
  (with props)
    incubator/ftpserver/trunk/core/src/test/org/apache/ftpserver/clienttests/DefaultMaxLoginTest.java
  (with props)
    incubator/ftpserver/trunk/core/src/test/org/apache/ftpserver/clienttests/UnlimitedMaxLoginTest.java
  (with props)

Added: incubator/ftpserver/trunk/core/src/test/org/apache/ftpserver/clienttests/ConcatedCommandsTest.java
URL: http://svn.apache.org/viewvc/incubator/ftpserver/trunk/core/src/test/org/apache/ftpserver/clienttests/ConcatedCommandsTest.java?view=auto&rev=550082
==============================================================================
--- incubator/ftpserver/trunk/core/src/test/org/apache/ftpserver/clienttests/ConcatedCommandsTest.java
(added)
+++ incubator/ftpserver/trunk/core/src/test/org/apache/ftpserver/clienttests/ConcatedCommandsTest.java
Sat Jun 23 11:35:50 2007
@@ -0,0 +1,36 @@
+/*
+ * 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.ftpserver.clienttests;
+
+import org.apache.commons.net.ftp.FTPReply;
+
+/**
+ * Tests that commands sent simultaniously are handled correctly.
+ */
+public class ConcatedCommandsTest extends ClientTestTemplate {
+
+    public void testLogin() throws Exception {
+        client.sendCommand("USER admin\r\nPASS admin");
+        
+        assertTrue(FTPReply.isPositiveCompletion(client.noop()));
+
+    }
+    
+}

Propchange: incubator/ftpserver/trunk/core/src/test/org/apache/ftpserver/clienttests/ConcatedCommandsTest.java
------------------------------------------------------------------------------
    svn:eol-style = native

Added: incubator/ftpserver/trunk/core/src/test/org/apache/ftpserver/clienttests/CustomMaxLoginTest.java
URL: http://svn.apache.org/viewvc/incubator/ftpserver/trunk/core/src/test/org/apache/ftpserver/clienttests/CustomMaxLoginTest.java?view=auto&rev=550082
==============================================================================
--- incubator/ftpserver/trunk/core/src/test/org/apache/ftpserver/clienttests/CustomMaxLoginTest.java
(added)
+++ incubator/ftpserver/trunk/core/src/test/org/apache/ftpserver/clienttests/CustomMaxLoginTest.java
Sat Jun 23 11:35:50 2007
@@ -0,0 +1,54 @@
+/*
+ * 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.ftpserver.clienttests;
+
+import java.util.Properties;
+
+import org.apache.commons.net.ftp.FTPConnectionClosedException;
+
+
+public class CustomMaxLoginTest extends ClientTestTemplate {
+    private static final String UNKNOWN_USERNAME = "foo";
+    private static final String UNKNOWN_PASSWORD = "bar";
+
+    
+    
+    protected Properties createConfig() {
+        Properties config = super.createConfig();
+        
+        config.setProperty("config.connection-manager.max-login-failures", "2");
+        return config;
+    }
+
+
+
+    public void testLogin() throws Exception {
+        assertFalse(client.login(UNKNOWN_USERNAME, UNKNOWN_PASSWORD));
+        assertFalse(client.login(UNKNOWN_USERNAME, UNKNOWN_PASSWORD));
+        
+        try {
+            client.login(UNKNOWN_USERNAME, UNKNOWN_PASSWORD);
+           
+            fail("Must be disconnected");
+        } catch(FTPConnectionClosedException e) {
+            // OK
+        }
+    }
+}

Propchange: incubator/ftpserver/trunk/core/src/test/org/apache/ftpserver/clienttests/CustomMaxLoginTest.java
------------------------------------------------------------------------------
    svn:eol-style = native

Added: incubator/ftpserver/trunk/core/src/test/org/apache/ftpserver/clienttests/DefaultMaxLoginTest.java
URL: http://svn.apache.org/viewvc/incubator/ftpserver/trunk/core/src/test/org/apache/ftpserver/clienttests/DefaultMaxLoginTest.java?view=auto&rev=550082
==============================================================================
--- incubator/ftpserver/trunk/core/src/test/org/apache/ftpserver/clienttests/DefaultMaxLoginTest.java
(added)
+++ incubator/ftpserver/trunk/core/src/test/org/apache/ftpserver/clienttests/DefaultMaxLoginTest.java
Sat Jun 23 11:35:50 2007
@@ -0,0 +1,42 @@
+/*
+ * 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.ftpserver.clienttests;
+
+import org.apache.commons.net.ftp.FTPConnectionClosedException;
+
+
+public class DefaultMaxLoginTest extends ClientTestTemplate {
+    private static final String UNKNOWN_USERNAME = "foo";
+    private static final String UNKNOWN_PASSWORD = "bar";
+
+    public void testLogin() throws Exception {
+        assertFalse(client.login(UNKNOWN_USERNAME, UNKNOWN_PASSWORD));
+        assertFalse(client.login(UNKNOWN_USERNAME, UNKNOWN_PASSWORD));
+        assertFalse(client.login(UNKNOWN_USERNAME, UNKNOWN_PASSWORD));
+        
+        try {
+            client.login(UNKNOWN_USERNAME, UNKNOWN_PASSWORD);
+           
+            fail("Must be disconnected");
+        } catch(FTPConnectionClosedException e) {
+            // OK
+        }
+    }
+}

Propchange: incubator/ftpserver/trunk/core/src/test/org/apache/ftpserver/clienttests/DefaultMaxLoginTest.java
------------------------------------------------------------------------------
    svn:eol-style = native

Added: incubator/ftpserver/trunk/core/src/test/org/apache/ftpserver/clienttests/UnlimitedMaxLoginTest.java
URL: http://svn.apache.org/viewvc/incubator/ftpserver/trunk/core/src/test/org/apache/ftpserver/clienttests/UnlimitedMaxLoginTest.java?view=auto&rev=550082
==============================================================================
--- incubator/ftpserver/trunk/core/src/test/org/apache/ftpserver/clienttests/UnlimitedMaxLoginTest.java
(added)
+++ incubator/ftpserver/trunk/core/src/test/org/apache/ftpserver/clienttests/UnlimitedMaxLoginTest.java
Sat Jun 23 11:35:50 2007
@@ -0,0 +1,52 @@
+/*
+ * 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.ftpserver.clienttests;
+
+import java.util.Properties;
+
+import org.apache.commons.net.ftp.FTPConnectionClosedException;
+
+
+public class UnlimitedMaxLoginTest extends ClientTestTemplate {
+    private static final String UNKNOWN_USERNAME = "foo";
+    private static final String UNKNOWN_PASSWORD = "bar";
+
+    
+    
+    protected Properties createConfig() {
+        Properties config = super.createConfig();
+        
+        config.setProperty("config.connection-manager.max-login-failures", "0");
+        return config;
+    }
+
+
+
+    public void testLogin() throws Exception {
+        // must never be disconnected
+        assertFalse(client.login(UNKNOWN_USERNAME, UNKNOWN_PASSWORD));
+        assertFalse(client.login(UNKNOWN_USERNAME, UNKNOWN_PASSWORD));
+        assertFalse(client.login(UNKNOWN_USERNAME, UNKNOWN_PASSWORD));
+        assertFalse(client.login(UNKNOWN_USERNAME, UNKNOWN_PASSWORD));
+        assertFalse(client.login(UNKNOWN_USERNAME, UNKNOWN_PASSWORD));
+        assertFalse(client.login(UNKNOWN_USERNAME, UNKNOWN_PASSWORD));
+        assertFalse(client.login(UNKNOWN_USERNAME, UNKNOWN_PASSWORD));
+    }
+}

Propchange: incubator/ftpserver/trunk/core/src/test/org/apache/ftpserver/clienttests/UnlimitedMaxLoginTest.java
------------------------------------------------------------------------------
    svn:eol-style = native



Mime
View raw message