denoland/deno_kv_oauth

bug: test `rejects if the OAuth provider hasn't issued the access token` fails when properly `await`ed

mitchwadair opened this issue ยท 5 comments

re: #201

When properly awaiting the rejects if the OAuth provider hasn't issued the access token in get_session_access_token_test.ts, the test fails. This happens because the correct conditions are met to just return the access token, and I'm not sure there is a good mechanism to actually test what it is describing

I haven't had time to look into this. A couple of thoughts:

  1. I think we really need to start leaning on mocking and spying in testing for this module.
  2. How is test coverage affected if this test is removed?

I don't really think coverage will be affected at all to be honest, the test already isn't exactly providing any useful results as it stands.

What would be the way to tell if the provider didn't issue the token? Would it be if a request were made to the provider with the auth token and it responds with a 4XX status code or something?

I think we really need to start leaning on mocking and spying in testing for this module.

+1 on this

I don't really think coverage will be affected at all to be honest, the test already isn't exactly providing any useful results as it stands.

I'll submit a PR that does this tomorrow. I'd also be happy to review a PR submitted before then ๐Ÿ™‚

What would be the way to tell if the provider didn't issue the token? Would it be if a request were made to the provider with the auth token and it responds with a 4XX status code or something?

IIRC, the response is checked and any error response causes an error throw. This is done within the oauth2_client module.

IIRC, the response is checked and any error response causes an error throw. This is done within the oauth2_client module.

Sounds like we need a mock then