Removed oAuth methods from collection docs. (#15606)

* Removed oAuth methods from collection docs.
This commit is contained in:
TVo 2024-11-07 08:58:31 -07:00 committed by GitHub
parent f4cbb9f9a8
commit aa162c6128
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
3 changed files with 1 additions and 106 deletions

View File

@ -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)
```

View File

@ -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'

View File

@ -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