krb_ticket: Create module (#8953)

* Add kutils module

* PR Fixes

* PR Fixes 2

* PR Fixes

* Fix executables

* Fix comment

* Fix functions

* PR Fix

* PR Fix 2

* Fix list name

* Fix list name 2

* Rever check_for_none func

* Rever check_for_none func 2

* Update tests

* Update tests 2

* Fix principal

* Fix cmdrunner args

* Fix multiline

* Fix backslash

* Fix tests

* Fix elif

* Fix bool arg

* Update doc

* Fix doc

* Add man reference

* Fix doc YAML-quoting

* PR Fixes

* Fix indent

* Fix version_added and name

* Fix units name

* Fix module name
This commit is contained in:
alexander 2024-10-10 23:03:30 +03:00 committed by GitHub
commit 3de4682193
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
4 changed files with 503 additions and 0 deletions

View file

@ -0,0 +1,14 @@
# -*- coding: utf-8 -*-
# Copyright (c) Alexei Znamensky (russoz@gmail.com)
# GNU General Public License v3.0+ (see LICENSES/GPL-3.0-or-later.txt or https://www.gnu.org/licenses/gpl-3.0.txt)
# SPDX-License-Identifier: GPL-3.0-or-later
from __future__ import (absolute_import, division, print_function)
__metaclass__ = type
from ansible_collections.community.general.plugins.modules import krb_ticket
from .helper import Helper, RunCommandMock # pylint: disable=unused-import
Helper.from_module(krb_ticket, __name__)

View file

@ -0,0 +1,109 @@
# -*- coding: utf-8 -*-
# Copyright (c) Alexei Znamensky (russoz@gmail.com)
# GNU General Public License v3.0+ (see LICENSES/GPL-3.0-or-later.txt or https://www.gnu.org/licenses/gpl-3.0.txt)
# SPDX-License-Identifier: GPL-3.0-or-later
---
- id: test_kinit_default
input:
state: present
password: cool_password
output:
changed: true
mocks:
run_command:
- command: [/testbin/klist]
environ: &env-def {environ_update: {LANGUAGE: C, LC_ALL: C}, check_rc: false}
rc: 1
out: ""
err: ""
- command: [/testbin/kinit]
environ: &env-data {environ_update: {LANGUAGE: C, LC_ALL: C}, check_rc: true, data: cool_password}
rc: 0
out: ""
err: ""
- id: test_kinit_principal
input:
state: present
password: cool_password
principal: admin@IPA.TEST
output:
changed: true
mocks:
run_command:
- command: [/testbin/klist, -l]
environ: *env-def
rc: 0
out: ""
err: ""
- command: [/testbin/kinit, admin@IPA.TEST]
environ: *env-data
rc: 0
out: ""
err: ""
- id: test_kdestroy_default
input:
state: absent
output:
changed: true
mocks:
run_command:
- command: [/testbin/klist]
environ: *env-def
rc: 0
out: ""
err: ""
- command: [/testbin/kdestroy]
environ: &env-norc {environ_update: {LANGUAGE: C, LC_ALL: C}, check_rc: true}
rc: 0
out: ""
err: ""
- id: test_kdestroy_principal
input:
state: absent
principal: admin@IPA.TEST
output:
changed: true
mocks:
run_command:
- command: [/testbin/klist, -l]
environ: *env-def
rc: 0
out: "admin@IPA.TEST"
err: ""
- command: [/testbin/kdestroy, -p, admin@IPA.TEST]
environ: *env-norc
rc: 0
out: ""
err: ""
- id: test_kdestroy_cache_name
input:
state: absent
cache_name: KEYRING:persistent:0:0
output:
changed: true
mocks:
run_command:
- command: [/testbin/klist, -l]
environ: *env-def
rc: 0
out: "KEYRING:persistent:0:0"
err: ""
- command: [/testbin/kdestroy, -c, KEYRING:persistent:0:0]
environ: *env-norc
rc: 0
out: ""
err: ""
- id: test_kdestroy_all
input:
state: absent
kdestroy_all: true
output:
changed: true
mocks:
run_command:
- command: [/testbin/kdestroy, -A]
environ: *env-norc
rc: 0
out: ""
err: ""