Using registry keys to limit devcanvas usage to just team members (#613)
* stash * reg key scanning * fix * removing vscode * updating tests * fix test * change key name
This commit is contained in:
Родитель
4ca5cace60
Коммит
358bc24767
|
@ -144,7 +144,19 @@ namespace Sarif.Viewer.VisualStudio.ResultSources.DeveloperCanvas.Core.Services
|
|||
/// <inheritdoc/>
|
||||
public System.Threading.Tasks.Task InitializeAsync()
|
||||
{
|
||||
// TODO: Remove this when merging into main.
|
||||
return IsActiveAsync();
|
||||
}
|
||||
|
||||
/// <inheritdoc/>
|
||||
public Task<Result> IsActiveAsync()
|
||||
{
|
||||
// TODO: remove below to release to general users.
|
||||
string devcanvasKey = (string)Registry.GetValue("HKEY_CURRENT_USER\\Software\\Microsoft\\VisualStudio\\devcanvas", "DevCanvasInsider", null);
|
||||
if (devcanvasKey != "True")
|
||||
{
|
||||
return System.Threading.Tasks.Task.FromResult(Result.Failure("Not a DevCanvas user."));
|
||||
}
|
||||
|
||||
DevCanvasTracer.WriteLine($"Initializing {nameof(DevCanvasResultSourceService)}. Version 11/20");
|
||||
string userName = (string)Registry.GetValue("HKEY_CURRENT_USER\\Software\\Microsoft\\VSCommon\\ConnectedUser\\IdeUserV4\\Cache", "EmailAddress", null);
|
||||
|
||||
|
@ -160,12 +172,6 @@ namespace Sarif.Viewer.VisualStudio.ResultSources.DeveloperCanvas.Core.Services
|
|||
}
|
||||
}
|
||||
|
||||
/// <inheritdoc/>
|
||||
public Task<Result> IsActiveAsync()
|
||||
{
|
||||
return System.Threading.Tasks.Task.FromResult(Result.Success());
|
||||
}
|
||||
|
||||
/// <inheritdoc/>
|
||||
public Task<Result<bool, ErrorType>> OnDocumentEventAsync(string[] filePaths)
|
||||
{
|
||||
|
|
|
@ -70,12 +70,12 @@ namespace Microsoft.Sarif.Viewer.ResultSources.Factory.UnitTests
|
|||
|
||||
result.IsSuccess.Should().BeTrue();
|
||||
result.Value.Should().NotBeNull();
|
||||
result.Value.Count.Should().Be(2);
|
||||
result.Value.Count.Should().Be(1);
|
||||
result.Value[0].GetType().Name.Should().Be("GitHubSourceService");
|
||||
}
|
||||
|
||||
[Fact]
|
||||
public void GetResultSourceService_ReturnsPlatformNotSupported_WhenPathDoesNotContainsDotGitDirectory()
|
||||
public async Task GetResultSourceService_ReturnsPlatformNotSupported_WhenPathDoesNotContainsDotGitDirectoryAsync()
|
||||
{
|
||||
string path = @"C:\Git\MyProject";
|
||||
string uri = "https://github.com/user/myproject.git";
|
||||
|
@ -106,11 +106,9 @@ namespace Microsoft.Sarif.Viewer.ResultSources.Factory.UnitTests
|
|||
standardKernel.Bind<IStatusBarService>().ToConstant(mockStatusBarService.Object);
|
||||
|
||||
var resultSourceFactory = new ResultSourceFactory(path, standardKernel, (string key) => true, SetOptionStateCallback);
|
||||
Result<List<IResultSourceService>, ErrorType> result = resultSourceFactory.GetResultSourceServicesAsync().ConfigureAwait(false).GetAwaiter().GetResult();
|
||||
Result<List<IResultSourceService>, ErrorType> result = await resultSourceFactory.GetResultSourceServicesAsync().ConfigureAwait(false);
|
||||
|
||||
result.Value.Count.Should().Be(1);
|
||||
result.IsSuccess.Should().BeTrue();
|
||||
result.Value[0].GetType().Name.Should().Be("DevCanvasResultSourceService");
|
||||
result.Error.Should().Be(ErrorType.PlatformNotSupported);
|
||||
}
|
||||
|
||||
[Fact]
|
||||
|
@ -175,7 +173,7 @@ namespace Microsoft.Sarif.Viewer.ResultSources.Factory.UnitTests
|
|||
factory.AddResultSource(new SampleResultSourceService().GetType(), 1, 1);
|
||||
ResultSourceHost resultSourceHost = new ResultSourceHost(factory);
|
||||
await resultSourceHost.RequestAnalysisResultsAsync();
|
||||
resultSourceHost.ServiceCount.Should().Be(3);
|
||||
resultSourceHost.ServiceCount.Should().Be(2);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
Загрузка…
Ссылка в новой задаче