Actually simpler

This commit is contained in:
shamoon
2026-01-29 09:02:22 -08:00
parent 8cf6d9fa3c
commit 6c1b9fe492

View File

@@ -862,65 +862,33 @@ class TestApiWorkflows(DirectoriesMixin, APITestCase):
self.assertEqual(response.status_code, status.HTTP_201_CREATED) self.assertEqual(response.status_code, status.HTTP_201_CREATED)
self.assertEqual(response.data["passwords"], passwords) self.assertEqual(response.data["passwords"], passwords)
def test_password_action_no_passwords_field(self): def test_password_action_invalid_passwords_field(self):
""" """
GIVEN: GIVEN:
- Nothing - Nothing
WHEN: WHEN:
- A workflow password removal action is created with no passwords set - A workflow password removal action is created with invalid passwords field
- A workflow password removal action is created with passwords set to empty string
THEN: THEN:
- The required validation error is raised - The required validation error is raised
""" """
response = self.client.post( for payload in [
"/api/workflow_actions/", {"type": WorkflowAction.WorkflowActionType.PASSWORD_REMOVAL},
{
"type": WorkflowAction.WorkflowActionType.PASSWORD_REMOVAL,
},
)
self.assertEqual(response.status_code, status.HTTP_400_BAD_REQUEST)
self.assertIn(
"Passwords are required",
str(response.data["non_field_errors"][0]),
)
response = self.client.post(
"/api/workflow_actions/",
json.dumps(
{ {
"type": WorkflowAction.WorkflowActionType.PASSWORD_REMOVAL, "type": WorkflowAction.WorkflowActionType.PASSWORD_REMOVAL,
"passwords": "", "passwords": "",
}, },
),
content_type="application/json",
)
self.assertEqual(response.status_code, status.HTTP_400_BAD_REQUEST)
self.assertIn(
"Passwords are required",
str(response.data["non_field_errors"][0]),
)
response = self.client.post(
"/api/workflow_actions/",
json.dumps(
{ {
"type": WorkflowAction.WorkflowActionType.PASSWORD_REMOVAL, "type": WorkflowAction.WorkflowActionType.PASSWORD_REMOVAL,
"passwords": [], "passwords": [],
}, },
),
content_type="application/json",
)
self.assertEqual(response.status_code, status.HTTP_400_BAD_REQUEST)
self.assertIn(
"Passwords are required",
str(response.data["non_field_errors"][0]),
)
response = self.client.post(
"/api/workflow_actions/",
json.dumps(
{ {
"type": WorkflowAction.WorkflowActionType.PASSWORD_REMOVAL, "type": WorkflowAction.WorkflowActionType.PASSWORD_REMOVAL,
"passwords": ["", "password2"], "passwords": ["", "password2"],
}, },
), ]:
response = self.client.post(
"/api/workflow_actions/",
json.dumps(payload),
content_type="application/json", content_type="application/json",
) )
self.assertEqual(response.status_code, status.HTTP_400_BAD_REQUEST) self.assertEqual(response.status_code, status.HTTP_400_BAD_REQUEST)