-
Notifications
You must be signed in to change notification settings - Fork 88
VSCODE-110: Enable linux tests with graphics workaround for credential store #81
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
Merged
Merged
Changes from all commits
Commits
Show all changes
8 commits
Select commit
Hold shift + click to select a range
3c1691a
Enable linux tests with graphics workaround
ee80920
Use older ubuntu with python gnome keyring unlock
647c005
Tweak environment variable for display on linux
683fa88
Use fake keytar in testing environment
3dbbbee
Remove unused linux packages and keyring setup
1b8a78a
Remove unused xvfb config
89bf0cb
Tweak pipeline
ee82282
Improve keytar helper naming
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,63 @@ | ||
import { KeytarInterface } from '../../utils/keytar'; | ||
|
||
const retrievalDelay = 1; // ms simulated delay on keytar methods. | ||
|
||
export default class KeytarStub implements KeytarInterface { | ||
private _services: Map<string, Map<string, string>> = new Map<string, Map<string, string>>(); | ||
|
||
public async findCredentials(service: string): Promise<Map<string, string> | undefined> { | ||
await this.delay(); | ||
const savedServices = this._services.get(service); | ||
if (savedServices) { | ||
return savedServices; | ||
} | ||
|
||
return undefined; | ||
} | ||
|
||
public async getPassword(service: string, account: string): Promise<string | null> { | ||
await this.delay(); | ||
const savedService = this._services.get(service); | ||
if (savedService) { | ||
const savedAccount = savedService.get(account); | ||
|
||
if (savedAccount !== undefined) { | ||
return savedAccount; | ||
} | ||
} | ||
|
||
return null; | ||
} | ||
|
||
public async setPassword(service: string, account: string, password: string): Promise<void> { | ||
await this.delay(); | ||
let savedService = this._services.get(service); | ||
if (!savedService) { | ||
savedService = new Map<string, string>(); | ||
this._services.set(service, savedService); | ||
} | ||
|
||
savedService.set(account, password); | ||
} | ||
|
||
public async deletePassword(service: string, account: string): Promise<boolean> { | ||
await this.delay(); | ||
const savedService = this._services.get(service); | ||
if (savedService) { | ||
if (savedService.has(account)) { | ||
savedService.delete(account); | ||
return true; | ||
} | ||
} | ||
|
||
return false; | ||
} | ||
|
||
private async delay(): Promise<void> { | ||
return new Promise<void>(resolve => { | ||
setTimeout(() => { | ||
resolve(); | ||
}, retrievalDelay); | ||
}); | ||
} | ||
} |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,53 @@ | ||
import * as keytarType from 'keytar'; | ||
|
||
import { getNodeModule } from './getNodeModule'; | ||
|
||
export interface KeytarInterface { | ||
/** | ||
* Get the stored password for the service and account. | ||
* | ||
* @param service The string service name. | ||
* @param account The string account name. | ||
* | ||
* @returns A promise for the password string. | ||
*/ | ||
getPassword(service: string, account: string): Promise<string | null>; | ||
|
||
/** | ||
* Add the password for the service and account to the keychain. | ||
* | ||
* @param service The string service name. | ||
* @param account The string account name. | ||
* @param password The string password. | ||
* | ||
* @returns A promise for the set password completion. | ||
*/ | ||
setPassword( | ||
service: string, | ||
account: string, | ||
password: string | ||
): Promise<void>; | ||
|
||
/** | ||
* Delete the stored password for the service and account. | ||
* | ||
* @param service The string service name. | ||
* @param account The string account name. | ||
* | ||
* @returns A promise for the deletion status. True on success. | ||
*/ | ||
deletePassword(service: string, account: string): Promise<boolean>; | ||
} | ||
|
||
export const createKeytar = (): KeytarInterface | undefined => { | ||
// We load keytar in two different ways. This is because when the | ||
// extension is webpacked it requires the vscode external keytar dependency | ||
// differently then our development environment. | ||
let keytarModule: KeytarInterface | undefined = require('keytar'); | ||
|
||
if (!keytarModule) { | ||
keytarModule = getNodeModule<typeof keytarType>('keytar'); | ||
} | ||
|
||
return keytarModule; | ||
}; |
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
👏