+ owner_uuid: "ownerUuid",
+ is_admin: false,
+ is_active: true,
+ username: "jdoe",
+ prefs: {}
+ })
+ .onGet("/api_client_authorizations/current")
+ .reply(200, {
+ expires_at: "2140-01-01T00:00:00.000Z"
+ })
+ .onGet("https://xc59z.example.com/discovery/v1/apis/arvados/v1/rest")
+ .reply(200, {
+ baseUrl: "https://xc59z.example.com/arvados/v1",
+ keepWebServiceUrl: "",
+ keepWebInlineServiceUrl: "",
+ remoteHosts: {},
+ rootUrl: "https://xc59z.example.com",
+ uuidPrefix: "xc59z",
+ websocketUrl: "",
+ workbenchUrl: "",
+ workbench2Url: "",
+ revision: 12345678
+ });
+
+ importMocks.push(ImportMock.mockFunction(servicesModule, 'createServices', services));
+
+ // Only test the case when a link account operation is not being cancelled
+ sessionStorage.setItem(ACCOUNT_LINK_STATUS_KEY, "0");
+ localStorage.setItem(API_TOKEN_KEY, "token");
+
+ const config: any = {
+ rootUrl: "https://zzzzz.example.com",
+ uuidPrefix: "zzzzz",
+ remoteHosts: { xc59z: "xc59z.example.com" },
+ apiRevision: 12345678,
+ clusterConfig: {
+ Login: { LoginCluster: "" },
+ },
+ };
+
+ store.dispatch(initAuth(config));
+
+ store.subscribe(() => {
+ const auth = store.getState().auth;
+ if (auth.apiToken === "token" &&
+ auth.sessions.length === 2 &&
+ auth.sessions[0].status === SessionStatus.VALIDATED &&
+ auth.sessions[1].status === SessionStatus.VALIDATED
+ ) {
+ try {
+ expect(auth).toEqual({
+ apiToken: "token",
+ apiTokenExpiration: new Date("2140-01-01T00:00:00.000Z"),
+ apiTokenLocation: "localStorage",
+ config: {
+ apiRevision: 12345678,
+ clusterConfig: {
+ Login: {
+ LoginCluster: "",
+ },
+ },
+ remoteHosts: {
+ "xc59z": "xc59z.example.com",
+ },
+ rootUrl: "https://zzzzz.example.com",
+ uuidPrefix: "zzzzz",
+ },
+ sshKeys: [],
+ extraApiToken: undefined,
+ extraApiTokenExpiration: undefined,
+ homeCluster: "zzzzz",
+ localCluster: "zzzzz",
+ loginCluster: undefined,
+ remoteHostsConfig: {
+ "zzzzz": {
+ "apiRevision": 12345678,
+ "clusterConfig": {
+ "Login": {
+ "LoginCluster": "",
+ },
+ },
+ "remoteHosts": {
+ "xc59z": "xc59z.example.com",
+ },
+ "rootUrl": "https://zzzzz.example.com",
+ "uuidPrefix": "zzzzz",
+ },
+ "xc59z": mockConfig({
+ apiRevision: 12345678,
+ baseUrl: "https://xc59z.example.com/arvados/v1",
+ rootUrl: "https://xc59z.example.com",
+ uuidPrefix: "xc59z"
+ })
+ },
+ remoteHosts: {
+ zzzzz: "zzzzz.example.com",
+ xc59z: "xc59z.example.com"
+ },
+ sessions: [{
+ "active": true,
+ "baseUrl": undefined,
+ "clusterId": "zzzzz",
+ "email": "test@test.com",
+ "loggedIn": true,
+ "remoteHost": "https://zzzzz.example.com",
+ "status": 2,
+ "token": "token",
+ "name": "John Doe",
+ "apiRevision": 12345678,
+ "uuid": "zzzzz-tpzed-abcefg",
+ "userIsActive": true
+ }, {
+ "active": false,
+ "baseUrl": "",
+ "clusterId": "xc59z",
+ "email": "",
+ "loggedIn": false,
+ "remoteHost": "xc59z.example.com",
+ "status": 2,
+ "token": "",
+ "name": "",
+ "uuid": "",
+ "apiRevision": 0,
+ }],
+ user: {
+ email: "test@test.com",
+ firstName: "John",
+ lastName: "Doe",
+ uuid: "zzzzz-tpzed-abcefg",
+ ownerUuid: "ownerUuid",
+ username: "jdoe",
+ prefs: { profile: {} },
+ isAdmin: false,
+ isActive: true
+ }
+ });
+ done();
+ } catch (e) {
+ fail(e);
+ }