From 9be844ebd9b2d4be7a50801ec6c671522a793fd8 Mon Sep 17 00:00:00 2001 From: TVo Date: Thu, 7 Nov 2024 08:58:31 -0700 Subject: [PATCH] Removed oAuth methods from collection docs. (#15606) * Removed oAuth methods from collection docs. --- awx_collection/TESTING.md | 53 ------------------- awx_collection/test/awx/test_token.py | 30 ----------- .../template_galaxy/templates/README.md.j2 | 24 +-------- 3 files changed, 1 insertion(+), 106 deletions(-) delete mode 100644 awx_collection/test/awx/test_token.py diff --git a/awx_collection/TESTING.md b/awx_collection/TESTING.md index 97ada687fb0d..71748769c38b 100644 --- a/awx_collection/TESTING.md +++ b/awx_collection/TESTING.md @@ -9,43 +9,6 @@ When trying to fix a bug, it is best to replicate its behavior within a test wit The unit tests are stored in the `test/awx` directory and, where possible, test interactions between the collections modules and the AWX database. This is achieved by using a Python testing suite and having a mocked layer which emulates interactions with the API. You do not need a server to run these unit tests. The depth of testing is not fixed and can change from module to module. -Let's take a closer look at the `test_token.py` file (which tests the `token` module): - -``` -from __future__ import absolute_import, division, print_function - -__metaclass__ = type - -import pytest - -from awx.main.models import OAuth2AccessToken - - -@pytest.mark.django_db -def test_create_token(run_module, admin_user): - - module_args = { - 'description': 'barfoo', - 'state': 'present', - 'scope': 'read', - 'controller_host': None, - 'controller_username': None, - 'controller_password': None, - 'validate_certs': None, - 'controller_oauthtoken': None, - 'controller_config_file': None, - } - - result = run_module('token', module_args, admin_user) - assert result.get('changed'), result - - tokens = OAuth2AccessToken.objects.filter(description='barfoo') - assert len(tokens) == 1, 'Tokens with description of barfoo != 0: {0}'.format(len(tokens)) - assert tokens[0].scope == 'read', 'Token was not given read access' -``` - -This test has a single test called `test_create_token`. It creates a `module_args` section which is what will be passed into our module. We then call `run_module`, asking it to run the `token` module with the `module_args` we created and give us back the results. After that, we run an assertion to validate that our module did in fact report a change to the system. We will then use Python objects to look up the token that has a description of `barfoo` (which was in our arguments to the module). We want to validate that we only got back one token (the one we created) and that the scope of the token we created was read. - ### Completion Test @@ -93,22 +56,6 @@ While not strictly followed, the general flow of a test should be: cred_name1: "AWX-Collection-tests-instance_group-cred1-{{ test_id }}" ``` -- **Non-creating tests (i.e. test for specific error conditions, etc), with assertion** - -``` -- name: Try to use a token as a dict which is missing the token parameter - job_list: - controller_oauthtoken: - not_token: "This has no token entry" - register: results - ignore_errors: true - -- assert: - that: - - results is failed - - '"The provided dict in controller_oauthtoken did not properly contain the token entry" == results.msg' -``` - - **`Block:`** - Run test which creates/modifies/deletes object(s) ``` diff --git a/awx_collection/test/awx/test_token.py b/awx_collection/test/awx/test_token.py deleted file mode 100644 index d49dd01df9e4..000000000000 --- a/awx_collection/test/awx/test_token.py +++ /dev/null @@ -1,30 +0,0 @@ -from __future__ import absolute_import, division, print_function - -__metaclass__ = type - -import pytest - -from awx.main.models import OAuth2AccessToken - - -@pytest.mark.django_db -def test_create_token(run_module, admin_user): - - module_args = { - 'description': 'barfoo', - 'state': 'present', - 'scope': 'read', - 'controller_host': None, - 'controller_username': None, - 'controller_password': None, - 'validate_certs': None, - 'controller_oauthtoken': None, - 'controller_config_file': None, - } - - result = run_module('token', module_args, admin_user) - assert result.get('changed'), result - - tokens = OAuth2AccessToken.objects.filter(description='barfoo') - assert len(tokens) == 1, 'Tokens with description of barfoo != 0: {0}'.format(len(tokens)) - assert tokens[0].scope == 'read', 'Token was not given read access' diff --git a/awx_collection/tools/roles/template_galaxy/templates/README.md.j2 b/awx_collection/tools/roles/template_galaxy/templates/README.md.j2 index c80b7fc397c9..8ffe9d33dffb 100644 --- a/awx_collection/tools/roles/template_galaxy/templates/README.md.j2 +++ b/awx_collection/tools/roles/template_galaxy/templates/README.md.j2 @@ -40,30 +40,8 @@ Non-deprecated modules in this collection have no Python requirements, but may require the AWX CLI in the future. The `DOCUMENTATION` for each module will report this. -You can specify authentication by a combination of either: +You can specify authentication by host, username, and password. - - host, username, password - - host, OAuth2 token - -The OAuth2 token is the preferred method. You can obtain a token via the -``login`` command with the AWX CLI. - -These can be specified via (from highest to lowest precedence): - - - direct module parameters - - environment variables (most useful when running against localhost) - - a config file path specified by the `tower_config_file` parameter - - a config file at `~/.tower_cli.cfg` - - a config file at `/etc/tower/tower_cli.cfg` - -Config file syntax looks like this: - -``` -[general] -host = https://localhost:8043 -verify_ssl = true -oauth_token = LEdCpKVKc4znzffcpQL5vLG8oyeku6 -``` ## Release and Upgrade Notes