Chromium Code Reviews| 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 ).then( | |
| 55 // TODO(jamiewalch): The sign-in button of the host-list doesn't work | |
| 56 // for apps v2, because it assumes the v1 sign-in flow. Fix this and | |
| 57 // extend this test to handle an authentication failure at this point. | |
| 58 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
| |
| 59 return Promise.resolve(); | |
| 60 } | |
| 61 ).then( | |
| 62 function(value) { | |
|
kelvinp
2015/01/08 22:54:41
value is unused, consider removing?
| |
| 63 return browserTest.pass(value); | |
| 64 }, | |
| 65 function(error) { | |
| 66 return browserTest.fail(error); | |
| 67 } | |
| 68 ); | |
| 69 }; | |
| 70 | |
| 71 // Set a valid access token, then re-authenticate. Note that we're not | |
| 72 // trying to test the sign-in flow here (that's tested elsewhere), we're | |
| 73 // just getting the app back into a signed-in state so that we can continue | |
| 74 // to test its behaviour if the token becomes invalid at various stages. | |
| 75 browserTest.Unauthenticated.prototype.restoreSignedInState = function() { | |
| 76 remoting.mockIdentity.setAccessToken( | |
| 77 remoting.MockIdentity.AccessToken.VALID); | |
| 78 browserTest.clickOnControl('auth-button'); | |
| 79 return Promise.resolve(); | |
| 80 }; | |
| OLD | NEW |