Chromium Code Reviews| Index: remoting/webapp/browser_test/unauthenticated_browser_test.js |
| diff --git a/remoting/webapp/browser_test/unauthenticated_browser_test.js b/remoting/webapp/browser_test/unauthenticated_browser_test.js |
| new file mode 100644 |
| index 0000000000000000000000000000000000000000..84cef03da2f0e603332cf6f02cb22371a1ea3cdc |
| --- /dev/null |
| +++ b/remoting/webapp/browser_test/unauthenticated_browser_test.js |
| @@ -0,0 +1,80 @@ |
| +// Copyright 2015 The Chromium Authors. All rights reserved. |
| +// Use of this source code is governed by a BSD-style license that can be |
| +// found in the LICENSE file. |
| + |
| +/** |
| + * @fileoverview |
| + * @suppress {checkTypes} |
| + * |
| + * Browser test to verify that an unauthenticated state is handled correctly |
| + * in the following situations: |
| + * 1. When launching the app. |
| + * 2. When refreshing the host-list. |
| + * |
| + * TODO(jamiewalch): Add a test case for connecting to a host. |
| + */ |
| + |
| +'use strict'; |
| + |
| +/** @constructor */ |
| +browserTest.Unauthenticated = function() { |
| +}; |
| + |
| +browserTest.Unauthenticated.prototype.run = function(data) { |
| + remoting.MockIdentity.setActive(true); |
| + remoting.MockHostListApi.setActive(true); |
| + remoting.MockOAuth2Api.setActive(true); |
| + remoting.mockIdentity.setAccessToken( |
| + remoting.MockIdentity.AccessToken.NONE); |
| + remoting.startDesktopRemoting(); |
| + |
| + browserTest.waitFor( |
| + browserTest.isVisible('auth-button') |
| + ).then( |
| + this.restoreSignedInState.bind(this) |
| + ).then( |
| + function() { |
| + console.log('waiting for enabled'); |
| + return browserTest.waitFor(browserTest.isEnabled('get-started-me2me')); |
| + } |
| + ).then( |
| + // Show the Me2Me UI, invalidate the access token again, and refresh the |
| + // host-list to verify that the user is prompted to sign in again. |
| + function() { |
| + console.log('clicking get-started-me2me'); |
| + browserTest.clickOnControl('get-started-me2me'); |
| + remoting.mockIdentity.setAccessToken( |
| + remoting.MockIdentity.AccessToken.INVALID); |
| + browserTest.clickOnControl('host-list-reload'); |
| + return browserTest.waitFor( |
| + browserTest.isVisible('host-list-refresh-failed-button')); |
| + } |
| + ).then( |
| + this.restoreSignedInState.bind(this) |
| + ).then( |
| + // TODO(jamiewalch): The sign-in button of the host-list doesn't work |
| + // for apps v2, because it assumes the v1 sign-in flow. Fix this and |
| + // extend this test to handle an authentication failure at this point. |
| + function() { |
|
kelvinp
2015/01/08 22:54:41
Not sure what this block is for. Some clarificati
Jamie
2015/01/08 23:43:08
I originally had some code here to click the "sign
|
| + return Promise.resolve(); |
| + } |
| + ).then( |
| + function(value) { |
|
kelvinp
2015/01/08 22:54:41
value is unused, consider removing?
|
| + return browserTest.pass(value); |
| + }, |
| + function(error) { |
| + return browserTest.fail(error); |
| + } |
| + ); |
| +}; |
| + |
| +// Set a valid access token, then re-authenticate. Note that we're not |
| +// trying to test the sign-in flow here (that's tested elsewhere), we're |
| +// just getting the app back into a signed-in state so that we can continue |
| +// to test its behaviour if the token becomes invalid at various stages. |
| +browserTest.Unauthenticated.prototype.restoreSignedInState = function() { |
| + remoting.mockIdentity.setAccessToken( |
| + remoting.MockIdentity.AccessToken.VALID); |
| + browserTest.clickOnControl('auth-button'); |
| + return Promise.resolve(); |
| +}; |