Add support for OAuth provider APIs to return long-lived access tokens
This adds methods for storing long-lived access tokens in the secure store. This also adds support for OAuth APIs to send only an access token when given a one-time-code.
please add a test when both refresh_token & access_token are returned and only refresh_token was written.
@itsankit-google @sahusanket I've been looking to add a test for this case, but as far as I can tell there are no similar unit tests that would modify the response from the backend before asserting behavior. The other methods in OAuthStore are tested in OAuthServiceTest.java. Is there a currently a way to change what the http response will return?
please add a test when both refresh_token & access_token are returned and only refresh_token was written.
@itsankit-google @sahusanket I've been looking to add a test for this case, but as far as I can tell there are no similar unit tests that would modify the response from the backend before asserting behavior. The other methods in OAuthStore are tested in OAuthServiceTest.java. Is there a currently a way to change what the http response will return?
Hi, you can use powermock to mock static methods response, if you see in implementation methods we have used this method to execute http request : https://github.com/cdapio/common/blob/7d2ab9f010de01c01f42dfedcdd955a5bd841e5f/common-http/src/main/java/io/cdap/common/http/HttpRequests.java#L63
please add a test when both refresh_token & access_token are returned and only refresh_token was written.
@itsankit-google @sahusanket I've been looking to add a test for this case, but as far as I can tell there are no similar unit tests that would modify the response from the backend before asserting behavior. The other methods in OAuthStore are tested in OAuthServiceTest.java. Is there a currently a way to change what the http response will return?
Hi, you can use powermock to mock static methods response, if you see in implementation methods we have used this method to execute http request : https://github.com/cdapio/common/blob/7d2ab9f010de01c01f42dfedcdd955a5bd841e5f/common-http/src/main/java/io/cdap/common/http/HttpRequests.java#L63
Thanks, I will do this in the follow-up PR.
I cherry-picked #15967 onto this one at your request