Commit 7604d497 authored by ale's avatar ale

Use a more realistic test password

This should prove that the PAM client and the auth server are
neutral with respect to password encoding.
parent 7538b294
......@@ -16,6 +16,9 @@ from authserv import server
URL = '/api/1/auth'
# A 'difficult' password that requires encoding.
TEST_PASSWORD = 'fagiano& +"% b^rb$g~=|{;\\i'
def _relpath(x):
return os.path.join(os.path.dirname(__file__), x)
......@@ -54,8 +57,8 @@ class SSLServerTest(unittest.TestCase):
def setup_class(cls):
# set up the server in a separate process.
cls.users = {
'user': FakeUser('user', 'pass'),
'user2': FakeUser('user2', 'pass2'),
'user': FakeUser('user', TEST_PASSWORD),
'user2': FakeUser('user2', TEST_PASSWORD),
}
cls.pid = 0
......@@ -89,7 +92,7 @@ class SSLServerTest(unittest.TestCase):
req = urllib2.Request('https://localhost:%d%s' % (self.port, URL),
data=urllib.urlencode(
{'username': 'user2',
'password': 'pass2',
'password': TEST_PASSWORD,
'service': 'svc',
'source_ip': '127.0.0.1'}))
self.assertRaises(urllib2.URLError, urllib2.urlopen, req)
......@@ -98,7 +101,7 @@ class SSLServerTest(unittest.TestCase):
req = urllib2.Request('https://localhost:%d%s' % (self.port, URL),
data=urllib.urlencode(
{'username': 'user2',
'password': 'pass2',
'password': TEST_PASSWORD,
'service': 'svc',
'source_ip': '127.0.0.1'}))
resp = self.opener.open(req)
......
......@@ -9,6 +9,9 @@ extern "C" {
static const char *server = NULL;
// Must match what is in authserv/test/test_integration.py.
static const char *test_password = "fagiano& +\"% b^rb$g~=|{;\\i";
static const char *ssl_ca = "../authserv/test/testca/public/ca.pem";
static const char *ssl_cert = "../authserv/test/testca/public/certs/client.pem";
static const char *ssl_key = "../authserv/test/testca/private/client.key";
......@@ -62,7 +65,7 @@ TEST_F(AuthClientTest, AuthOK) {
result = auth_client_set_certificate(ac, ssl_ca, ssl_cert, ssl_key);
EXPECT_EQ(AC_OK, result) << "set_certificate() error: " << auth_client_strerror(result);
result = auth_client_authenticate(ac, "user", "pass", NULL, "127.0.0.1", NULL);
result = auth_client_authenticate(ac, "user", test_password, NULL, "127.0.0.1", NULL);
EXPECT_EQ(AC_OK, result) << "authenticate() error: " << auth_client_strerror(result)
<< ", server=" << server;
}
......@@ -75,7 +78,7 @@ TEST_F(AuthClientTest, ManyAuthOK) {
result = auth_client_set_certificate(ac, ssl_ca, ssl_cert, ssl_key);
EXPECT_EQ(AC_OK, result) << "set_certificate() error: " << auth_client_strerror(result);
result = auth_client_authenticate(ac, "user", "pass", NULL, "127.0.0.1", NULL);
result = auth_client_authenticate(ac, "user", test_password, NULL, "127.0.0.1", NULL);
EXPECT_EQ(AC_OK, result) << "authenticate() error: " << auth_client_strerror(result)
<< ", server=" << server;
}
......@@ -105,7 +108,7 @@ TEST_F(AuthClientTest, SSLFailsWithBadCertificate) {
result = auth_client_set_certificate(ac, ssl_ca, ssl_ca, ssl_key);
EXPECT_EQ(AC_OK, result) << "set_certificate() error: " << auth_client_strerror(result);
result = auth_client_authenticate(ac, "user", "pass", NULL, "127.0.0.1", NULL);
result = auth_client_authenticate(ac, "user", test_password, NULL, "127.0.0.1", NULL);
EXPECT_NE(AC_OK, result) << "authenticate() didn't fail, server=" << server;
}
......@@ -116,7 +119,7 @@ TEST_F(AuthClientTest, SSLFailsWithBadCAClientSide) {
result = auth_client_set_certificate(ac, ssl_bad_ca, ssl_cert, ssl_key);
EXPECT_EQ(AC_OK, result) << "set_certificate() error: " << auth_client_strerror(result);
result = auth_client_authenticate(ac, "user", "pass", NULL, "127.0.0.1", NULL);
result = auth_client_authenticate(ac, "user", test_password, NULL, "127.0.0.1", NULL);
EXPECT_NE(AC_OK, result) << "authenticate() didn't fail, server=" << server;
}
......@@ -127,7 +130,7 @@ TEST_F(AuthClientTest, SSLFailsWithBadCAServerSide) {
result = auth_client_set_certificate(ac, ssl_ca, ssl_bad_cert, ssl_bad_key);
EXPECT_EQ(AC_OK, result) << "set_certificate() error: " << auth_client_strerror(result);
result = auth_client_authenticate(ac, "user", "pass", NULL, "127.0.0.1", NULL);
result = auth_client_authenticate(ac, "user", test_password, NULL, "127.0.0.1", NULL);
EXPECT_NE(AC_OK, result) << "authenticate() didn't fail, server=" << server;
}
......@@ -147,7 +150,7 @@ TEST_F(AuthClientServerFallbackTest, AuthOK) {
result = auth_client_set_certificate(ac, ssl_ca, ssl_cert, ssl_key);
EXPECT_EQ(AC_OK, result) << "set_certificate() error: " << auth_client_strerror(result);
result = auth_client_authenticate(ac, "user", "pass", NULL, "127.0.0.1", NULL);
result = auth_client_authenticate(ac, "user", test_password, NULL, "127.0.0.1", NULL);
EXPECT_EQ(AC_OK, result) << "authenticate() error: " << auth_client_strerror(result)
<< ", server=" << server;
}
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment