mirror of
https://salsa.debian.org/freeipa-team/freeipa.git
synced 2025-01-26 16:16:31 -06:00
ipatests: Add tests for schema
Command
- the base testing of this command is made by ipaclient `schema` remote plugin, but some specifics are not covered - allow testing of the plugin in `development` mode(locked API). Fixes: https://pagure.io/freeipa/issue/8955 Signed-off-by: Stanislav Levin <slev@altlinux.org> Reviewed-By: Florence Blanc-Renaud <flo@redhat.com> Reviewed-By: Rob Crittenden <rcritten@redhat.com>
This commit is contained in:
parent
3eb0759a6d
commit
77e7ac3592
@ -839,7 +839,7 @@ class schema(Command):
|
||||
langs = "".join(getattr(context, "languages", []))
|
||||
|
||||
if getattr(self.api, "_schema", None) is None:
|
||||
setattr(self.api, "_schema", {})
|
||||
object.__setattr__(self.api, "_schema", {})
|
||||
|
||||
schema = self.api._schema.get(langs)
|
||||
if schema is None:
|
||||
|
@ -8,7 +8,7 @@ Test the `ipaserver/plugins/schema.py` module.
|
||||
|
||||
import pytest
|
||||
|
||||
from ipalib import errors
|
||||
from ipalib import api, errors
|
||||
from ipatests.test_xmlrpc.tracker.base import Tracker
|
||||
from ipatests.test_xmlrpc.xmlrpc_test import XMLRPC_test
|
||||
|
||||
@ -119,3 +119,43 @@ class TestOutputFindAndShowCommand(XMLRPC_test):
|
||||
# wrong command, wrong criteria
|
||||
with pytest.raises(errors.NotFound):
|
||||
self.tracker.run_command('output_show', u'fake', u'fake')
|
||||
|
||||
|
||||
class TestSchemaCommand(XMLRPC_test):
|
||||
"""Test functionality of the ipa schema Command(no cli)"""
|
||||
expected_keys = {
|
||||
"classes", "commands", "fingerprint", "topics", "ttl", "version"
|
||||
}
|
||||
|
||||
def run_command(self, command, *args, **options):
|
||||
cmd = api.Command[command]
|
||||
cmd_result = cmd(*args, **options)
|
||||
return cmd_result
|
||||
|
||||
def test_schema_no_args(self):
|
||||
"""Test schema command without any args"""
|
||||
cmd_result = self.run_command("schema")
|
||||
result = cmd_result["result"]
|
||||
assert result.keys() == self.expected_keys
|
||||
|
||||
def test_schema_known_valid_fp(self):
|
||||
"""Test schema command with valid fingerprint"""
|
||||
# first, fetch current FP to reuse it
|
||||
cmd_result = self.run_command("schema")
|
||||
result = cmd_result["result"]
|
||||
fp_valid = result["fingerprint"]
|
||||
|
||||
with pytest.raises(errors.SchemaUpToDate):
|
||||
self.run_command("schema", known_fingerprints=(fp_valid,))
|
||||
|
||||
def test_schema_known_wrong_fp(self):
|
||||
"""Test schema command with wrong fingerprint"""
|
||||
fp_wrong = "wrong FP"
|
||||
cmd_result = self.run_command("schema", known_fingerprints=(fp_wrong,))
|
||||
result = cmd_result["result"]
|
||||
assert result.keys() == self.expected_keys
|
||||
|
||||
def test_schema_too_many_args(self):
|
||||
"""Test schema with too many args"""
|
||||
with pytest.raises(errors.ZeroArgumentError):
|
||||
self.run_command("schema", "arg1")
|
||||
|
Loading…
Reference in New Issue
Block a user