Skip to content

Commit

Permalink
WIP: Add remaining user mgmt endpoints and code improvements (#336)
Browse files Browse the repository at this point in the history
…explanation, enable logging<!--- Provide a general summary of your
changes in the Title above -->

## Description
<!--- Describe the big picture of your changes here to communicate to
the maintainers why we should accept this pull request. If it fixes a
bug or resolves a feature request, be sure to link to that issue. --->

## Motivation and Context
<!--- Why is this change required? What problem does it solve? -->
<!--- If it fixes an open issue, please link to the issue here. -->

## How Has This Been Tested?
<!--- Please describe in detail how you tested your changes. -->
<!--- Include details of your testing environment, and the tests you ran
to -->
<!--- see how your change affects other areas of the code, etc. -->

## Types of changes

<!--- What types of changes does your code introduce? Put an `x` in all
the boxes that apply: -->

- [ ] Bugfix (non-breaking change which fixes an issue)
- [ ] New feature (non-breaking change which adds functionality)
- [ ] Refactoring (change which improves current code base; please
describe the change)
- [ ] Breaking change (fix or feature that would cause existing
functionality to not work as expected)
- [ ] Documentation Update (if none of the other choices apply)

## Screenshots (if appropriate):

## Checklist
<!--- Go over all the following points, and put an `x` in all the boxes
that apply. -->
<!--- If you're unsure about any of these, don't hesitate to ask. We're
here to help! -->
<!--- This is simply a reminder of what we are going to look for before
merging your code --->

- [ ] I have read the
[CONTRIBUTING](https://github.com/saucelabs/saucerest-java/blob/master/CONTRIBUTING.md)
doc
- [ ] I have added tests that prove my fix is effective or that my
feature works
- [ ] All new and existing tests passed locally
- [ ] I have added necessary documentation (if appropriate)

## Further comments

If this is a relatively large or complex change, kick off the discussion
by explaining why you chose the solution you did and what alternatives
you considered, etc...
  • Loading branch information
sceiler authored Mar 6, 2023
2 parents 8c72717 + b2d010e commit 4cb0524
Show file tree
Hide file tree
Showing 38 changed files with 1,432 additions and 453 deletions.
2 changes: 1 addition & 1 deletion .github/workflows/dependency-review.yml
Original file line number Diff line number Diff line change
Expand Up @@ -17,4 +17,4 @@ jobs:
- name: 'Checkout Repository'
uses: actions/checkout@v3
- name: 'Dependency Review'
uses: actions/dependency-review-action@v2
uses: actions/dependency-review-action@v3
18 changes: 17 additions & 1 deletion .github/workflows/java-ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,8 @@ on:
pull_request:
types: [ opened, reopened, synchronize ]
workflow_dispatch:
schedule:
- cron: '0 */8 * * *'

permissions:
contents: write
Expand Down Expand Up @@ -118,5 +120,19 @@ jobs:
configFile: ${{ github.workspace }}/src/test/resources/sauce-connect-config-apac-southeast.yaml

- name: Build with Maven
id: runIntegrationTests
if: ${{ env.NOT_FROM_FORK }} == 'true'
run: mvn clean test -Dtest="com.saucelabs.saucerest.integration.**" -Dgpg.skip -B -Dorg.slf4j.simpleLogger.log.org.apache.maven.cli.transfer.Slf4jMavenTransferListener=warn -V
run: mvn clean test -Dtest="com.saucelabs.saucerest.integration.**" -Dgpg.skip -B -Dorg.slf4j.simpleLogger.log.org.apache.maven.cli.transfer.Slf4jMavenTransferListener=warn -V

slackNotification:
name: Slack Notification
if: |
always() && (steps.runIntegrationTests.outcome == 'failure') &&
(${{ github.repository == github.event.pull_request.head.repo.full_name }} || ${{ github.event.push.head.repo.full_name == github.repository }})
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v2
- name: Slack Notification
uses: rtCamp/action-slack-notify@v2
env:
SLACK_WEBHOOK: ${{ secrets.SLACK_WEBHOOK }}
10 changes: 8 additions & 2 deletions pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -65,7 +65,7 @@
<dependency>
<groupId>org.json</groupId>
<artifactId>json</artifactId>
<version>20220924</version>
<version>20230227</version>
</dependency>
<dependency>
<groupId>commons-io</groupId>
Expand Down Expand Up @@ -283,7 +283,7 @@
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-compiler-plugin</artifactId>
<version>3.10.1</version>
<version>3.11.0</version>
<configuration>
<source>${java.version}</source>
<target>${java.version}</target>
Expand All @@ -308,6 +308,12 @@
</consoleOutputReporter>
<statelessTestsetInfoReporter
implementation="org.apache.maven.plugin.surefire.extensions.junit5.JUnit5StatelessTestsetInfoTreeReporter"/>
<systemProperties>
<property>
<name>java.util.logging.config.file</name>
<value>src/test/resources/logging.properties</value>
</property>
</systemProperties>
</configuration>
</plugin>
</plugins>
Expand Down
112 changes: 69 additions & 43 deletions src/main/java/com/saucelabs/saucerest/ErrorExplainers.java
Original file line number Diff line number Diff line change
Expand Up @@ -11,102 +11,128 @@ public static String errorMessageBuilder(String errorReason, String errorExplana

public static String missingCreds() {
return String.join(System.lineSeparator(),
"If using System Properties/Environment Variables (ENVars), this can happen because:",
" * You are using a toolchain which does not automatically propagate ENVars between tools",
" * You are using a CI platform which does not automatically propagate ENVars between separate controller and processing hosts",
" * You are running tests on an environment on which these properties are not set; A newly build CI server, a Docker instance, etc"
"If using System Properties/Environment Variables (ENVars), this can happen because:",
" * You are using a toolchain which does not automatically propagate ENVars between tools",
" * You are using a CI platform which does not automatically propagate ENVars between separate controller and processing hosts",
" * You are running tests on an environment on which these properties are not set; A newly build CI server, a Docker instance, etc"
);
}

public static String incorrectCreds(String username, String accessKey) {
String endOfKey = accessKey.substring(accessKey.length() - 3);

return String.join(System.lineSeparator(),
"Not Authorized. Possible Reasons:",
" * The provided Username (" + username + ") is incorrect",
" * This account does not have permissions to access this job",
" * The provided Access Key ending with '" + endOfKey + "' is incorrect"
"Not Authorized. Possible Reasons:",
" * The provided Username (" + username + ") is incorrect",
" * This account does not have permissions to access this job",
" * The provided Access Key ending with '" + endOfKey + "' is incorrect"
);
}

static String resourceMissing() {
return String.join(System.lineSeparator(),
"Resource Not Found. Possible reasons:",
" * This job does not exist",
" * Job assets have expired"
"Resource Not Found. Possible reasons:",
" * This job does not exist",
" * Job assets have expired"
);
}

static String videoMissing() {
return String.join(System.lineSeparator(),
" * You disabled video recording by setting the `recordVideo` capability to false",
" * This test was not able to complete video encoding due to an error or early termination"
" * You disabled video recording by setting the `recordVideo` capability to false",
" * This test was not able to complete video encoding due to an error or early termination"
);
}

static String HARMissing() {
return String.join(System.lineSeparator(),
" * This test was run without Extended Debugging. See https://wiki.saucelabs.com/pages/viewpage.action?pageId=70072943",
" * This test was not able to complete HAR file recording due to an error or early termination"
" * This test was run without Extended Debugging. See https://wiki.saucelabs.com/pages/viewpage.action?pageId=70072943",
" * This test was not able to complete HAR file recording due to an error or early termination"
);
}

public static String JobNotYetDone() {
return String.join(System.lineSeparator(),
" * This job hasn't finished processing yet.",
" * After driver.quit() is called it will take some seconds to process and make available all job assets"
" * This job hasn't finished processing yet.",
" * After driver.quit() is called it will take some seconds to process and make available all job assets"
);
}

static String LogNotFound() {
return String.join(System.lineSeparator(),
" * Log file could not be found. Possible reasons:",
" * The requested log does not exist for the used framework. For example asking for the Selenium log when using Appium",
" * A error occurred where the job was created on Sauce Labs but no test were executed."
" * Log file could not be found. Possible reasons:",
" * The requested log does not exist for the used framework. For example asking for the Selenium log when using Appium",
" * A error occurred where the job was created on Sauce Labs but no test were executed."
);
}

public static String TunnelNotFound() {
return String.join(System.lineSeparator(),
" * Tunnel ID could not be found. Possible reasons:",
" * The tunnel ID requested does not exist in this data center. Ensure the data center endpoint is correct.",
" * A tunnel with this id never existed."
" * Tunnel ID could not be found. Possible reasons:",
" * The tunnel ID requested does not exist in this data center. Ensure the data center endpoint is correct.",
" * A tunnel with this id never existed."
);
}

public static String TunnelNotFound(String tunnelID) {
return String.join(System.lineSeparator(),
" * Tunnel ID " + tunnelID + " could not be found. Possible reasons:",
" * The tunnel ID requested does not exist in this data center. Ensure the data center endpoint is correct.",
" * A tunnel with this id never existed."
" * Tunnel ID " + tunnelID + " could not be found. Possible reasons:",
" * The tunnel ID requested does not exist in this data center. Ensure the data center endpoint is correct.",
" * A tunnel with this id never existed."
);
}

public static String ResigningNotAllowed() {
return String.join(System.lineSeparator(),
" * Trying to set Resigning for this app failed. Possible reason:",
" * You set the app platform to be Android. Resigning is only available and applied for iOS apps.",
" * Either use Instrumentation which is for Android apps or change the platform to iOS."
" * Trying to set Resigning for this app failed. Possible reason:",
" * You set the app platform to be Android. Resigning is only available and applied for iOS apps.",
" * Either use Instrumentation which is for Android apps or change the platform to iOS."
);
}

public static String InstrumentationNotAllowed() {
return String.join(System.lineSeparator(),
" * Trying to set Instrumentation for this app failed. Possible reason:",
" * You set the app platform to be iOS. Instrumentation is only available and applied for Android apps.",
" * Either use Resigning which is for iOS apps or change the platform to Android."
" * Trying to set Instrumentation for this app failed. Possible reason:",
" * You set the app platform to be iOS. Instrumentation is only available and applied for Android apps.",
" * Either use Resigning which is for iOS apps or change the platform to Android."
);
}

public static String DeviceLockOnlyOnAndroid() {
return String.join(System.lineSeparator(),
" * Trying to setup a PIN code is only available for Android devices."
);
}
public static String DeviceLockOnlyOnAndroid() {
return String.join(System.lineSeparator(),
" * Trying to setup a PIN code is only available for Android devices."
);
}

public static String NoResult() {
return String.join(System.lineSeparator(),
" * API request was successful but nothing found."
);
}

public static String NoResult() {
return String.join(System.lineSeparator(),
" * API request was successful but nothing found."
);
}
}
public static String AppNotFound() {
return String.join(System.lineSeparator(),
"App or app group could not be found. Possible reasons:",
" * App was automatically deleted after 60 days",
" * App was deleted manually",
" * App was never uploaded",
" * App was uploaded to a different data center",
" * App was uploaded to a different account",
" * App was uploaded to a different team",
" * App was uploaded to a different user"
);
}

public static String AppNotFound(String fileID) {
return String.join(System.lineSeparator(),
"App or app group with ID " + fileID + " could not be found. Possible reasons:",
" * App was automatically deleted after 60 days",
" * App was deleted manually",
" * App was never uploaded",
" * App was uploaded to a different data center",
" * App was uploaded to a different account",
" * App was uploaded to a different team",
" * App was uploaded to a different user"
);
}
}
Loading

0 comments on commit 4cb0524

Please sign in to comment.