139 lines
6.3 KiB
Plaintext
139 lines
6.3 KiB
Plaintext
*** Settings ***
|
|
Documentation Configuration API tests for Aniworld.
|
|
... Covers get, update, validate, backup create/list/restore/delete, and export/import.
|
|
|
|
Resource ${CURDIR}/../resources/common.resource
|
|
Resource ${CURDIR}/../resources/api_keywords.resource
|
|
|
|
Test Setup Run Keywords
|
|
... Create Anonymous Session
|
|
... AND Setup Master Password
|
|
... AND Create Authenticated Session
|
|
|
|
Test Teardown Delete All Sessions
|
|
|
|
*** Test Cases ***
|
|
# ---------------------------------------------------------------------------
|
|
# Get / Update Config
|
|
# ---------------------------------------------------------------------------
|
|
Get Default Config
|
|
[Documentation] Retrieve the current configuration and verify its structure.
|
|
${resp}= GET API /api/config
|
|
Response Should Have Status ${resp} 200
|
|
Response Should Contain Keys ${resp} name data_dir scheduler logging backup nfo
|
|
|
|
Update Config
|
|
[Documentation] Update configuration fields and verify they are persisted.
|
|
${payload}= Create Dictionary
|
|
... name=UpdatedAniworld
|
|
... data_dir=data
|
|
... scheduler={'enabled': False, 'schedule_time': '04:00', 'schedule_days': ['mon', 'tue']}
|
|
... logging={'level': 'DEBUG', 'file': 'logs/test.log', 'max_bytes': 1048576, 'backup_count': 5}
|
|
... backup={'enabled': False}
|
|
... nfo={'tmdb_api_key': '', 'auto_create': False, 'download_poster': False, 'download_logo': False, 'download_fanart': False}
|
|
... other={'anime_directory': '/tmp/aniworld_test_anime'}
|
|
${resp}= Update Config ${payload}
|
|
Response Should Have Status ${resp} 200
|
|
${config}= Get Current Config
|
|
Should Be Equal As Strings ${config}[name] UpdatedAniworld
|
|
|
|
# ---------------------------------------------------------------------------
|
|
# Config Validation
|
|
# ---------------------------------------------------------------------------
|
|
Validate Valid Config
|
|
[Documentation] Validate a well-formed configuration.
|
|
${payload}= Create Dictionary
|
|
... name=Aniworld
|
|
... data_dir=data
|
|
... scheduler={'enabled': True, 'schedule_time': '03:00', 'schedule_days': ['mon', 'tue', 'wed', 'thu', 'fri', 'sat', 'sun']}
|
|
... logging={'level': 'INFO', 'file': None, 'max_bytes': None, 'backup_count': 3}
|
|
... backup={'enabled': False}
|
|
... nfo={'tmdb_api_key': '', 'auto_create': True, 'download_poster': True, 'download_logo': True, 'download_fanart': True}
|
|
... other={}
|
|
${resp}= Validate Config ${payload} 200
|
|
Response Should Have Status ${resp} 200
|
|
${valid}= Get JSON Value ${resp} $.valid
|
|
Should Be Equal As Strings ${valid} True
|
|
|
|
Validate Invalid Config Missing Name
|
|
[Documentation] Validate a config missing the required 'name' field.
|
|
${payload}= Create Dictionary
|
|
... data_dir=data
|
|
... scheduler={'enabled': True, 'schedule_time': '03:00', 'schedule_days': ['mon']}
|
|
... logging={'level': 'INFO'}
|
|
... backup={'enabled': False}
|
|
... nfo={'auto_create': False}
|
|
... other={}
|
|
${resp}= Validate Config ${payload} 422
|
|
Response Should Have Status ${resp} 422
|
|
|
|
Validate Invalid Schedule Time
|
|
[Documentation] Validate a config with malformed schedule_time.
|
|
${payload}= Create Dictionary
|
|
... name=Aniworld
|
|
... data_dir=data
|
|
... scheduler={'enabled': True, 'schedule_time': '25:00', 'schedule_days': ['mon']}
|
|
... logging={'level': 'INFO'}
|
|
... backup={'enabled': False}
|
|
... nfo={'auto_create': False}
|
|
... other={}
|
|
${resp}= Validate Config ${payload} 422
|
|
Response Should Have Status ${resp} 422
|
|
|
|
Validate Invalid Log Level
|
|
[Documentation] Validate a config with an invalid logging level.
|
|
${payload}= Create Dictionary
|
|
... name=Aniworld
|
|
... data_dir=data
|
|
... scheduler={'enabled': True, 'schedule_time': '03:00', 'schedule_days': ['mon']}
|
|
... logging={'level': 'INVALID', 'file': None, 'max_bytes': None, 'backup_count': 3}
|
|
... backup={'enabled': False}
|
|
... nfo={'auto_create': False}
|
|
... other={}
|
|
${resp}= Validate Config ${payload} 422
|
|
Response Should Have Status ${resp} 422
|
|
|
|
# ---------------------------------------------------------------------------
|
|
# Backup Management
|
|
# ---------------------------------------------------------------------------
|
|
Config Backup Create
|
|
[Documentation] Create a configuration backup and verify it exists.
|
|
${resp}= POST API /api/config/backups expected_status=201
|
|
Response Should Have Status ${resp} 201
|
|
|
|
Config Backup List
|
|
[Documentation] List configuration backups and verify the response structure.
|
|
POST API /api/config/backups expected_status=201
|
|
${resp}= GET API /api/config/backups
|
|
Response Should Have Status ${resp} 200
|
|
Response Should Contain Key ${resp} $.backups
|
|
|
|
Config Backup Restore
|
|
[Documentation] Create a backup, change config, then restore and verify reversion.
|
|
${resp}= POST API /api/config/backups expected_status=201
|
|
${json}= Convert String To Json ${resp.text}
|
|
${backup_name}= Get Value From Json ${json} $.backup_name
|
|
${name_before}= Set Variable ${backup_name}[0]
|
|
# Change config
|
|
${payload}= Create Dictionary
|
|
... name=BeforeRestore
|
|
... data_dir=data
|
|
... scheduler={'enabled': False, 'schedule_time': '03:00', 'schedule_days': ['mon']}
|
|
... logging={'level': 'INFO', 'file': None, 'max_bytes': None, 'backup_count': 3}
|
|
... backup={'enabled': False}
|
|
... nfo={'auto_create': False}
|
|
... other={}
|
|
Update Config ${payload}
|
|
# Restore
|
|
${resp}= POST API /api/config/backups/${name_before}/restore
|
|
Response Should Have Status ${resp} 200
|
|
|
|
Config Backup Delete
|
|
[Documentation] Create a backup and then delete it.
|
|
${resp}= POST API /api/config/backups expected_status=201
|
|
${json}= Convert String To Json ${resp.text}
|
|
${backup_name}= Get Value From Json ${json} $.backup_name
|
|
${name}= Set Variable ${backup_name}[0]
|
|
${del_resp}= DELETE API /api/config/backups/${name}
|
|
Response Should Have Status ${del_resp} 200
|