Skip to content

Commit

Permalink
Fix test_oidc_login_existing_user test
Browse files Browse the repository at this point in the history
Fix the following error:

```
self = <test_auth_oidc.TestGalaxyOIDCLoginIntegration object at 0x7f00ca129150>

    def test_oidc_login_existing_user(self):
        ...
        _, response = self._login_via_keycloak("gxyuser_existing", KEYCLOAK_TEST_PASSWORD, save_cookies=True)

        # Should prompt user to associate accounts
        parsed_url = parse.urlparse(response.url)
        provider = parse.parse_qs(parsed_url.query)["connect_external_provider"][0]
        assert "keycloak" == provider
        response = self._get("users/current")
>       self._assert_status_code_is(response, 400)

test/integration/oidc/test_auth_oidc.py:229:
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _
lib/galaxy_test/base/api.py:199: in _assert_status_code_is
    assert_status_code_is(response, expected_status_code)
lib/galaxy_test/base/api_asserts.py:21: in assert_status_code_is
    _report_status_code_error(response, expected_status_code, failure_message)
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _

response = <Response [200]>, expected_status_code = 400, failure_message = None

    def _report_status_code_error(
        response: Response, expected_status_code: Union[str, int], failure_message: Optional[str]
    ):
        try:
            body = response.json()
        except Exception:
            body = f"INVALID JSON RESPONSE <{response.text}>"
        assertion_message = "Request status code (%d) was not expected value %s. Body was %s" % (response.status_code, expected_status_code, body)
        if failure_message:
            assertion_message = f"{failure_message}. {assertion_message}"
>       raise AssertionError(assertion_message)
E       AssertionError: Request status code (200) was not expected value 400. Body was {'total_disk_usage': 0.0, 'nice_total_disk_usage': '0 bytes', 'quota_percent': None}

lib/galaxy_test/base/api_asserts.py:48: AssertionError
```

This broke when commit 85630e2 was
merged forward because now that the failed keycloak login session
still gets a history, this check

```
        if not trans.user and not trans.history:
            # Can't return info about this user, may not have a history yet.
            # return {}
            raise glx_exceptions.MessageException(err_msg="The user has no history, which should always be the case.")
```

in `_anon_user_api_value()` inside `lib/galaxy/webapps/galaxy/services/users.py`
does not raise the exception any more.
  • Loading branch information
nsoranzo committed Mar 6, 2024
1 parent 184d880 commit ff9c6b7
Showing 1 changed file with 1 addition and 1 deletion.
2 changes: 1 addition & 1 deletion test/integration/oidc/test_auth_oidc.py
Original file line number Diff line number Diff line change
Expand Up @@ -226,7 +226,7 @@ def test_oidc_login_existing_user(self):
provider = parse.parse_qs(parsed_url.query)["connect_external_provider"][0]
assert "keycloak" == provider
response = self._get("users/current")
self._assert_status_code_is(response, 400)
assert "id" not in response.json()

def test_oidc_login_account_linkup(self):
# pre-create a user account manually
Expand Down

0 comments on commit ff9c6b7

Please sign in to comment.