summaryrefslogtreecommitdiff
path: root/python
Commit message (Collapse)AuthorAgeFilesLines
...
* pytest dns_aging: add simple delete testsDouglas Bagnall2021-06-221-0/+131
| | | | | | | | | | When records are added and deleted and added again, Windows gets all kinds of ideas about what should happen, and many of our tests explore that. Here we focus the simplest case with a variety of timestamp combinations. Signed-off-by: Douglas Bagnall <douglas.bagnall@catalyst.net.nz> Reviewed-by: Andrew Bartlett <abartlet@samba.org>
* pytest: samba-tool dns: allow identical updatesDouglas Bagnall2021-06-221-18/+14
| | | | | | | | We know this should work from tests of the underlying RPC calls on Windows (see dns_aging). Signed-off-by: Douglas Bagnall <douglas.bagnall@catalyst.net.nz> Reviewed-by: Andrew Bartlett <abartlet@samba.org>
* pytest: samba-tool dns: allow valid updatesDouglas Bagnall2021-06-221-0/+3
| | | | | | | | | | | | | | | Without this patch we will get errors like this when in-place RPC updates start to work: AssertionError: unexpectedly None : Successfully updated record '192.168.0.1' to '192.168.0.1', even though the latter is of type 'A' where 'A' was expected. That's because we have always rejected updates that try to modify an existing record. We shouldn't. Signed-off-by: Douglas Bagnall <douglas.bagnall@catalyst.net.nz> Reviewed-by: Andrew Bartlett <abartlet@samba.org>
* pytest: dns_aging: test delete multiple recordsDouglas Bagnall2021-06-221-3/+88
| | | | | | | | Using dns.DNS_QCLASS_ANY we can delete all the records of a certain type. What happens to other timestamps? The answer should be nothing. Signed-off-by: Douglas Bagnall <douglas.bagnall@catalyst.net.nz> Reviewed-by: Andrew Bartlett <abartlet@samba.org>
* pytest: dns_aging: test RPC updates of disparate typesDouglas Bagnall2021-06-221-1/+16
| | | | | | | | | Can a TXT record be replaced by an A record in an RPC update? According to Windows, yes. Signed-off-by: Douglas Bagnall <douglas.bagnall@catalyst.net.nz> Reviewed-by: Andrew Bartlett <abartlet@samba.org>
* python dns: dns_record_match() matches IPv6 semanticallyDouglas Bagnall2021-06-221-1/+8
| | | | | Signed-off-by: Douglas Bagnall <douglas.bagnall@catalyst.net.nz> Reviewed-by: Andrew Bartlett <abartlet@samba.org>
* python/samba/tests: Remove DCs joined to test samba-tool behaviourAndrew Bartlett2021-06-214-3/+37
| | | | | | | | | | | | | | | | | Otherwise we have the live DCs spamming the logs looking for the long-gone test servers: Failed to connect host fd00::5357:5f0b on port 135 - NT_STATUS_OBJECT_NAME_NOT_FOUND Failed to connect host fd00::5357:5f0b (6f44653d-18c8-4bf4-b2e7-6f85cf7b0f74._msdcs.addom.samba.example.com) on port 135 - NT_STATUS_OBJECT_NAME_NOT_FOUND. Failed to connect host 10.53.57.11 on port 135 - NT_STATUS_OBJECT_NAME_NOT_FOUND Failed to connect host 10.53.57.11 (6f44653d-18c8-4bf4-b2e7-6f85cf7b0f74._msdcs.addom.samba.example.com) on port 135 - NT_STATUS_OBJECT_NAME_NOT_FOUND. Failed to connect host 10.53.57.12 on port 135 - NT_STATUS_OBJECT_NAME_NOT_FOUND This avoids spamming the GitLab pipeline logs with a lot of noise, as there is a size limit to the output, as well as being cleaner. Signed-off-by: Andrew Bartlett <abartlet@samba.org> Reviewed-by: Gary Lockyer <gary@catalyst.net.nz>
* python: Streamline option parser of python toolsAndreas Schneider2021-06-202-17/+60
| | | | | | | | The python tools, especially samba-tool should have the same option set as the rest of the client utils. Signed-off-by: Andreas Schneider <asn@samba.org> Reviewed-by: Andrew Bartlett <abartlet@samba.org>
* librpc:tools: Migrate ndrdump to new cmdline option parserAndreas Schneider2021-06-201-32/+32
| | | | | Signed-off-by: Andreas Schneider <asn@samba.org> Reviewed-by: Andrew Bartlett <abartlet@samba.org>
* pytest dns_aging: test tombstone timestamp rangesDouglas Bagnall2021-06-201-1/+56
| | | | | | | | We have always used hours where we are meant to use NTTIME. Let's make sure we don't break old tombstones. Signed-off-by: Douglas Bagnall <douglas.bagnall@catalyst.net.nz> Reviewed-by: Andrew Bartlett <abartlet@samba.org>
* pytest: dns_aging: remove a test that fails on WindowsDouglas Bagnall2021-06-201-42/+0
| | | | | | | | This fails on Windows due to apparent races between the RPC, DNS, and LDAP servers. There is no point having it sit there doing nothing. Signed-off-by: Douglas Bagnall <douglas.bagnall@catalyst.net.nz> Reviewed-by: Andrew Bartlett <abartlet@samba.org>
* pytest: dns_aging: add Samba-specific scavenging testDouglas Bagnall2021-06-201-0/+85
| | | | | | | | We can't make scavenging happen on demand on Windows, so we just concentrate on Samba here. Signed-off-by: Douglas Bagnall <douglas.bagnall@catalyst.net.nz> Reviewed-by: Andrew Bartlett <abartlet@samba.org>
* pytest: dns_aging: try queries of recently tombstoned nodesDouglas Bagnall2021-06-201-0/+16
| | | | | | | Windows fails this one. Signed-off-by: Douglas Bagnall <douglas.bagnall@catalyst.net.nz> Reviewed-by: Andrew Bartlett <abartlet@samba.org>
* pytest: dns_aging tests deletions using DNS updateDouglas Bagnall2021-06-201-0/+95
| | | | | Signed-off-by: Douglas Bagnall <douglas.bagnall@catalyst.net.nz> Reviewed-by: Andrew Bartlett <abartlet@samba.org>
* pytest: dns_aging: remove/fix unused helper functionsDouglas Bagnall2021-06-201-8/+6
| | | | | | | self.rpc_delete_txt() will be used next commit. Signed-off-by: Douglas Bagnall <douglas.bagnall@catalyst.net.nz> Reviewed-by: Andrew Bartlett <abartlet@samba.org>
* pytest: dns_aging: helper to get non-tombstoned recordsDouglas Bagnall2021-06-201-0/+8
| | | | | Signed-off-by: Douglas Bagnall <douglas.bagnall@catalyst.net.nz> Reviewed-by: Andrew Bartlett <abartlet@samba.org>
* pytest: dns_aging: add helper for DNS delete updatesDouglas Bagnall2021-06-201-0/+6
| | | | | Signed-off-by: Douglas Bagnall <douglas.bagnall@catalyst.net.nz> Reviewed-by: Andrew Bartlett <abartlet@samba.org>
* pytest: dns_aging: correct typo mis-assertions in 2 testsDouglas Bagnall2021-06-201-2/+2
| | | | | Signed-off-by: Douglas Bagnall <douglas.bagnall@catalyst.net.nz> Reviewed-by: Andrew Bartlett <abartlet@samba.org>
* pytest: dns_aging: remind developers to use fl2003Douglas Bagnall2021-06-201-0/+6
| | | | | | | | | | By "developers", I of course mean "me". Other environments insist on secure updates, which these tests don't do. Signed-off-by: Douglas Bagnall <douglas.bagnall@catalyst.net.nz> Reviewed-by: Andrew Bartlett <abartlet@samba.org>
* pytest: dns_aging: use assert_timestamps_equal() widelyDouglas Bagnall2021-06-201-110/+110
| | | | | Signed-off-by: Douglas Bagnall <douglas.bagnall@catalyst.net.nz> Reviewed-by: Andrew Bartlett <abartlet@samba.org>
* pytest: add A and AAAA aging testsDouglas Bagnall2021-06-201-1/+121
| | | | | Signed-off-by: Douglas Bagnall <douglas.bagnall@catalyst.net.nz> Reviewed-by: Andrew Bartlett <abartlet@samba.org>
* pytest: adjust dns_aging to handle some non-TXT recordsDouglas Bagnall2021-06-201-11/+120
| | | | | Signed-off-by: Douglas Bagnall <douglas.bagnall@catalyst.net.nz> Reviewed-by: Andrew Bartlett <abartlet@samba.org>
* pytests: dns_aging get informative assertionsDouglas Bagnall2021-06-201-2/+47
| | | | | | | | | | | | | When trying to understand the results of these tests, it is not very helpful to have messages like: AssertionError: 3685511 != 3685343 when the only thing you want to know is the difference between these two numbers. So here we make timestamp specific assertions. Signed-off-by: Douglas Bagnall <douglas.bagnall@catalyst.net.nz> Reviewed-by: Andrew Bartlett <abartlet@samba.org>
* python:tests: Fix group_edit test with system libldbAndreas Schneider2021-06-201-1/+6
| | | | | | | | Signed-off-by: Andreas Schneider <asn@samba.org> Reviewed-by: Andrew Bartlett <abartlet@samba.org> Autobuild-User(master): Andrew Bartlett <abartlet@samba.org> Autobuild-Date(master): Sun Jun 20 22:52:05 UTC 2021 on sn-devel-184
* python:tests: Fix user_edit test with system libldbAndreas Schneider2021-06-201-1/+6
| | | | | Signed-off-by: Andreas Schneider <asn@samba.org> Reviewed-by: Andrew Bartlett <abartlet@samba.org>
* python:tests: Fix contact_edit test with system libldbAndreas Schneider2021-06-201-1/+6
| | | | | Signed-off-by: Andreas Schneider <asn@samba.org> Reviewed-by: Andrew Bartlett <abartlet@samba.org>
* samba-tool: Disable AD DC options in samba-tool domainDavid Mulder2021-06-201-14/+16
| | | | | Signed-off-by: David Mulder <dmulder@suse.com> Reviewed-by: Andrew Bartlett <abartlet@samba.org>
* netcmd: Incorrect arguments to Exception constructorGarming Sam2021-06-171-1/+1
| | | | | | | | | | | Discovered by Semmle code analysis: https://lgtm.com/projects/g/samba-team/samba Signed-off-by: Garming Sam <garming@catalyst.net.nz> Reviewed-by: Douglas Bagnall <douglas.bagnall@catalyst.net.nz> Autobuild-User(master): Douglas Bagnall <dbagnall@samba.org> Autobuild-Date(master): Thu Jun 17 05:12:03 UTC 2021 on sn-devel-184
* join: provision_fill does not return anythingGarming Sam2021-06-171-7/+7
| | | | | | | | Discovered by Semmle code analysis: https://lgtm.com/projects/g/samba-team/samba Signed-off-by: Garming Sam <garming@catalyst.net.nz> Reviewed-by: Douglas Bagnall <douglas.bagnall@catalyst.net.nz>
* pytests: add dns_aging, embracing and extending ageing testsDouglas Bagnall2021-06-111-0/+1895
| | | | | | | | | | | | | | | | This incorporates tests from various dns*.py files, but makes them correct. All but one of these tests pass against Windows 2012r2. Further patches will remove the broken tests in other files, and fix Samba so it passes these. Signed-off-by: Douglas Bagnall <douglas.bagnall@catalyst.net.nz> Reviewed-by: Andrew Bartlett <abartlet@samba.org> Autobuild-User(master): Andrew Bartlett <abartlet@samba.org> Autobuild-Date(master): Fri Jun 11 09:29:23 UTC 2021 on sn-devel-184
* py: samba.dnsserver: add helper for record buffersDouglas Bagnall2021-06-111-0/+7
| | | | | | | We *always* make these steps when we get a record. Signed-off-by: Douglas Bagnall <douglas.bagnall@catalyst.net.nz> Reviewed-by: Andrew Bartlett <abartlet@samba.org>
* pytest:dns_base: make_txt_update can set arbitrary TTLDouglas Bagnall2021-06-111-3/+3
| | | | | | | Also, improve a variable name. Signed-off-by: Douglas Bagnall <douglas.bagnall@catalyst.net.nz> Reviewed-by: Andrew Bartlett <abartlet@samba.org>
* python:subunit: Avoid misleading "Test was never started" error messageJoseph Sutton2021-06-111-67/+84
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | subunithelper.py keeps track of tests that have been started, and displays an error message if a test reports an outcome without having previously been started. However, it makes the assumption that a test has finished once it has reported a single outcome. This means that a misleading error message will be displayed if it receives multiple outcomes from the same test (which can happen if a test using the Python unittest framework does not complete successfully, and the cleanup subsequently fails), and any actual errors from the cleanup remain undisplayed. This commit ensures that only a single outcome is reported for each test, and only after the test has finished. Outcomes are buffered up until the stopTest() function is called, when a single outcome is determined and all errors received for that test are output. FilterOps still needs to output test outcomes immediately rather than buffering them, otherwise they are never picked up and passed on to the remote test case by subunithelper.parse_results(). This would result in an error as the test would be considered to have never finished. Example subunitrun output before the change: time: 2021-04-28 01:28:49.862123Z test: samba.tests.example.ExampleTests.test time: 2021-04-28 01:28:49.862215Z failure: samba.tests.example.ExampleTests.test [ Traceback (most recent call last): File "bin/python/samba/tests/example.py", line 28, in test self.fail() AssertionError: None ] time: 2021-04-28 01:28:49.862407Z failure: samba.tests.example.ExampleTests.test [ Traceback (most recent call last): File "bin/python/samba/tests/example.py", line 31, in tearDown self.fail() AssertionError: None ] time: 2021-04-28 01:28:49.862467Z time: 2021-04-28 01:28:49.862510Z and after: time: 2021-04-28 01:29:19.949347Z test: samba.tests.example.ExampleTests.test time: 2021-04-28 01:29:19.949440Z time: 2021-04-28 01:29:19.949590Z time: 2021-04-28 01:29:19.949640Z failure: samba.tests.example.ExampleTests.test [ Traceback (most recent call last): File "bin/python/samba/tests/example.py", line 28, in test self.fail() AssertionError: None Traceback (most recent call last): File "bin/python/samba/tests/example.py", line 31, in tearDown self.fail() AssertionError: None ] time: 2021-04-28 01:29:19.949702Z Signed-off-by: Joseph Sutton <josephsutton@catalyst.net.nz> Reviewed-by: Andreas Schneider <asn@samba.org> Reviewed-by: Andrew Bartlett <abartlet@samba.org>
* python:subunit: Remove write_traceback()Joseph Sutton2021-06-111-44/+7
| | | | | | | | | This functionality is already present in the Python unittest framework, and so is not necessary to include here. Signed-off-by: Joseph Sutton <josephsutton@catalyst.net.nz> Reviewed-by: Andreas Schneider <asn@samba.org> Reviewed-by: Andrew Bartlett <abartlet@samba.org>
* python:subunit: Fix skipping a test with no reason givenJoseph Sutton2021-06-111-2/+2
| | | | | | | | | | Not specifying a reason means addSkip() is passed an empty string rather than None. As a result, this condition was never hit, and the call to _addOutcome() had an incorrect parameter. Signed-off-by: Joseph Sutton <josephsutton@catalyst.net.nz> Reviewed-by: Andreas Schneider <asn@samba.org> Reviewed-by: Andrew Bartlett <abartlet@samba.org>
* dbcheck: formattingJoseph Sutton2021-06-111-12/+22
| | | | | | | | | | | Reduce the length of some lines to 79 characters or less. Signed-off-by: Joseph Sutton <josephsutton@catalyst.net.nz> Reviewed-by: Andrew Bartlett <abartlet@samba.org> Reviewed-by: Douglas Bagnall <douglas.bagnall@catalyst.net.nz> Autobuild-User(master): Andrew Bartlett <abartlet@samba.org> Autobuild-Date(master): Fri Jun 11 08:28:28 UTC 2021 on sn-devel-184
* dbcheck: Refactor RID Set check to use free_rid_bounds()Joseph Sutton2021-06-111-28/+24
| | | | | | | | | | | This function provides a simpler method of getting the bounds of the range of RIDs we want to check. We also now check that the low bound is less than the high bound for both rIDAllocationPool and rIDPreviousAllocationPool. Signed-off-by: Joseph Sutton <josephsutton@catalyst.net.nz> Reviewed-by: Andrew Bartlett <abartlet@samba.org> Reviewed-by: Douglas Bagnall <douglas.bagnall@catalyst.net.nz>
* netcmd: Avoid conflicting SIDs when creating an offline backupJoseph Sutton2021-06-111-1/+2
| | | | | | | | | | | | | | | | | To allow the new DC object to be created in a restored domain while avoiding conflicts with existing SIDS, we fetch a SID that is available at the time of backing up and store it in the backed-up database. However, if a new security principal is created on this DC during the backup process, the stored SID may be reused for that object, resulting in an error on restoration. By getting the SID for restore only after all the database files have been backed up, we ensure that the chosen SID does not conflict with any objects in the backed-up database. Signed-off-by: Joseph Sutton <josephsutton@catalyst.net.nz> Reviewed-by: Andrew Bartlett <abartlet@samba.org> Reviewed-by: Douglas Bagnall <douglas.bagnall@catalyst.net.nz>
* ridalloc: Don't skip the first RID of a poolJoseph Sutton2021-06-112-5/+4
| | | | | | | | | | Previously, if either of the rIDPreviousAllocation and rIDNextRID attributes were not present in a RID Set, the first RID in rIDAllocationPool was skipped over when determining their values. Signed-off-by: Joseph Sutton <josephsutton@catalyst.net.nz> Reviewed-by: Andrew Bartlett <abartlet@samba.org> Reviewed-by: Douglas Bagnall <douglas.bagnall@catalyst.net.nz>
* netcmd: Use next_free_rid() function to calculate a SID for restoring a backupJoseph Sutton2021-06-111-43/+14
| | | | | | | | | | | | This means we won't get errors if the DC doesn't have a rIDNextRID attribute, but we will still error if there is no RID Set or if all its pools are exhausted. BUG: https://bugzilla.samba.org/show_bug.cgi?id=14669 Signed-off-by: Joseph Sutton <josephsutton@catalyst.net.nz> Reviewed-by: Andrew Bartlett <abartlet@samba.org> Reviewed-by: Douglas Bagnall <douglas.bagnall@catalyst.net.nz>
* python/tests/dsdb: Add tests for RID allocation functionsJoseph Sutton2021-06-111-1/+304
| | | | | | | | BUG: https://bugzilla.samba.org/show_bug.cgi?id=14669 Signed-off-by: Joseph Sutton <josephsutton@catalyst.net.nz> Reviewed-by: Andrew Bartlett <abartlet@samba.org> Reviewed-by: Douglas Bagnall <douglas.bagnall@catalyst.net.nz>
* dsdb: Add next_free_rid() function to allocate a RID without modifying the ↵Joseph Sutton2021-06-111-0/+105
| | | | | | | | | | | | | database If used to generate SIDs for objects, care should be taken, as the possibility for having duplicate objectSIDs can arise. BUG: https://bugzilla.samba.org/show_bug.cgi?id=14669 Signed-off-by: Joseph Sutton <josephsutton@catalyst.net.nz> Reviewed-by: Andrew Bartlett <abartlet@samba.org> Reviewed-by: Douglas Bagnall <douglas.bagnall@catalyst.net.nz>
* netcmd: Add tests for performing an offline backup immediately after joining ↵Joseph Sutton2021-06-111-7/+54
| | | | | | | | | | | | | a domain This currently fails due to the DC not having a rIDNextRID attribute, which is required for the restore process. BUG: https://bugzilla.samba.org/show_bug.cgi?id=14669 Signed-off-by: Joseph Sutton <josephsutton@catalyst.net.nz> Reviewed-by: Andrew Bartlett <abartlet@samba.org> Reviewed-by: Douglas Bagnall <douglas.bagnall@catalyst.net.nz>
* dbcheck: check correct RID set attributes when looking for SID conflictsAndrew Bartlett2021-06-111-8/+34
| | | | | | | | | | The previous code would only work for the first rid set ever given to a DC because the names are so misleading. BUG: https://bugzilla.samba.org/show_bug.cgi?id=13632 Signed-off-by: Andrew Bartlett <abartlet@samba.org> Reviewed-by: Douglas Bagnall <douglas.bagnall@catalyst.net.nz>
* netcmd: Refactor seizing DNS roles while restoring from a backupJoseph Sutton2021-06-111-12/+5
| | | | | | Signed-off-by: Joseph Sutton <josephsutton@catalyst.net.nz> Reviewed-by: Andrew Bartlett <abartlet@samba.org> Reviewed-by: Douglas Bagnall <douglas.bagnall@catalyst.net.nz>
* netcmd: Use correct path for state directory during offline backupJoseph Sutton2021-06-111-1/+1
| | | | | | | | | | | | During the restore process, we use make_smbconf() to create a new smb.conf file with the default paths. The default location for 'state directory' is 'state', but we currently rename this directory to 'statedir' on backing up, so it will end up pointing to a non-existent directory. This commit ensures the names are consistent. Signed-off-by: Joseph Sutton <josephsutton@catalyst.net.nz> Reviewed-by: Andrew Bartlett <abartlet@samba.org> Reviewed-by: Douglas Bagnall <douglas.bagnall@catalyst.net.nz>
* tests: Specify additional modules for 'vfs objects' parameterJoseph Sutton2021-06-112-2/+2
| | | | | | | | | This helps to avoid a warning 'vfs objects specified without required AD DC module'. Signed-off-by: Joseph Sutton <josephsutton@catalyst.net.nz> Reviewed-by: Andrew Bartlett <abartlet@samba.org> Reviewed-by: Douglas Bagnall <douglas.bagnall@catalyst.net.nz>
* netcmd: Ignore rIDUsedPool attribute in offline domain backup testJoseph Sutton2021-06-111-1/+1
| | | | | | | | | | | | The RID Set of the newly created DC account has all its values initialised to zero. If the rIDUsedPool attribute was previously non-zero, then the restore process will cause its value to change. BUG: https://bugzilla.samba.org/show_bug.cgi?id=14669 Signed-off-by: Joseph Sutton <josephsutton@catalyst.net.nz> Reviewed-by: Andrew Bartlett <abartlet@samba.org> Reviewed-by: Douglas Bagnall <douglas.bagnall@catalyst.net.nz>
* netcmd: Fix error-checking conditionJoseph Sutton2021-06-111-3/+4
| | | | | | | | | | | This condition probably meant to check the argument of the most recently thrown exception, rather than the previous one again. BUG: https://bugzilla.samba.org/show_bug.cgi?id=14669 Signed-off-by: Joseph Sutton <josephsutton@catalyst.net.nz> Reviewed-by: Andrew Bartlett <abartlet@samba.org> Reviewed-by: Douglas Bagnall <douglas.bagnall@catalyst.net.nz>
* provision: Refactor another usage of create_dns_dir_keytab_linkJoseph Sutton2021-06-111-35/+2
| | | | | | | | | BUG: https://bugzilla.samba.org/show_bug.cgi?id=14181 BUG: https://bugzilla.samba.org/show_bug.cgi?id=14535 Signed-off-by: Joseph Sutton <josephsutton@catalyst.net.nz> Reviewed-by: Andrew Bartlett <abartlet@samba.org> Reviewed-by: Douglas Bagnall <douglas.bagnall@catalyst.net.nz>