From d87a0fe615586cc549526e0a929dfab82849097c Mon Sep 17 00:00:00 2001 From: Gaston Dombiak Date: Thu, 14 Apr 2005 03:24:04 +0000 Subject: [PATCH] Added #testLoginWithNoResource for testing that a resource is always required by the server. git-svn-id: http://svn.igniterealtime.org/svn/repos/smack/trunk@2483 b35dd754-fafc-0310-a699-88a17e54d16e --- test/org/jivesoftware/smack/LoginTest.java | 21 +++++++++++++++++++++ 1 file changed, 21 insertions(+) diff --git a/test/org/jivesoftware/smack/LoginTest.java b/test/org/jivesoftware/smack/LoginTest.java index 8523156e2..3850177d5 100644 --- a/test/org/jivesoftware/smack/LoginTest.java +++ b/test/org/jivesoftware/smack/LoginTest.java @@ -76,6 +76,27 @@ public class LoginTest extends SmackTestCase { } } + /** + * Check that the server does not allow to log in without specifying a resource. + */ + public void testLoginWithNoResource() { + try { + XMPPConnection conn = new XMPPConnection(getHost(), getPort()); + try { + conn.getAccountManager().createAccount("user_1", "user_1"); + } catch (XMPPException e) { + // Do nothing if the accout already exists + if (e.getXMPPError().getCode() != 409) { + throw e; + } + } + conn.login("user_1", "user_1", null); + fail("User with no resource was able to log into the server"); + + } catch (XMPPException e) { + assertEquals("Wrong error code returned", 406, e.getXMPPError().getCode()); + } + } protected int getMaxConnections() { return 0;