-
Notifications
You must be signed in to change notification settings - Fork 29
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Check to make sure only one AWX token exists #331
Closed
Closed
Changes from all commits
Commits
Show all changes
7 commits
Select commit
Hold shift + click to select a range
dbbcf0b
Remove check for more than one AWX token. As long as we have one tok…
ddonahue007 ac8e609
fix import
ddonahue007 6a009c0
Remove unneeded unit test
ddonahue007 37f9085
Only allow one AWX token to be created
ddonahue007 e6bded0
Updates based on PR review
ddonahue007 851d509
Merge branch 'main' into unique-awx-token
Alex-Izquierdo 10b3f39
Merge branch 'main' into unique-awx-token
mkanoor File filter
Filter by extension
Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -67,21 +67,6 @@ def test_create_controller_token(client: APIClient, user: models.User): | |
row = cursor.fetchone() | ||
assert row[0].startswith("$encrypted$fernet-256$") | ||
|
||
response = client.post( | ||
f"{api_url_v1}/users/me/awx-tokens/", | ||
data={ | ||
"name": "Test token 2", | ||
"description": "Token description", | ||
"token": "test-token-value", | ||
}, | ||
) | ||
assert response.status_code == status.HTTP_201_CREATED | ||
data = response.json() | ||
assert data["name"] == "Test token 2" | ||
assert data["description"] == "Token description" | ||
assert data["user_id"] == user.id | ||
assert "token" not in data | ||
|
||
|
||
@pytest.mark.django_db | ||
def test_create_token_missing_field(client: APIClient, user: models.User): | ||
|
@@ -109,7 +94,7 @@ def test_create_token_missing_field(client: APIClient, user: models.User): | |
|
||
|
||
@pytest.mark.django_db(transaction=True) | ||
def test_create_token_duplicate_name(client: APIClient, user: models.User): | ||
def test_create_token_to_many_tokens(client: APIClient, user: models.User): | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Possibly a typo: There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. likely :) |
||
models.AwxToken.objects.create( | ||
user=user, name="test-token", token="test-token-value" | ||
) | ||
|
@@ -121,9 +106,10 @@ def test_create_token_duplicate_name(client: APIClient, user: models.User): | |
"token": "test-token-value", | ||
}, | ||
) | ||
assert response.status_code == status.HTTP_409_CONFLICT | ||
assert response.status_code == status.HTTP_422_UNPROCESSABLE_ENTITY | ||
assert response.json() == { | ||
"detail": "Token with this name already exists." | ||
"detail": "Found an existing controller token, " | ||
"currently only 1 token is supported" | ||
} | ||
|
||
|
||
|
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Should we use this
status.HTTP_422_UNPROCESSABLE_ENTITY
instead of just hard-coded integer? Or we could inherit fromUnprocessable
class on line 48 and customize detail field since they fall under the same error code. Thoughts?There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Agree