-
Notifications
You must be signed in to change notification settings - Fork 461
Add scoped-credential integration tests #590
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
Open
AndreyVMarkelov
wants to merge
1
commit into
main
Choose a base branch
from
integration-test-scoped-creds
base: main
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Open
Changes from all commits
Commits
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Some comments aren't visible on the classic Files Changed page.
There are no files selected for viewing
This file contains hidden or 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 hidden or 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 hidden or 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 hidden or 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
25 changes: 25 additions & 0 deletions
25
core/src/test/java/com/dropbox/core/v2/ScopedUserClientV2IT.java
This file contains hidden or 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 |
|---|---|---|
| @@ -0,0 +1,25 @@ | ||
| package com.dropbox.core.v2; | ||
|
|
||
| import static com.google.common.truth.Truth.assertThat; | ||
|
|
||
| import org.testng.annotations.Test; | ||
|
|
||
| import com.dropbox.core.ITUtil; | ||
| import com.dropbox.core.v2.users.FullAccount; | ||
|
|
||
| /** | ||
| * Integration test for a user {@link DbxClientV2} authenticated via the scoped user refresh token | ||
| * (mirrors the scoped-user credentials shared across the Dropbox SDKs). Requires the | ||
| * {@code SCOPED_USER_*} environment variables; otherwise the tests are skipped. | ||
| */ | ||
| public class ScopedUserClientV2IT { | ||
| @Test | ||
| public void testScopedUserRefreshAccountInfo() throws Exception { | ||
| DbxClientV2 client = ITUtil.newScopedUserClientV2(); | ||
|
|
||
| FullAccount account = client.users().getCurrentAccount(); | ||
| assertThat(account).isNotNull(); | ||
| assertThat(account.getAccountId()).isNotNull(); | ||
| assertThat(account.getName()).isNotNull(); | ||
| } | ||
| } |
27 changes: 27 additions & 0 deletions
27
core/src/test/java/com/dropbox/core/v2/SharedLinkV2IT.java
This file contains hidden or 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 |
|---|---|---|
| @@ -0,0 +1,27 @@ | ||
| package com.dropbox.core.v2; | ||
|
|
||
| import static com.google.common.truth.Truth.assertThat; | ||
|
|
||
| import org.testng.annotations.Test; | ||
|
|
||
| import com.dropbox.core.ITUtil; | ||
| import com.dropbox.core.v2.sharing.SharedLinkMetadata; | ||
|
|
||
| /** | ||
| * Integration test that resolves the shared link supplied via {@code DROPBOX_SHARED_LINK} using | ||
| * the sharing API (mirrors the shared-link credential shared across the Dropbox SDKs). Requires | ||
| * the {@code SCOPED_USER_*} and {@code DROPBOX_SHARED_LINK} environment variables; otherwise the | ||
| * tests are skipped. | ||
| */ | ||
| public class SharedLinkV2IT { | ||
| @Test | ||
| public void testGetSharedLinkMetadata() throws Exception { | ||
| String sharedLink = ITUtil.valueFromEnvOrSkip(ITUtil.DROPBOX_SHARED_LINK); | ||
| DbxClientV2 client = ITUtil.newScopedUserClientV2(); | ||
|
|
||
| SharedLinkMetadata metadata = client.sharing().getSharedLinkMetadata(sharedLink); | ||
| assertThat(metadata).isNotNull(); | ||
| assertThat(metadata.getUrl()).isNotNull(); | ||
| assertThat(metadata.getName()).isNotNull(); | ||
| } | ||
| } |
25 changes: 25 additions & 0 deletions
25
core/src/test/java/com/dropbox/core/v2/TeamClientV2IT.java
This file contains hidden or 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 |
|---|---|---|
| @@ -0,0 +1,25 @@ | ||
| package com.dropbox.core.v2; | ||
|
|
||
| import static com.google.common.truth.Truth.assertThat; | ||
|
|
||
| import org.testng.annotations.Test; | ||
|
|
||
| import com.dropbox.core.ITUtil; | ||
| import com.dropbox.core.v2.team.TeamGetInfoResult; | ||
|
|
||
| /** | ||
| * Integration test for {@link DbxTeamClientV2} authenticated via the scoped team refresh token | ||
| * (mirrors the {@code dbx_team_from_env} fixture in dropbox-sdk-python). Requires the | ||
| * {@code SCOPED_TEAM_*} environment variables; otherwise the tests are skipped. | ||
| */ | ||
| public class TeamClientV2IT { | ||
| @Test | ||
| public void testScopedTeamGetInfo() throws Exception { | ||
| DbxTeamClientV2 client = ITUtil.newScopedTeamClientV2(); | ||
|
|
||
| TeamGetInfoResult info = client.team().getInfo(); | ||
| assertThat(info).isNotNull(); | ||
| assertThat(info.getTeamId()).isNotNull(); | ||
| assertThat(info.getName()).isNotNull(); | ||
| } | ||
| } |
This file contains hidden or 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
Oops, something went wrong.
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.
We cannot read environment variables that are set on the system. Per the docs:
This is why we kick off tests we use
-Pcom.dropbox.test.authInfoFile=../auth_outputin our gradle command, which passes the variable to test process.Integration tests don't run on PRs, only when we land, so you'll need to run them locally and confirm
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.
Confirmed with a temporary PR integration run: https://github.com/dropbox/dropbox-sdk-java/actions/runs/29540327341
The integration job passed for
OkHttpRequestor,OkHttp3Requestor, andStandardHttpRequestor.ScopedUserClientV2IT,SharedLinkV2IT, andTeamClientV2ITran successfully in all three suites while reading the scoped credentials throughSystem.getenv().This confirms that the environment variables configured on the workflow step are inherited by the forked Gradle test process.
authInfoFileuses a separate mechanism:-Pcom.dropbox.test.authInfoFileis a Gradle project property thatcore/build.gradleexplicitly forwards as a JVM system property.