Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Test new behavior of ClearSessionPreference in getSession #180771

Closed
2 tasks done
TylerLeonhardt opened this issue Apr 25, 2023 · 4 comments
Closed
2 tasks done

Test new behavior of ClearSessionPreference in getSession #180771

TylerLeonhardt opened this issue Apr 25, 2023 · 4 comments

Comments

@TylerLeonhardt
Copy link
Member

TylerLeonhardt commented Apr 25, 2023

Refs: #152399

Complexity: 2

Create Issue


The issue referenced is encompassing the overall story for multi-account extensions, and we'll certainly have a TPI for that when it's ready, but one part that has gone in does affect users today and that's the changes to ClearSessionPreference which is a part of the getSession API.

You see, for authentication providers that support being signed into multiple accounts at once (like Microsoft), the user will be prompted to select an account to use when vscode.authentication.getSession with createIfNone: true is called.

Previous behavior:

This preference is remembered until vscode.authentication.getSession is called with the ClearSessionPreference flag.

New behavior:

This preference is remembered per-workspace until vscode.authentication.getSession is called in that workspace with the ClearSessionPreference flag.

This sets us up to allow an extension like GitHub Repos say "this workspace is this account and that workspace is that account".

Anyway, it's a lot of backstory, but the testing itself is pretty easy... All I want to you do is:

  • Grab my test extension that leverages this API: vscode-clearsessionpref-0.0.1.vsix.zip (unzip it and run Extensions: Install from VSIX...)
  • Open two windows each pointing to a different workspace
  • Run the command Run Clear Session Preference Test in one, chose your work account
  • In the other window, run the same command. Note: it should go directly to the notification that says what account you're logged in to
  • Now, in that new window, click the "Clear session preference" button in the notification... follow the flow to add a new account (your personal Microsoft account)
  • Reload both windows and run Run Clear Session Preference Test

Expected:

  • The workspace that you didn't clear the session preference in should have the account as before (work)
  • The workspace that you did clear the session preference in should have the new account (personal)
What the code of the test extension looks like

import * as vscode from 'vscode';

export function activate(context: vscode.ExtensionContext) {
	let disposable = vscode.commands.registerCommand('vscode-clearsessionpref.helloWorld', async () => {
		const sessionMaybe = await vscode.authentication.getSession('microsoft', ['email'], { silent: true });
		const session1 = sessionMaybe ?? await vscode.authentication.getSession('microsoft', ['email'], { createIfNone: true });
		const yes = await vscode.window.showInformationMessage(`Account: ${session1.account.label}`, 'Clear session preference');
		if (yes) {
			const session2 = await vscode.authentication.getSession('microsoft', ['email'], { clearSessionPreference: true, createIfNone: true });
			await vscode.window.showInformationMessage(`Account: ${session2.account.label}`);
		}
	});

	context.subscriptions.push(disposable);
}

export function deactivate() {}

@hbons
Copy link
Member

hbons commented Apr 25, 2023

I'll be out of office and won't be able to test this round.

@roblourens roblourens removed their assignment Apr 25, 2023
@roblourens
Copy link
Member

Thanks for the test extension and clear steps!

@roblourens
Copy link
Member

Should the description for clearSessionPreference be updated to describe the change?

@TylerLeonhardt
Copy link
Member Author

@roblourens yeah you're right... it probably should. Wanna Create Issue?

@rebornix rebornix removed their assignment Apr 25, 2023
@github-actions github-actions bot locked and limited conversation to collaborators Jun 9, 2023
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Projects
None yet
Development

No branches or pull requests

4 participants