rapidscada-admin 1.0.0__tar.gz

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -0,0 +1,21 @@
1
+ MIT License
2
+
3
+ Copyright (c) 2024 rapidscada-admin contributors
4
+
5
+ Permission is hereby granted, free of charge, to any person obtaining a copy
6
+ of this software and associated documentation files (the "Software"), to deal
7
+ in the Software without restriction, including without limitation the rights
8
+ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9
+ copies of the Software, and to permit persons to whom the Software is
10
+ furnished to do so, subject to the following conditions:
11
+
12
+ The above copyright notice and this permission notice shall be included in all
13
+ copies or substantial portions of the Software.
14
+
15
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21
+ SOFTWARE.
@@ -0,0 +1,187 @@
1
+ Metadata-Version: 2.4
2
+ Name: rapidscada-admin
3
+ Version: 1.0.0
4
+ Summary: Linux CLI for administering Rapid SCADA BaseDAT configuration files
5
+ Author: rapidscada-admin contributors
6
+ License-Expression: MIT
7
+ Project-URL: Homepage, https://github.com/Shadow21AR/rapidscada-admin
8
+ Project-URL: Repository, https://github.com/Shadow21AR/rapidscada-admin
9
+ Project-URL: Issues, https://github.com/Shadow21AR/rapidscada-admin/issues
10
+ Keywords: rapidscada,scada,basdat,industrial,admin
11
+ Classifier: Development Status :: 4 - Beta
12
+ Classifier: Environment :: Console
13
+ Classifier: Intended Audience :: System Administrators
14
+ Classifier: Operating System :: POSIX :: Linux
15
+ Classifier: Programming Language :: Python :: 3
16
+ Classifier: Programming Language :: Python :: 3.11
17
+ Classifier: Programming Language :: Python :: 3.12
18
+ Classifier: Programming Language :: Python :: 3.13
19
+ Classifier: Topic :: System :: Systems Administration
20
+ Requires-Python: >=3.11
21
+ Description-Content-Type: text/markdown
22
+ License-File: LICENSE
23
+ Dynamic: license-file
24
+
25
+ # rapidscada-admin
26
+
27
+ [![CI](https://github.com/Shadow21AR/rapidscada-admin/actions/workflows/ci.yml/badge.svg)](https://github.com/Shadow21AR/rapidscada-admin/actions/workflows/ci.yml)
28
+ [![PyPI](https://img.shields.io/pypi/v/rapidscada-admin)](https://pypi.org/project/rapidscada-admin/)
29
+ [![Python](https://img.shields.io/pypi/pyversions/rapidscada-admin)](https://pypi.org/project/rapidscada-admin/)
30
+ [![License: MIT](https://img.shields.io/badge/License-MIT-blue.svg)](LICENSE)
31
+
32
+ A Linux command-line utility for administering [Rapid SCADA](https://rapidscada.org/) v6 BaseDAT configuration files.
33
+
34
+ ## What is Rapid SCADA?
35
+
36
+ [Rapid SCADA](https://rapidscada.org/) is an open-source industrial automation and SCADA system. It stores configuration — users, roles, rights, and other tables — in binary BaseDAT (`.dat`) files. Editing these files normally requires the Windows Administrator application. This tool fills the gap for Linux environments.
37
+
38
+ ## Why this tool?
39
+
40
+ - Automate user management from shell scripts and Ansible playbooks
41
+ - Inspect and modify `user.dat` without the Windows GUI
42
+ - Validate file integrity before and after changes
43
+ - Export/import user data as JSON for backup and migration
44
+ - No third-party dependencies — pure Python standard library
45
+
46
+ ## Supported platforms
47
+
48
+ - **Linux** (primary target)
49
+ - macOS / Windows (should work, but untested)
50
+
51
+ Requires **Python 3.11+**.
52
+
53
+ ## Installation
54
+
55
+ ### From PyPI
56
+
57
+ ```bash
58
+ pip install rapidscada-admin
59
+ ```
60
+
61
+ Or with [pipx](https://pypa.github.io/pipx/) (recommended for CLI tools):
62
+
63
+ ```bash
64
+ pipx install rapidscada-admin
65
+ ```
66
+
67
+ ### From source
68
+
69
+ ```bash
70
+ git clone https://github.com/Shadow21AR/rapidscada-admin.git
71
+ cd rapidscada-admin
72
+ pip install .
73
+ ```
74
+
75
+ For development:
76
+
77
+ ```bash
78
+ pip install -e ".[dev]"
79
+ ```
80
+
81
+ ### Verify installation
82
+
83
+ ```bash
84
+ rapidscada-admin --version
85
+ ```
86
+
87
+ ## Usage
88
+
89
+ Every command takes the `.dat` file path as a positional argument. No files are hardcoded.
90
+
91
+ ```bash
92
+ rapidscada-admin <command> <subcommand> <file> [options]
93
+ ```
94
+
95
+ ### User management
96
+
97
+ ```bash
98
+ # List all users
99
+ rapidscada-admin users list user.dat
100
+
101
+ # Show one user
102
+ rapidscada-admin users show user.dat --user admin
103
+
104
+ # Add a user
105
+ rapidscada-admin users add user.dat \
106
+ --name operator \
107
+ --password 'S3cur3P@ss!' \
108
+ --role 2 \
109
+ --description "Shift operator"
110
+
111
+ # Delete a user
112
+ rapidscada-admin users delete user.dat --user operator
113
+
114
+ # Rename a user
115
+ rapidscada-admin users rename user.dat --old-name operator --new-name op2
116
+
117
+ # Change password
118
+ rapidscada-admin users passwd user.dat --user admin --password 'NewP@ssw0rd!'
119
+
120
+ # Enable / disable account
121
+ rapidscada-admin users enable user.dat --user admin
122
+ rapidscada-admin users disable user.dat --user admin
123
+ ```
124
+
125
+ ### Export and import
126
+
127
+ ```bash
128
+ # Export all users to JSON
129
+ rapidscada-admin users export user.dat > users.json
130
+
131
+ # Import users from JSON
132
+ rapidscada-admin users import user.dat --input users.json
133
+ ```
134
+
135
+ ### Password hashing
136
+
137
+ Compute a Rapid SCADA password hash without modifying any file:
138
+
139
+ ```bash
140
+ rapidscada-admin hash --password secret
141
+ rapidscada-admin hash --user-id 11 --password scada
142
+ ```
143
+
144
+ ### Validation
145
+
146
+ Check a BaseDAT file for corruption, schema errors, and duplicate entries:
147
+
148
+ ```bash
149
+ rapidscada-admin verify user.dat
150
+ ```
151
+
152
+ Exit code `0` means valid, `1` means errors found.
153
+
154
+ ## Safety
155
+
156
+ Every mutating command follows a 7-step safety protocol:
157
+
158
+ 1. **Verify schema** — required fields (`UserID`, `Enabled`, `Name`, `Password`, `RoleID`) must be present
159
+ 2. **Create backup** — timestamped `.bak` file alongside the original
160
+ 3. **Write temporary file** — changes go to a temp file first
161
+ 4. **Re-read temporary file** — parse the file we just wrote
162
+ 5. **Validate** — check schema, duplicates, integrity
163
+ 6. **Atomic replace** — `os.replace()` ensures no partial writes
164
+ 7. **Report** — print the backup location
165
+
166
+ A malformed `.dat` file can prevent Rapid SCADA from starting. **Always verify before and after operations.**
167
+
168
+ ## Limitations
169
+
170
+ - Only supports BaseDAT format version 4.x (Rapid SCADA v6)
171
+ - Does not support editing the Windows Administrator application's in-memory state
172
+ - Password hashing uses MD5 (matching the Rapid SCADA protocol — not a general security recommendation)
173
+ - Does not validate RoleID values against `role.dat` (role table is not yet supported)
174
+
175
+ ## Contributing
176
+
177
+ Contributions are welcome. Please:
178
+
179
+ 1. Fork the repository
180
+ 2. Create a feature branch
181
+ 3. Add tests for new functionality
182
+ 4. Run `pytest` and `ruff check` before submitting
183
+ 5. Open a pull request
184
+
185
+ ## License
186
+
187
+ [MIT](LICENSE)
@@ -0,0 +1,163 @@
1
+ # rapidscada-admin
2
+
3
+ [![CI](https://github.com/Shadow21AR/rapidscada-admin/actions/workflows/ci.yml/badge.svg)](https://github.com/Shadow21AR/rapidscada-admin/actions/workflows/ci.yml)
4
+ [![PyPI](https://img.shields.io/pypi/v/rapidscada-admin)](https://pypi.org/project/rapidscada-admin/)
5
+ [![Python](https://img.shields.io/pypi/pyversions/rapidscada-admin)](https://pypi.org/project/rapidscada-admin/)
6
+ [![License: MIT](https://img.shields.io/badge/License-MIT-blue.svg)](LICENSE)
7
+
8
+ A Linux command-line utility for administering [Rapid SCADA](https://rapidscada.org/) v6 BaseDAT configuration files.
9
+
10
+ ## What is Rapid SCADA?
11
+
12
+ [Rapid SCADA](https://rapidscada.org/) is an open-source industrial automation and SCADA system. It stores configuration — users, roles, rights, and other tables — in binary BaseDAT (`.dat`) files. Editing these files normally requires the Windows Administrator application. This tool fills the gap for Linux environments.
13
+
14
+ ## Why this tool?
15
+
16
+ - Automate user management from shell scripts and Ansible playbooks
17
+ - Inspect and modify `user.dat` without the Windows GUI
18
+ - Validate file integrity before and after changes
19
+ - Export/import user data as JSON for backup and migration
20
+ - No third-party dependencies — pure Python standard library
21
+
22
+ ## Supported platforms
23
+
24
+ - **Linux** (primary target)
25
+ - macOS / Windows (should work, but untested)
26
+
27
+ Requires **Python 3.11+**.
28
+
29
+ ## Installation
30
+
31
+ ### From PyPI
32
+
33
+ ```bash
34
+ pip install rapidscada-admin
35
+ ```
36
+
37
+ Or with [pipx](https://pypa.github.io/pipx/) (recommended for CLI tools):
38
+
39
+ ```bash
40
+ pipx install rapidscada-admin
41
+ ```
42
+
43
+ ### From source
44
+
45
+ ```bash
46
+ git clone https://github.com/Shadow21AR/rapidscada-admin.git
47
+ cd rapidscada-admin
48
+ pip install .
49
+ ```
50
+
51
+ For development:
52
+
53
+ ```bash
54
+ pip install -e ".[dev]"
55
+ ```
56
+
57
+ ### Verify installation
58
+
59
+ ```bash
60
+ rapidscada-admin --version
61
+ ```
62
+
63
+ ## Usage
64
+
65
+ Every command takes the `.dat` file path as a positional argument. No files are hardcoded.
66
+
67
+ ```bash
68
+ rapidscada-admin <command> <subcommand> <file> [options]
69
+ ```
70
+
71
+ ### User management
72
+
73
+ ```bash
74
+ # List all users
75
+ rapidscada-admin users list user.dat
76
+
77
+ # Show one user
78
+ rapidscada-admin users show user.dat --user admin
79
+
80
+ # Add a user
81
+ rapidscada-admin users add user.dat \
82
+ --name operator \
83
+ --password 'S3cur3P@ss!' \
84
+ --role 2 \
85
+ --description "Shift operator"
86
+
87
+ # Delete a user
88
+ rapidscada-admin users delete user.dat --user operator
89
+
90
+ # Rename a user
91
+ rapidscada-admin users rename user.dat --old-name operator --new-name op2
92
+
93
+ # Change password
94
+ rapidscada-admin users passwd user.dat --user admin --password 'NewP@ssw0rd!'
95
+
96
+ # Enable / disable account
97
+ rapidscada-admin users enable user.dat --user admin
98
+ rapidscada-admin users disable user.dat --user admin
99
+ ```
100
+
101
+ ### Export and import
102
+
103
+ ```bash
104
+ # Export all users to JSON
105
+ rapidscada-admin users export user.dat > users.json
106
+
107
+ # Import users from JSON
108
+ rapidscada-admin users import user.dat --input users.json
109
+ ```
110
+
111
+ ### Password hashing
112
+
113
+ Compute a Rapid SCADA password hash without modifying any file:
114
+
115
+ ```bash
116
+ rapidscada-admin hash --password secret
117
+ rapidscada-admin hash --user-id 11 --password scada
118
+ ```
119
+
120
+ ### Validation
121
+
122
+ Check a BaseDAT file for corruption, schema errors, and duplicate entries:
123
+
124
+ ```bash
125
+ rapidscada-admin verify user.dat
126
+ ```
127
+
128
+ Exit code `0` means valid, `1` means errors found.
129
+
130
+ ## Safety
131
+
132
+ Every mutating command follows a 7-step safety protocol:
133
+
134
+ 1. **Verify schema** — required fields (`UserID`, `Enabled`, `Name`, `Password`, `RoleID`) must be present
135
+ 2. **Create backup** — timestamped `.bak` file alongside the original
136
+ 3. **Write temporary file** — changes go to a temp file first
137
+ 4. **Re-read temporary file** — parse the file we just wrote
138
+ 5. **Validate** — check schema, duplicates, integrity
139
+ 6. **Atomic replace** — `os.replace()` ensures no partial writes
140
+ 7. **Report** — print the backup location
141
+
142
+ A malformed `.dat` file can prevent Rapid SCADA from starting. **Always verify before and after operations.**
143
+
144
+ ## Limitations
145
+
146
+ - Only supports BaseDAT format version 4.x (Rapid SCADA v6)
147
+ - Does not support editing the Windows Administrator application's in-memory state
148
+ - Password hashing uses MD5 (matching the Rapid SCADA protocol — not a general security recommendation)
149
+ - Does not validate RoleID values against `role.dat` (role table is not yet supported)
150
+
151
+ ## Contributing
152
+
153
+ Contributions are welcome. Please:
154
+
155
+ 1. Fork the repository
156
+ 2. Create a feature branch
157
+ 3. Add tests for new functionality
158
+ 4. Run `pytest` and `ruff check` before submitting
159
+ 5. Open a pull request
160
+
161
+ ## License
162
+
163
+ [MIT](LICENSE)
@@ -0,0 +1,48 @@
1
+ [build-system]
2
+ requires = ["setuptools>=68.0"]
3
+ build-backend = "setuptools.build_meta"
4
+
5
+ [project]
6
+ name = "rapidscada-admin"
7
+ version = "1.0.0"
8
+ description = "Linux CLI for administering Rapid SCADA BaseDAT configuration files"
9
+ readme = "README.md"
10
+ license = "MIT"
11
+ requires-python = ">=3.11"
12
+ authors = [
13
+ { name = "rapidscada-admin contributors" },
14
+ ]
15
+ classifiers = [
16
+ "Development Status :: 4 - Beta",
17
+ "Environment :: Console",
18
+ "Intended Audience :: System Administrators",
19
+ "Operating System :: POSIX :: Linux",
20
+ "Programming Language :: Python :: 3",
21
+ "Programming Language :: Python :: 3.11",
22
+ "Programming Language :: Python :: 3.12",
23
+ "Programming Language :: Python :: 3.13",
24
+ "Topic :: System :: Systems Administration",
25
+ ]
26
+ keywords = ["rapidscada", "scada", "basdat", "industrial", "admin"]
27
+
28
+ [project.urls]
29
+ Homepage = "https://github.com/Shadow21AR/rapidscada-admin"
30
+ Repository = "https://github.com/Shadow21AR/rapidscada-admin"
31
+ Issues = "https://github.com/Shadow21AR/rapidscada-admin/issues"
32
+
33
+ [project.scripts]
34
+ rapidscada-admin = "rapidscada_admin.cli:main"
35
+
36
+ [tool.setuptools.packages.find]
37
+ include = ["rapidscada_admin*"]
38
+
39
+ [tool.pytest.ini_options]
40
+ testpaths = ["tests"]
41
+ addopts = "-v --tb=short"
42
+
43
+ [tool.ruff]
44
+ target-version = "py311"
45
+ line-length = 99
46
+
47
+ [tool.ruff.lint]
48
+ select = ["E", "F", "W", "I", "N", "UP", "B", "SIM"]
@@ -0,0 +1,187 @@
1
+ Metadata-Version: 2.4
2
+ Name: rapidscada-admin
3
+ Version: 1.0.0
4
+ Summary: Linux CLI for administering Rapid SCADA BaseDAT configuration files
5
+ Author: rapidscada-admin contributors
6
+ License-Expression: MIT
7
+ Project-URL: Homepage, https://github.com/Shadow21AR/rapidscada-admin
8
+ Project-URL: Repository, https://github.com/Shadow21AR/rapidscada-admin
9
+ Project-URL: Issues, https://github.com/Shadow21AR/rapidscada-admin/issues
10
+ Keywords: rapidscada,scada,basdat,industrial,admin
11
+ Classifier: Development Status :: 4 - Beta
12
+ Classifier: Environment :: Console
13
+ Classifier: Intended Audience :: System Administrators
14
+ Classifier: Operating System :: POSIX :: Linux
15
+ Classifier: Programming Language :: Python :: 3
16
+ Classifier: Programming Language :: Python :: 3.11
17
+ Classifier: Programming Language :: Python :: 3.12
18
+ Classifier: Programming Language :: Python :: 3.13
19
+ Classifier: Topic :: System :: Systems Administration
20
+ Requires-Python: >=3.11
21
+ Description-Content-Type: text/markdown
22
+ License-File: LICENSE
23
+ Dynamic: license-file
24
+
25
+ # rapidscada-admin
26
+
27
+ [![CI](https://github.com/Shadow21AR/rapidscada-admin/actions/workflows/ci.yml/badge.svg)](https://github.com/Shadow21AR/rapidscada-admin/actions/workflows/ci.yml)
28
+ [![PyPI](https://img.shields.io/pypi/v/rapidscada-admin)](https://pypi.org/project/rapidscada-admin/)
29
+ [![Python](https://img.shields.io/pypi/pyversions/rapidscada-admin)](https://pypi.org/project/rapidscada-admin/)
30
+ [![License: MIT](https://img.shields.io/badge/License-MIT-blue.svg)](LICENSE)
31
+
32
+ A Linux command-line utility for administering [Rapid SCADA](https://rapidscada.org/) v6 BaseDAT configuration files.
33
+
34
+ ## What is Rapid SCADA?
35
+
36
+ [Rapid SCADA](https://rapidscada.org/) is an open-source industrial automation and SCADA system. It stores configuration — users, roles, rights, and other tables — in binary BaseDAT (`.dat`) files. Editing these files normally requires the Windows Administrator application. This tool fills the gap for Linux environments.
37
+
38
+ ## Why this tool?
39
+
40
+ - Automate user management from shell scripts and Ansible playbooks
41
+ - Inspect and modify `user.dat` without the Windows GUI
42
+ - Validate file integrity before and after changes
43
+ - Export/import user data as JSON for backup and migration
44
+ - No third-party dependencies — pure Python standard library
45
+
46
+ ## Supported platforms
47
+
48
+ - **Linux** (primary target)
49
+ - macOS / Windows (should work, but untested)
50
+
51
+ Requires **Python 3.11+**.
52
+
53
+ ## Installation
54
+
55
+ ### From PyPI
56
+
57
+ ```bash
58
+ pip install rapidscada-admin
59
+ ```
60
+
61
+ Or with [pipx](https://pypa.github.io/pipx/) (recommended for CLI tools):
62
+
63
+ ```bash
64
+ pipx install rapidscada-admin
65
+ ```
66
+
67
+ ### From source
68
+
69
+ ```bash
70
+ git clone https://github.com/Shadow21AR/rapidscada-admin.git
71
+ cd rapidscada-admin
72
+ pip install .
73
+ ```
74
+
75
+ For development:
76
+
77
+ ```bash
78
+ pip install -e ".[dev]"
79
+ ```
80
+
81
+ ### Verify installation
82
+
83
+ ```bash
84
+ rapidscada-admin --version
85
+ ```
86
+
87
+ ## Usage
88
+
89
+ Every command takes the `.dat` file path as a positional argument. No files are hardcoded.
90
+
91
+ ```bash
92
+ rapidscada-admin <command> <subcommand> <file> [options]
93
+ ```
94
+
95
+ ### User management
96
+
97
+ ```bash
98
+ # List all users
99
+ rapidscada-admin users list user.dat
100
+
101
+ # Show one user
102
+ rapidscada-admin users show user.dat --user admin
103
+
104
+ # Add a user
105
+ rapidscada-admin users add user.dat \
106
+ --name operator \
107
+ --password 'S3cur3P@ss!' \
108
+ --role 2 \
109
+ --description "Shift operator"
110
+
111
+ # Delete a user
112
+ rapidscada-admin users delete user.dat --user operator
113
+
114
+ # Rename a user
115
+ rapidscada-admin users rename user.dat --old-name operator --new-name op2
116
+
117
+ # Change password
118
+ rapidscada-admin users passwd user.dat --user admin --password 'NewP@ssw0rd!'
119
+
120
+ # Enable / disable account
121
+ rapidscada-admin users enable user.dat --user admin
122
+ rapidscada-admin users disable user.dat --user admin
123
+ ```
124
+
125
+ ### Export and import
126
+
127
+ ```bash
128
+ # Export all users to JSON
129
+ rapidscada-admin users export user.dat > users.json
130
+
131
+ # Import users from JSON
132
+ rapidscada-admin users import user.dat --input users.json
133
+ ```
134
+
135
+ ### Password hashing
136
+
137
+ Compute a Rapid SCADA password hash without modifying any file:
138
+
139
+ ```bash
140
+ rapidscada-admin hash --password secret
141
+ rapidscada-admin hash --user-id 11 --password scada
142
+ ```
143
+
144
+ ### Validation
145
+
146
+ Check a BaseDAT file for corruption, schema errors, and duplicate entries:
147
+
148
+ ```bash
149
+ rapidscada-admin verify user.dat
150
+ ```
151
+
152
+ Exit code `0` means valid, `1` means errors found.
153
+
154
+ ## Safety
155
+
156
+ Every mutating command follows a 7-step safety protocol:
157
+
158
+ 1. **Verify schema** — required fields (`UserID`, `Enabled`, `Name`, `Password`, `RoleID`) must be present
159
+ 2. **Create backup** — timestamped `.bak` file alongside the original
160
+ 3. **Write temporary file** — changes go to a temp file first
161
+ 4. **Re-read temporary file** — parse the file we just wrote
162
+ 5. **Validate** — check schema, duplicates, integrity
163
+ 6. **Atomic replace** — `os.replace()` ensures no partial writes
164
+ 7. **Report** — print the backup location
165
+
166
+ A malformed `.dat` file can prevent Rapid SCADA from starting. **Always verify before and after operations.**
167
+
168
+ ## Limitations
169
+
170
+ - Only supports BaseDAT format version 4.x (Rapid SCADA v6)
171
+ - Does not support editing the Windows Administrator application's in-memory state
172
+ - Password hashing uses MD5 (matching the Rapid SCADA protocol — not a general security recommendation)
173
+ - Does not validate RoleID values against `role.dat` (role table is not yet supported)
174
+
175
+ ## Contributing
176
+
177
+ Contributions are welcome. Please:
178
+
179
+ 1. Fork the repository
180
+ 2. Create a feature branch
181
+ 3. Add tests for new functionality
182
+ 4. Run `pytest` and `ruff check` before submitting
183
+ 5. Open a pull request
184
+
185
+ ## License
186
+
187
+ [MIT](LICENSE)
@@ -0,0 +1,14 @@
1
+ LICENSE
2
+ README.md
3
+ pyproject.toml
4
+ rapidscada_admin.egg-info/PKG-INFO
5
+ rapidscada_admin.egg-info/SOURCES.txt
6
+ rapidscada_admin.egg-info/dependency_links.txt
7
+ rapidscada_admin.egg-info/entry_points.txt
8
+ rapidscada_admin.egg-info/top_level.txt
9
+ tests/test_backup.py
10
+ tests/test_basetable.py
11
+ tests/test_cli.py
12
+ tests/test_crypto.py
13
+ tests/test_users.py
14
+ tests/test_validation.py
@@ -0,0 +1,2 @@
1
+ [console_scripts]
2
+ rapidscada-admin = rapidscada_admin.cli:main
@@ -0,0 +1,4 @@
1
+ [egg_info]
2
+ tag_build =
3
+ tag_date = 0
4
+
@@ -0,0 +1,38 @@
1
+ """Tests for rapidscada_admin.backup — backup creation."""
2
+
3
+ from __future__ import annotations
4
+
5
+ import time
6
+ from pathlib import Path
7
+
8
+ from rapidscada_admin.backup import create_backup
9
+
10
+
11
+ class TestCreateBackup:
12
+ """Backup creation tests."""
13
+
14
+ def test_creates_backup_file(self, user_dat_path: Path) -> None:
15
+ backup = create_backup(user_dat_path)
16
+ assert backup.exists()
17
+ assert backup != user_dat_path
18
+
19
+ def test_backup_naming_format(self, user_dat_path: Path) -> None:
20
+ backup = create_backup(user_dat_path)
21
+ assert backup.name.startswith("user.dat.")
22
+ assert backup.name.endswith(".bak")
23
+
24
+ def test_backup_content_matches_original(self, user_dat_path: Path) -> None:
25
+ backup = create_backup(user_dat_path)
26
+ assert backup.read_bytes() == user_dat_path.read_bytes()
27
+
28
+ def test_multiple_backups_unique_names(self, user_dat_path: Path) -> None:
29
+ b1 = create_backup(user_dat_path)
30
+ time.sleep(1.1) # ensure different timestamp
31
+ b2 = create_backup(user_dat_path)
32
+ assert b1 != b2
33
+ assert b1.exists()
34
+ assert b2.exists()
35
+
36
+ def test_backup_in_same_directory(self, user_dat_path: Path) -> None:
37
+ backup = create_backup(user_dat_path)
38
+ assert backup.parent == user_dat_path.parent