Skip to content

Commit

Permalink
Updating Browserstack to use SSL (#3485)
Browse files Browse the repository at this point in the history
## Proposed changes

[//]: # (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.)
1.) Updating the hostname to match the current docs
2.) Switching to SSL <- This fixes the failed request on every test run
3.) Updating the rest api endpoints to match current docs
4.) Ripping out the hack for bail

## Types of changes

[//]: # (What types of changes does your code introduce to WebdriverIO?)
[//]: # (_Put an `x` in the boxes that apply_)

- [ ] Bugfix (non-breaking change which fixes an issue)
- [X] New feature (non-breaking change which adds functionality)
- [ ] Breaking change (fix or feature that would cause existing functionality to not work as expected)

## Checklist

[//]: # (_Put an `x` in the boxes that apply. You can also fill these out after creating the PR. If you're unsure about any of them, 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._)

- [X] I have read the [CONTRIBUTING](https://github.com/webdriverio/webdriverio/blob/master/CONTRIBUTING.md) doc
- [X] I have added tests that prove my fix is effective or that my feature works
- [ ] 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...)

### Reviewers: @webdriverio/technical-committee
  • Loading branch information
abjerstedt authored and christian-bromann committed Feb 2, 2019
1 parent 713f021 commit 4141627
Show file tree
Hide file tree
Showing 4 changed files with 9 additions and 24 deletions.
14 changes: 3 additions & 11 deletions packages/wdio-browserstack-service/src/service.js
Expand Up @@ -51,15 +51,7 @@ export default class BrowserstackService {
}
}

after(result) {
/**
* set failures if user has bail option set in which case afterTest and
* afterSuite aren't executed before after hook
*/
if (global.browser.config.mochaOpts && global.browser.config.mochaOpts.bail && Boolean(result)) {
this.failures = 1
}

after() {
return this._update(this.sessionId, this._getBody())
}

Expand All @@ -72,7 +64,7 @@ export default class BrowserstackService {

_update(sessionId, requestBody) {
return new Promise((resolve, reject) => {
request.put(`https://www.browserstack.com/automate/sessions/${sessionId}.json`, {
request.put(`https://api.browserstack.com/automate/sessions/${sessionId}.json`, {
json: true,
auth: this.auth,
body: requestBody
Expand All @@ -95,7 +87,7 @@ export default class BrowserstackService {
_printSessionURL() {
const capabilities = global.browser.capabilities
return new Promise((resolve,reject) => request.get(
`https://www.browserstack.com/automate/sessions/${this.sessionId}.json`,
`https://api.browserstack.com/automate/sessions/${this.sessionId}.json`,
{
json: true,
auth: this.auth
Expand Down
9 changes: 0 additions & 9 deletions packages/wdio-browserstack-service/tests/service.test.js
Expand Up @@ -223,15 +223,6 @@ describe('after', () => {
expect(service.failures).toBe(0)
expect(updateSpy).toHaveBeenCalled()
})

it('should set failures if error happend and bail is set', () => {
global.browser.config.mochaOpts = { bail: true }
const updateSpy = jest.spyOn(service, '_update')

service.after(1)
expect(updateSpy).toHaveBeenCalled()
expect(service.failures).toBe(1)
})
})

describe('_getBody', () => {
Expand Down
5 changes: 3 additions & 2 deletions packages/wdio-config/src/utils.js
Expand Up @@ -27,8 +27,9 @@ export function detectBackend (options = {}) {
*/
if (typeof user === 'string' && key.length === 20) {
return {
hostname: 'hub.browserstack.com',
port: 80
protocol: 'https',
hostname: 'hub-cloud.browserstack.com',
port: 443
}
}

Expand Down
5 changes: 3 additions & 2 deletions packages/wdio-config/tests/detectBackend.test.js
Expand Up @@ -35,8 +35,9 @@ describe('detectBackend', () => {
user: 'foobar',
key: 'zHcv9sZ39ip8ZPsxBVJ2'
})
expect(caps.hostname).toBe('hub.browserstack.com')
expect(caps.port).toBe(80)
expect(caps.hostname).toBe('hub-cloud.browserstack.com')
expect(caps.port).toBe(443)
expect(caps.protocol).toBe('https')
})

it('should detect testingbot user', () => {
Expand Down

0 comments on commit 4141627

Please sign in to comment.