PSA: GAIA account pool, and chrome.Auth deprecation

61 views
Skip to first unread message

Shuhei Takahashi (nya)

unread,
Mar 10, 2021, 12:45:51 AM3/10/21
to tast-users

TL;DR: You can log in with randomly chosen GAIA credentials with chrome.GAIALoginPool option. To log in with fixed credentials, pass a chrome.Creds struct to chrome.GAIALogin or chrome.FakeLogin.



We introduced a new option chrome.GAIALoginPool which allows you to choose login credentials randomly from a list of GAIA credentials (crbug.com/1182155). You can use this option if your tests logging in with real GAIA accounts are suffering from flakiness due to the per-account login rate limit (e.g. crbug.com/1166530).


We provide credentials of 20 test GAIA accounts via ui.gaiaPoolDefault runtime variable. You can use this default pool if your tests don't need special setups in GAIA accounts.


Here is an example to perform a GAIA login with pooled credentials. See ui.ChromeLoginGAIA for working code.


chrome.New(ctx, chrome.GAIALoginPool(s.RequiredVar("ui.gaiaPoolDefault")))



Besides, we're removing chrome.Auth, chrome.ParentAuth, chrome.Contact options in favor of chrome.GAIALogin and chrome.FakeLogin options accepting a chrome.Creds struct, which contains full credentials. See below for comparison of old/new APIs.


// Performing a GAIA login with a normal account:

// OLD

chrome.New(ctx, chrome.GAIALogin(), chrome.Auth(user, pass, ""))

// NEW

chrome.New(ctx, chrome.GAIALogin(chrome.Creds{User: user, Pass: pass}))


// Performing a GAIA login with a unicorn account:

// OLD

chrome.New(ctx, chrome.GAIALogin(), chrome.Auth(user, pass, ""), chrome.ParentAuth(parentUser, parentPass))

// NEW

chrome.New(ctx, chrome.GAIALogin(chrome.Creds{User: user, Pass: pass, ParentUser: parentUser, ParentPass: parentPass}))


// Performing a fake login:

// OLD

chrome.New(ctx, chrome.Auth(user, pass, gaiaID))

// NEW

chrome.New(ctx, chrome.FakeLogin(chrome.Creds{User: user, Pass: pass, GAIAID: gaiaID}))


This change makes it easy to treat credentials as a value. For example, it's trivial to log into the same GAIA account multiple times while using a credential pool (crbug.com/1184434):


// Log in with randomly chosen credentials.

cr, err := chrome.New(ctx, chrome.GAIALoginPool(...))

if err != nil {

  ...

}

creds := cr.Creds() // save chosen credentials

cr.Close()


// Log in with the same credentials again.

cr, err := chrome.New(ctx, chrome.GAIALogin(creds))

if err != nil {

  ...

}



--
Shuhei Takahashi a.k.a nya <n...@google.com>
Reply all
Reply to author
Forward
0 new messages