Skip to content

Add scoped-credential integration tests#590

Open
AndreyVMarkelov wants to merge 5 commits into
mainfrom
integration-test-scoped-creds
Open

Add scoped-credential integration tests#590
AndreyVMarkelov wants to merge 5 commits into
mainfrom
integration-test-scoped-creds

Conversation

@AndreyVMarkelov

@AndreyVMarkelov AndreyVMarkelov commented Jul 16, 2026

Copy link
Copy Markdown

Summary

Adds integration coverage for scoped user and team clients authenticated with refresh tokens, plus shared-link resolution.

Changes

  • Add integration tests for scoped user credentials, scoped team credentials, and shared links.
  • Add test helpers that construct refresh-token clients from environment variables and skip credential-specific tests when those variables are unavailable.
  • Configure the integrationTest task with the test source set and runtime classpath.
  • Update CI credential setup and generate the auth file used by the existing integration tests.
  • Document how to run the scoped credential tests locally.

Validation

  • git diff --check
  • GitHub Actions workflow YAML syntax validation
  • Integration tests use CI-provided credentials when available

@AndreyVMarkelov AndreyVMarkelov requested review from devPalacio and rharter and removed request for rharter July 16, 2026 20:18
Add integration coverage for scoped user and team refresh tokens and shared links using CI-provided credentials.

Configure the integrationTest task with the test source set and runtime classpath, and update CI to generate the auth file used by existing tests.
@AndreyVMarkelov AndreyVMarkelov force-pushed the integration-test-scoped-creds branch from 23384cb to 8aad8e5 Compare July 16, 2026 20:44
Comment thread core/build.gradle Outdated
Comment on lines +161 to +170
// Enable when the auth-file property is set (file-based tests) or when scoped credentials are
// supplied via the environment (scoped user/team/shared-link tests). Tests whose credentials
// are not present skip themselves.
enabled = project.hasProperty(authInfoPropertyName) ||
System.getenv('SCOPED_USER_REFRESH_TOKEN') != null ||
System.getenv('SCOPED_TEAM_REFRESH_TOKEN') != null

// Run against the same compiled classes and classpath as the unit `test` task.
testClassesDirs = sourceSets.test.output.classesDirs
classpath = sourceSets.test.runtimeClasspath

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'm not sure this is correct? I don't see anywhere that disables tests based on credentials not being there. If you don't have the authInfoPropertyName then when any test tries to load those credentials it will fail

But this keeps all tests enabled if you provide just a SCOPED_TEAM_REFRESH_TOKEN which that could also fail if you don't set the other required environment variables (SCOPED_TEAM_CLIENT_ID and SCOPED_TEAM_CLIENT_SECRET)

Plus i'm not sure what the changes are for the testClassesDirs and classpath that were needed as part of this

Copy link
Copy Markdown
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Gradle explicitly documents that, starting with 9.0, only the built-in test task is automatically configured. Custom Test tasks must configure both testClassesDirs and classpath. Gradle documentation

Copy link
Copy Markdown
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Fixed ENV

Comment thread generate-ci-auth-file Outdated
Comment on lines +12 to +13
-d client_id=$APP_KEY \
-d client_secret=$APP_SECRET > auth_output

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We had the app secret before but didn't need it as part of our token refresh, is that now needed? This also doesn't refresh the tokens for the team or user secrets other, is that needed?

Copy link
Copy Markdown
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Only if introduce new special tests for PKCE. Removed.

Comment on lines +218 to +226
public static String valueFromEnvOrSkip(String name) {
String value = System.getenv(name);
if (value == null || value.isEmpty()) {
throw new SkipException(
"Environment variable \"" + name + "\" is not set; skipping test that requires " +
"shared SDK integration credentials.");
}
return value;
}

Copy link
Copy Markdown
Member

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:

By default, Gradle does not automatically pass all terminal environment variables to the forked test process. You need to configure your integrationTest task to inherit them.

This is why we kick off tests we use -Pcom.dropbox.test.authInfoFile=../auth_output in 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

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants