summaryrefslogtreecommitdiff
path: root/python/samba/tests/credentials.py
AgeCommit message (Collapse)AuthorFilesLines
2025-08-25auth:creds: Make sure to uppercase the realm of a principalAndreas Schneider1-2/+2
BUG: https://bugzilla.samba.org/show_bug.cgi?id=15893 Signed-off-by: Andreas Schneider <asn@samba.org> Reviewed-by: Alexander Bokovoy <ab@samba.org>
2025-08-05auth:creds: Make sure when parsing username that realm is uppercaseAndreas Schneider1-2/+2
Signed-off-by: Andreas Schneider <asn@samba.org> Reviewed-by: Alexander Bokovoy <ab@samba.org>
2023-11-30python: tests: update all super calls to python 3 style in testsRob van der Linde1-1/+1
Signed-off-by: Rob van der Linde <rob@catalyst.net.nz> Reviewed-by: Douglas Bagnall <douglas.bagnall@catalyst.net.nz> Reviewed-by: Andrew Bartlett <abartlet@samba.org> [abartlet@samba.org Some python2 style super() calls remain due to being an actual, even if reasonable, behaviour change]
2020-11-05Revert "cli_credentials_parse_string: fix parsing of principals"Alexander Bokovoy1-2/+2
This reverts commit eb0474d27bae4592b25ac6bf600da29c6a1cb9f8.
2020-11-04cli_credentials_parse_string: fix parsing of principalsAlexander Bokovoy1-2/+2
When parsing a principal-like name, user name was left with full principal instead of taking only the left part before '@' sign. >>> from samba import credentials >>> t = credentials.Credentials() >>> t.parse_string('admin@realm.test', credentials.SPECIFIED) >>> t.get_username() 'admin@realm.test' The issue is that cli_credentials_set_username() does a talloc_strdup() of the argument, so we need to change order of assignment to allow talloc_strdup() to copy the right part of the string. Signed-off-by: Alexander Bokovoy <ab@samba.org> Reviewed-by: Andreas Schneider <asn@samba.org> Reviewed-by: Stefan Metzmacher <metze@samba.org>
2020-08-19auth:creds: Add python bindings for cli_credentials_set_conf()Andreas Schneider1-0/+33
Signed-off-by: Andreas Schneider <asn@samba.org> Reviewed-by: Stefan Metzmacher <metze@samba.org>
2020-08-19auth:creds: Add python bindings for (get|set)_smb_encryptionAndreas Schneider1-0/+6
Signed-off-by: Andreas Schneider <asn@samba.org> Reviewed-by: Stefan Metzmacher <metze@samba.org>
2020-08-19auth:creds: Add python bindings for (get|set)_smb_ipc_signingAndreas Schneider1-0/+6
Signed-off-by: Andreas Schneider <asn@samba.org> Reviewed-by: Stefan Metzmacher <metze@samba.org>
2020-08-19auth:creds: Add python bindings for (get|set)_smb_signingAndreas Schneider1-0/+6
Signed-off-by: Andreas Schneider <asn@samba.org> Reviewed-by: Stefan Metzmacher <metze@samba.org>
2020-08-19auth:creds: Introduce CRED_SMB_CONFStefan Metzmacher1-2/+2
We have several places where we check '> CRED_UNINITIALISED', so we better don't use CRED_UNINITIALISED for values from our smb.conf. Signed-off-by: Stefan Metzmacher <metze@samba.org> Reviewed-by: Andreas Schneider <asn@samba.org>
2020-08-11python compat: reduce use of 'if PY3:'Douglas Bagnall1-13/+5
Signed-off-by: Douglas Bagnall <douglas.bagnall@catalyst.net.nz> Reviewed-by: Noel Power <npower@samba.org>
2018-11-01python/tests/credentials: remove unused variablesDouglas Bagnall1-4/+0
Signed-off-by: Douglas Bagnall <douglas.bagnall@catalyst.net.nz> Reviewed-by: Noel Power <noel.power@suse.com>
2018-08-24PEP8: fix E303: too many blank lines (2)Joe Guo1-2/+0
Signed-off-by: Joe Guo <joeg@catalyst.net.nz> Reviewed-by: Andrew Bartlett <abartlet@samba.org> Reviewed-by: Douglas Bagnall <douglas.bagnall@catalyst.net.nz>
2018-08-24PEP8: fix E302: expected 2 blank lines, found 1Joe Guo1-0/+1
Signed-off-by: Joe Guo <joeg@catalyst.net.nz> Reviewed-by: Andrew Bartlett <abartlet@samba.org> Reviewed-by: Douglas Bagnall <douglas.bagnall@catalyst.net.nz>
2018-08-24PEP8: fix E225: missing whitespace around operatorJoe Guo1-31/+31
Signed-off-by: Joe Guo <joeg@catalyst.net.nz> Reviewed-by: Andrew Bartlett <abartlet@samba.org> Reviewed-by: Douglas Bagnall <douglas.bagnall@catalyst.net.nz>
2018-05-12selftest: Add a test for creds.{get,set}_secure_channel_type()Andrew Bartlett1-0/+8
Signed-off-by: Andrew Bartlett <abartlet@samba.org> Reviewed-by: Garming Sam <garming@catalyst.net.nz>
2017-03-29pycredentials: Add bindings for get_ntlm_response()Andrew Bartlett1-0/+21
This should make testing of SamLogon from python practical Signed-off-by: Andrew Bartlett <abartlet@samba.org>
2017-03-10python: samba.tests.credentials: Python 3 compatible testsLumir Balhar1-9/+17
Port test of pycredentials to Python 3 compatible form. Signed-off-by: Lumir Balhar <lbalhar@redhat.com> Reviewed-by: Andrew Bartlett <abartlet@samba.org> Reviewed-by: Douglas Bagnall <douglas.bagnall@catalyst.net.nz>
2016-12-20tests/credentials.py: demonstrate the last 'username' line of ↵Stefan Metzmacher1-0/+50
creds.parse_file() beats other lines Signed-off-by: Stefan Metzmacher <metze@samba.org> Reviewed-by: Andrew Bartlett <abartlet@samba.org>
2016-12-20tests/credentials.py: verify the new cli_credentials_parse_file() 'username' ↵Stefan Metzmacher1-0/+49
parsing Signed-off-by: Stefan Metzmacher <metze@samba.org> Reviewed-by: Andrew Bartlett <abartlet@samba.org>
2016-12-20tests/credentials.py: add tests to verify realm/principal behaviour of ↵Stefan Metzmacher1-1/+49
cli_credentials_parse_string() Signed-off-by: Stefan Metzmacher <metze@samba.org> Reviewed-by: Andrew Bartlett <abartlet@samba.org>
2016-12-20auth/credentials: let cli_credentials_parse_string() always reset username ↵Stefan Metzmacher1-4/+4
and domain If cli_credentials_parse_string() is used we should no longer use any guessed values and need to make sure username and domain are reset if principal and realm are set. Signed-off-by: Stefan Metzmacher <metze@samba.org> Reviewed-by: Andrew Bartlett <abartlet@samba.org>
2016-12-20tests/credentials.py: add tests with a realm from smb.confStefan Metzmacher1-1/+16
As we don't want to create a new smb.conf file we just simulate it with "creds.set_realm(realm, credentials.UNINITIALISED)". That's basically the same as the cli_credentials_set_conf() behaviour if a realm is specified in the configuration. Signed-off-by: Stefan Metzmacher <metze@samba.org> Reviewed-by: Andrew Bartlett <abartlet@samba.org>
2016-12-20auth/credentials: handle situations without a configured (default) realmStefan Metzmacher1-5/+14
We should not have cli_credentials_get_realm() return "" without a configured (default) realm in smb.conf. Note that the existing tests with creds.get_realm() == lp.get("realm") also work with "" as string. At the same time we should never let cli_credentials_get_principal() return "@REALM.EXAMPLE.COM" nor "username@". If cli_credentials_parse_string() gets "OTHERDOMAIN\username" we must not use cli_credentials_get_realm() to generate a principal unless cli_credentials_get_domain() returns also "OTHERDOMAIN". What we need to do is using username@OTHERDOMAIN as principal, whild we still use cli_credentials_get_realm to get a default kdc, (which may route us to the correct kdc with WRONG_REALM messages). Signed-off-by: Stefan Metzmacher <metze@samba.org> Reviewed-by: Andrew Bartlett <abartlet@samba.org>
2016-12-20tests/credentials.py: add very simple test for py_creds_parse_fileStefan Metzmacher1-1/+23
Signed-off-by: Stefan Metzmacher <metze@samba.org> Reviewed-by: Andrew Bartlett <abartlet@samba.org>
2016-12-20tests/credentials.py: verify the difference of parse_string("someone") and ↵Stefan Metzmacher1-0/+10
parse_string("someone%") Signed-off-by: Stefan Metzmacher <metze@samba.org> Reviewed-by: Andrew Bartlett <abartlet@samba.org>
2016-12-20tests/credentials.py: add test for ↵Stefan Metzmacher1-2/+14
cli_credentials_set_password_will_be_nt_hash() Signed-off-by: Stefan Metzmacher <metze@samba.org> Reviewed-by: Andrew Bartlett <abartlet@samba.org>
2016-11-07credentials: Add test for credentials behaviourAndrew Bartlett1-4/+100
Signed-off-by: Andrew Bartlett <abartlet@samba.org> Reviewed-by: Garming Sam <garming@catalyst.net.nz> Autobuild-User(master): Garming Sam <garming@samba.org> Autobuild-Date(master): Mon Nov 7 03:51:11 CET 2016 on sn-devel-144
2016-11-06python: samba.tests.credentials: Add testsLumir Balhar1-0/+17
Newly tested functions: - set_utf16_password - set_old_password - get_old_password - set_old_utf16_password Signed-off-by: Lumir Balhar <lbalhar@redhat.com> Reviewed-by: Garming Sam <garming@catalyst.net.nz> Reviewed-by: Andrew Bartlett <abartlet@samba.org>
2016-11-06python: samba.tests.credentials: Fix DeprecationWarningLumir Balhar1-15/+15
For historical reasons, TestCase methods have some aliases which are deprecated since Python 2.7. Change "assertEquals" to the preferred name, "assertEqual". Deprecation notice: https://docs.python.org/2/library/unittest.html#deprecated-aliases Signed-off-by: Lumir Balhar <lbalhar@redhat.com> Reviewed-by: Garming Sam <garming@catalyst.net.nz> Reviewed-by: Andrew Bartlett <abartlet@samba.org>
2013-03-02Move python modules from source4/scripting/python/ to python/.Jelmer Vernooij1-0/+98
Reviewed-by: Andrew Bartlett <abartlet@samba.org> Autobuild-User(master): Andrew Bartlett <abartlet@samba.org> Autobuild-Date(master): Sat Mar 2 03:57:34 CET 2013 on sn-devel-104