OLD | NEW |
(Empty) | |
| 1 // Copyright 2015 The Chromium Authors. All rights reserved. |
| 2 // Use of this source code is governed by a BSD-style license that can be |
| 3 // found in the LICENSE file. |
| 4 |
| 5 /** |
| 6 * @fileoverview |
| 7 * @suppress {checkTypes} |
| 8 * |
| 9 * Browser test to verify that an unauthenticated state is handled correctly |
| 10 * in the following situations: |
| 11 * 1. When launching the app. |
| 12 * 2. When refreshing the host-list. |
| 13 * |
| 14 * TODO(jamiewalch): Add a test case for connecting to a host. |
| 15 */ |
| 16 |
| 17 'use strict'; |
| 18 |
| 19 /** @constructor */ |
| 20 browserTest.Unauthenticated = function() { |
| 21 }; |
| 22 |
| 23 browserTest.Unauthenticated.prototype.run = function(data) { |
| 24 remoting.MockIdentity.setActive(true); |
| 25 remoting.MockHostListApi.setActive(true); |
| 26 remoting.MockOAuth2Api.setActive(true); |
| 27 remoting.mockIdentity.setAccessToken( |
| 28 remoting.MockIdentity.AccessToken.NONE); |
| 29 remoting.startDesktopRemoting(); |
| 30 |
| 31 browserTest.waitFor( |
| 32 browserTest.isVisible('auth-button') |
| 33 ).then( |
| 34 this.restoreSignedInState.bind(this) |
| 35 ).then( |
| 36 function() { |
| 37 console.log('waiting for enabled'); |
| 38 return browserTest.waitFor(browserTest.isEnabled('get-started-me2me')); |
| 39 } |
| 40 ).then( |
| 41 // Show the Me2Me UI, invalidate the access token again, and refresh the |
| 42 // host-list to verify that the user is prompted to sign in again. |
| 43 function() { |
| 44 console.log('clicking get-started-me2me'); |
| 45 browserTest.clickOnControl('get-started-me2me'); |
| 46 remoting.mockIdentity.setAccessToken( |
| 47 remoting.MockIdentity.AccessToken.INVALID); |
| 48 browserTest.clickOnControl('host-list-reload'); |
| 49 return browserTest.waitFor( |
| 50 browserTest.isVisible('host-list-refresh-failed-button')); |
| 51 } |
| 52 ).then( |
| 53 this.restoreSignedInState.bind(this) |
| 54 // TODO(jamiewalch): The sign-in button of the host-list doesn't work |
| 55 // for apps v2, because it assumes the v1 sign-in flow. Fix this and |
| 56 // extend this test to handle an authentication failure at this point. |
| 57 ).then(browserTest.pass, browserTest.fail); |
| 58 }; |
| 59 |
| 60 // Set a valid access token, then re-authenticate. Note that we're not |
| 61 // trying to test the sign-in flow here (that's tested elsewhere), we're |
| 62 // just getting the app back into a signed-in state so that we can continue |
| 63 // to test its behaviour if the token becomes invalid at various stages. |
| 64 browserTest.Unauthenticated.prototype.restoreSignedInState = function() { |
| 65 remoting.mockIdentity.setAccessToken( |
| 66 remoting.MockIdentity.AccessToken.VALID); |
| 67 browserTest.clickOnControl('auth-button'); |
| 68 return Promise.resolve(); |
| 69 }; |
OLD | NEW |