mirror of
https://github.com/ansible-collections/community.general.git
synced 2026-04-24 20:59:16 +00:00
Make all doc fragments, module utils, and plugin utils private (#11896)
* Make all doc fragments private. * Make all plugin utils private. * Make all module utils private. * Reformat. * Changelog fragment. * Update configs and ignores. * Adjust unit test names.
This commit is contained in:
parent
9ef1dbb6d5
commit
4fa82b9617
807 changed files with 2041 additions and 1702 deletions
|
|
@ -1,147 +0,0 @@
|
|||
# Copyright (c) Ansible project
|
||||
# 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 annotations
|
||||
|
||||
import unittest
|
||||
|
||||
from ansible_collections.community.general.plugins.module_utils.scaleway import SecretVariables, argon2
|
||||
|
||||
|
||||
class SecretVariablesTestCase(unittest.TestCase):
|
||||
def test_dict_to_list(self):
|
||||
source = dict(attribute1="value1", attribute2="value2")
|
||||
expect = [dict(key="attribute1", value="value1"), dict(key="attribute2", value="value2")]
|
||||
|
||||
result = SecretVariables.dict_to_list(source)
|
||||
result = sorted(result, key=lambda el: el["key"])
|
||||
self.assertEqual(result, expect)
|
||||
|
||||
def test_list_to_dict(self):
|
||||
source = [
|
||||
dict(
|
||||
key="secret1",
|
||||
hashed_value="$argon2id$v=19$m=65536,t=1,p=2$NuZk+6UATHNFV78nFRXFvA$3kivcXfzNHI1c/4ZBpP8BeBSGhhI82NfOh4Dd48JJgc",
|
||||
),
|
||||
dict(
|
||||
key="secret2",
|
||||
hashed_value="$argon2id$v=19$m=65536,t=1,p=2$etGO/Z8ImYDeKr6uFsyPAQ$FbL5+hG/duDEpa8UCYqXpEUQ5EacKg6i2iAs+Dq4dAI",
|
||||
),
|
||||
]
|
||||
expect = dict(
|
||||
secret1="$argon2id$v=19$m=65536,t=1,p=2$NuZk+6UATHNFV78nFRXFvA$3kivcXfzNHI1c/4ZBpP8BeBSGhhI82NfOh4Dd48JJgc",
|
||||
secret2="$argon2id$v=19$m=65536,t=1,p=2$etGO/Z8ImYDeKr6uFsyPAQ$FbL5+hG/duDEpa8UCYqXpEUQ5EacKg6i2iAs+Dq4dAI",
|
||||
)
|
||||
|
||||
self.assertEqual(SecretVariables.list_to_dict(source, hashed=True), expect)
|
||||
|
||||
def test_list_to_dict_2(self):
|
||||
source = [dict(key="secret1", value="value1"), dict(key="secret2", value="value2")]
|
||||
expect = dict(secret1="value1", secret2="value2")
|
||||
|
||||
self.assertEqual(SecretVariables.list_to_dict(source, hashed=False), expect)
|
||||
|
||||
@unittest.skipIf(argon2 is None, "Missing required 'argon2' library")
|
||||
def test_decode_full(self):
|
||||
source_secret = [
|
||||
dict(
|
||||
key="secret1",
|
||||
hashed_value="$argon2id$v=19$m=65536,t=1,p=2$NuZk+6UATHNFV78nFRXFvA$3kivcXfzNHI1c/4ZBpP8BeBSGhhI82NfOh4Dd48JJgc",
|
||||
),
|
||||
dict(
|
||||
key="secret2",
|
||||
hashed_value="$argon2id$v=19$m=65536,t=1,p=2$etGO/Z8ImYDeKr6uFsyPAQ$FbL5+hG/duDEpa8UCYqXpEUQ5EacKg6i2iAs+Dq4dAI",
|
||||
),
|
||||
]
|
||||
source_value = [
|
||||
dict(key="secret1", value="value1"),
|
||||
dict(key="secret2", value="value2"),
|
||||
]
|
||||
|
||||
expect = [
|
||||
dict(key="secret1", value="value1"),
|
||||
dict(key="secret2", value="value2"),
|
||||
]
|
||||
|
||||
result = SecretVariables.decode(source_secret, source_value)
|
||||
result = sorted(result, key=lambda el: el["key"])
|
||||
self.assertEqual(result, expect)
|
||||
|
||||
@unittest.skipIf(argon2 is None, "Missing required 'argon2' library")
|
||||
def test_decode_dict_divergent_values(self):
|
||||
source_secret = [
|
||||
dict(
|
||||
key="secret1",
|
||||
hashed_value="$argon2id$v=19$m=65536,t=1,p=2$NuZk+6UATHNFV78nFRXFvA$3kivcXfzNHI1c/4ZBpP8BeBSGhhI82NfOh4Dd48JJgc",
|
||||
),
|
||||
dict(
|
||||
key="secret2",
|
||||
hashed_value="$argon2id$v=19$m=65536,t=1,p=2$etGO/Z8ImYDeKr6uFsyPAQ$FbL5+hG/duDEpa8UCYqXpEUQ5EacKg6i2iAs+Dq4dAI",
|
||||
),
|
||||
]
|
||||
source_value = [
|
||||
dict(key="secret1", value="value1"),
|
||||
dict(key="secret2", value="diverged_value2"),
|
||||
]
|
||||
|
||||
expect = [
|
||||
dict(key="secret1", value="value1"),
|
||||
dict(
|
||||
key="secret2",
|
||||
value="$argon2id$v=19$m=65536,t=1,p=2$etGO/Z8ImYDeKr6uFsyPAQ$FbL5+hG/duDEpa8UCYqXpEUQ5EacKg6i2iAs+Dq4dAI",
|
||||
),
|
||||
]
|
||||
|
||||
result = SecretVariables.decode(source_secret, source_value)
|
||||
result = sorted(result, key=lambda el: el["key"])
|
||||
self.assertEqual(result, expect)
|
||||
|
||||
@unittest.skipIf(argon2 is None, "Missing required 'argon2' library")
|
||||
def test_decode_dict_missing_values_left(self):
|
||||
source_secret = [
|
||||
dict(
|
||||
key="secret1",
|
||||
hashed_value="$argon2id$v=19$m=65536,t=1,p=2$NuZk+6UATHNFV78nFRXFvA$3kivcXfzNHI1c/4ZBpP8BeBSGhhI82NfOh4Dd48JJgc",
|
||||
),
|
||||
]
|
||||
source_value = [
|
||||
dict(key="secret1", value="value1"),
|
||||
dict(key="secret2", value="value2"),
|
||||
]
|
||||
|
||||
expect = [
|
||||
dict(key="secret1", value="value1"),
|
||||
]
|
||||
|
||||
result = SecretVariables.decode(source_secret, source_value)
|
||||
result = sorted(result, key=lambda el: el["key"])
|
||||
self.assertEqual(result, expect)
|
||||
|
||||
@unittest.skipIf(argon2 is None, "Missing required 'argon2' library")
|
||||
def test_decode_dict_missing_values_right(self):
|
||||
source_secret = [
|
||||
dict(
|
||||
key="secret1",
|
||||
hashed_value="$argon2id$v=19$m=65536,t=1,p=2$NuZk+6UATHNFV78nFRXFvA$3kivcXfzNHI1c/4ZBpP8BeBSGhhI82NfOh4Dd48JJgc",
|
||||
),
|
||||
dict(
|
||||
key="secret2",
|
||||
hashed_value="$argon2id$v=19$m=65536,t=1,p=2$etGO/Z8ImYDeKr6uFsyPAQ$FbL5+hG/duDEpa8UCYqXpEUQ5EacKg6i2iAs+Dq4dAI",
|
||||
),
|
||||
]
|
||||
source_value = [
|
||||
dict(key="secret1", value="value1"),
|
||||
]
|
||||
|
||||
expect = [
|
||||
dict(key="secret1", value="value1"),
|
||||
dict(
|
||||
key="secret2",
|
||||
value="$argon2id$v=19$m=65536,t=1,p=2$etGO/Z8ImYDeKr6uFsyPAQ$FbL5+hG/duDEpa8UCYqXpEUQ5EacKg6i2iAs+Dq4dAI",
|
||||
),
|
||||
]
|
||||
|
||||
result = SecretVariables.decode(source_secret, source_value)
|
||||
result = sorted(result, key=lambda el: el["key"])
|
||||
self.assertEqual(result, expect)
|
||||
Loading…
Add table
Add a link
Reference in a new issue