From f6322e4b96c589b968c18953cd454dd12bde2c18 Mon Sep 17 00:00:00 2001 From: Jelmer Vernooij Date: Wed, 21 Nov 2007 11:56:41 +0100 Subject: r26069: Import python bindings for credentials. (This used to be commit 97bb235cc8c2855a0903bbd9dee53f0e03c4adc0) --- source4/auth/credentials/tests/bindings.py | 84 ++++++++++++++++++++++++++++++ 1 file changed, 84 insertions(+) create mode 100644 source4/auth/credentials/tests/bindings.py (limited to 'source4/auth/credentials/tests/bindings.py') diff --git a/source4/auth/credentials/tests/bindings.py b/source4/auth/credentials/tests/bindings.py new file mode 100644 index 0000000000..9bb49a12a5 --- /dev/null +++ b/source4/auth/credentials/tests/bindings.py @@ -0,0 +1,84 @@ +#!/usr/bin/python + +# Unix SMB/CIFS implementation. +# Copyright (C) Jelmer Vernooij 2007 +# +# This program is free software; you can redistribute it and/or modify +# it under the terms of the GNU General Public License as published by +# the Free Software Foundation; either version 3 of the License, or +# (at your option) any later version. +# +# This program is distributed in the hope that it will be useful, +# but WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +# GNU General Public License for more details. +# +# You should have received a copy of the GNU General Public License +# along with this program. If not, see . +# + +"""Tests for the Credentials Python bindings. + +Note that this just tests the bindings work. It does not intend to test +the functionality, that's already done in other tests. +""" + +import unittest +import credentials + +class CredentialsTests(unittest.TestCase): + def setUp(self): + self.creds = credentials.Credentials() + + def test_set_username(self): + self.creds.set_username("somebody") + self.assertEquals("somebody", self.creds.get_username()) + + def test_set_password(self): + self.creds.set_password("S3CreT") + self.assertEquals("S3CreT", self.creds.get_password()) + + def test_set_domain(self): + self.creds.set_domain("ABMAS") + self.assertEquals("ABMAS", self.creds.get_domain()) + + def test_set_realm(self): + self.creds.set_realm("myrealm") + self.assertEquals("MYREALM", self.creds.get_realm()) + + def test_parse_string_anon(self): + self.creds.parse_string("%") + self.assertEquals("", self.creds.get_username()) + self.assertEquals(None, self.creds.get_password()) + + def test_parse_string_user_pw_domain(self): + self.creds.parse_string("dom\\someone%secr") + self.assertEquals("someone", self.creds.get_username()) + self.assertEquals("secr", self.creds.get_password()) + self.assertEquals("DOM", self.creds.get_domain()) + + def test_bind_dn(self): + self.assertEquals(None, self.creds.get_bind_dn()) + self.creds.set_bind_dn("dc=foo,cn=bar") + self.assertEquals("dc=foo,cn=bar", self.creds.get_bind_dn()) + + def test_is_anon(self): + self.creds.set_username("") + self.assertTrue(self.creds.is_anonymous()) + self.creds.set_username("somebody") + self.assertFalse(self.creds.is_anonymous()) + + def test_workstation(self): + # FIXME: This is uninitialised, it should be None + #self.assertEquals(None, self.creds.get_workstation()) + self.creds.set_workstation("myworksta") + self.assertEquals("myworksta", self.creds.get_workstation()) + + def test_get_nt_hash(self): + self.creds.set_password("geheim") + self.assertEquals('\xc2\xae\x1f\xe6\xe6H\x84cRE>\x81o*\xeb\x93', + self.creds.get_nt_hash()) + + def test_guess(self): + # Just check the method is there and doesn't raise an exception + self.creds.guess() -- cgit From 0e191fa26ab6f0f4119eccca0170e5ebd7f46382 Mon Sep 17 00:00:00 2001 From: Jelmer Vernooij Date: Thu, 29 Nov 2007 16:01:11 +0100 Subject: r26204: Binsings for some more functions. (This used to be commit ab6be3086f7ad8c22e6f4805bccad5a04c0325f2) --- source4/auth/credentials/tests/bindings.py | 8 ++++++++ 1 file changed, 8 insertions(+) (limited to 'source4/auth/credentials/tests/bindings.py') diff --git a/source4/auth/credentials/tests/bindings.py b/source4/auth/credentials/tests/bindings.py index 9bb49a12a5..6253e8fbad 100644 --- a/source4/auth/credentials/tests/bindings.py +++ b/source4/auth/credentials/tests/bindings.py @@ -82,3 +82,11 @@ class CredentialsTests(unittest.TestCase): def test_guess(self): # Just check the method is there and doesn't raise an exception self.creds.guess() + + def test_authentication_requested(self): + self.assertFalse(self.creds.authentication_requested()) + + def test_wrong_password(self): + self.assertTrue(self.creds.wrong_password()) + self.assertTrue(self.creds.wrong_password()) + self.assertFalse(self.creds.wrong_password()) -- cgit From bd9e8e9ae1123041fffbf270178c4fa8cc5e1fc0 Mon Sep 17 00:00:00 2001 From: Jelmer Vernooij Date: Thu, 6 Dec 2007 21:40:00 +0100 Subject: r26321: Fix python tests. (This used to be commit f9bf02fd5ce76dfb08950dc4a016fa886f2f4dd5) --- source4/auth/credentials/tests/bindings.py | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) (limited to 'source4/auth/credentials/tests/bindings.py') diff --git a/source4/auth/credentials/tests/bindings.py b/source4/auth/credentials/tests/bindings.py index 6253e8fbad..8312e77e9e 100644 --- a/source4/auth/credentials/tests/bindings.py +++ b/source4/auth/credentials/tests/bindings.py @@ -84,9 +84,10 @@ class CredentialsTests(unittest.TestCase): self.creds.guess() def test_authentication_requested(self): + self.creds.set_username("") self.assertFalse(self.creds.authentication_requested()) + self.creds.set_username("somebody") + self.assertTrue(self.creds.authentication_requested()) def test_wrong_password(self): - self.assertTrue(self.creds.wrong_password()) - self.assertTrue(self.creds.wrong_password()) self.assertFalse(self.creds.wrong_password()) -- cgit From 9a3cbd276bc60afa254a64216435f7448b8c453f Mon Sep 17 00:00:00 2001 From: Jelmer Vernooij Date: Thu, 24 Jan 2008 01:05:19 +0100 Subject: python: Add bindings for cli_credentials_set_cmdline_callbacks(). (This used to be commit 557207f86ba901262e76704df5c51888b2737ddf) --- source4/auth/credentials/tests/bindings.py | 3 +++ 1 file changed, 3 insertions(+) (limited to 'source4/auth/credentials/tests/bindings.py') diff --git a/source4/auth/credentials/tests/bindings.py b/source4/auth/credentials/tests/bindings.py index 8312e77e9e..d2ca68d115 100644 --- a/source4/auth/credentials/tests/bindings.py +++ b/source4/auth/credentials/tests/bindings.py @@ -83,6 +83,9 @@ class CredentialsTests(unittest.TestCase): # Just check the method is there and doesn't raise an exception self.creds.guess() + def test_set_cmdline_callbacks(self): + self.creds.set_cmdline_callbacks() + def test_authentication_requested(self): self.creds.set_username("") self.assertFalse(self.creds.authentication_requested()) -- cgit From 142fbfb3c1f9f8cda7f0edaa801f8345f23d805f Mon Sep 17 00:00:00 2001 From: Andrew Bartlett Date: Fri, 28 Mar 2008 21:57:15 +1100 Subject: Fix and test python scripts and kerberos This fixes up the python credentials interface in a number of areas, with the aim of supporting '-k yes' as a command line option. (This enables the use of kerberos). As such, I've had to change the get_credentials call to take a loadparm context, so that the credentials can be initialised correctly. The test_kinit script has been modified to prove that this continues to work, as well as to provide greater code coverage of the kerberos paths. Andrew Bartlett (This used to be commit 727ef40c2b56910028ef3c1092b8eab1bfa6ce63) --- source4/auth/credentials/tests/bindings.py | 2 ++ 1 file changed, 2 insertions(+) (limited to 'source4/auth/credentials/tests/bindings.py') diff --git a/source4/auth/credentials/tests/bindings.py b/source4/auth/credentials/tests/bindings.py index d2ca68d115..d0a99502c1 100644 --- a/source4/auth/credentials/tests/bindings.py +++ b/source4/auth/credentials/tests/bindings.py @@ -67,6 +67,8 @@ class CredentialsTests(unittest.TestCase): self.assertTrue(self.creds.is_anonymous()) self.creds.set_username("somebody") self.assertFalse(self.creds.is_anonymous()) + self.creds.set_anonymous() + self.assertTrue(self.creds.is_anonymous()) def test_workstation(self): # FIXME: This is uninitialised, it should be None -- cgit From 49706ab19bd3ffd6125639e6a7753b2350cf54e1 Mon Sep 17 00:00:00 2001 From: Jelmer Vernooij Date: Wed, 21 May 2008 23:59:34 +0200 Subject: Move more modules inside of the samba package. (This used to be commit 9b39e99f48266a54ed0b8890c2efde218b4b118a) --- source4/auth/credentials/tests/bindings.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'source4/auth/credentials/tests/bindings.py') diff --git a/source4/auth/credentials/tests/bindings.py b/source4/auth/credentials/tests/bindings.py index d0a99502c1..30120b3a60 100644 --- a/source4/auth/credentials/tests/bindings.py +++ b/source4/auth/credentials/tests/bindings.py @@ -24,7 +24,7 @@ the functionality, that's already done in other tests. """ import unittest -import credentials +from samba import credentials class CredentialsTests(unittest.TestCase): def setUp(self): -- cgit