mirror of
https://github.com/ckaczor/sqltoolsservice.git
synced 2026-01-14 17:23:27 -05:00
Create Firewall Rule support with a simple Resource Provider implementation
Implementation of the resource provider APIs in order to support Create Firewall Rule. Provides definition for a ResourceProvider and Authentication service. The ResourceProvider supports firewall rules for now, and since authentication is routed through that method it will call into the auth service to set up the current account to be used. Additional notes: - Fixed deserialization by adding an Accept header. This shouldn't be necessary, but for some reason the firewall rule defaults to XML without this - Use generic server list and parse the ID to get the resource group, avoiding a large number of extra calls for each RG - Errors now include error message from the API
This commit is contained in:
@@ -0,0 +1,40 @@
|
||||
//
|
||||
// Copyright (c) Microsoft. All rights reserved.
|
||||
// Licensed under the MIT license. See LICENSE file in the project root for full license information.
|
||||
//
|
||||
|
||||
using Microsoft.SqlTools.Hosting.Protocol;
|
||||
using Microsoft.SqlTools.Extensibility;
|
||||
using Microsoft.SqlTools.ResourceProvider.Core;
|
||||
using Moq;
|
||||
using Microsoft.SqlTools.ResourceProvider;
|
||||
using Microsoft.SqlTools.ResourceProvider.Core.Authentication;
|
||||
|
||||
namespace Microsoft.SqlTools.ServiceLayer.UnitTests.Formatter
|
||||
{
|
||||
public class ResourceProviderServiceTests
|
||||
{
|
||||
public ResourceProviderServiceTests()
|
||||
{
|
||||
HostMock = new Mock<IProtocolEndpoint>();
|
||||
AuthenticationManagerMock = new Mock<IAzureAuthenticationManager>();
|
||||
ResourceManagerMock = new Mock<IAzureResourceManager>();
|
||||
ServiceProvider = ExtensionServiceProvider.CreateFromAssembliesInDirectory(ResourceProviderHostLoader.GetResourceProviderExtensionDlls());
|
||||
ServiceProvider.RegisterSingleService<IAzureAuthenticationManager>(AuthenticationManagerMock.Object);
|
||||
ServiceProvider.RegisterSingleService<IAzureResourceManager>(ResourceManagerMock.Object);
|
||||
HostLoader.InitializeHostedServices(ServiceProvider, HostMock.Object);
|
||||
ResourceProviderService = ServiceProvider.GetService<ResourceProviderService>();
|
||||
}
|
||||
|
||||
protected RegisteredServiceProvider ServiceProvider { get; private set; }
|
||||
protected Mock<IProtocolEndpoint> HostMock { get; private set; }
|
||||
|
||||
protected Mock<IAzureAuthenticationManager> AuthenticationManagerMock { get; set; }
|
||||
protected Mock<IAzureResourceManager> ResourceManagerMock { get; set; }
|
||||
|
||||
protected ResourceProviderService ResourceProviderService { get; private set; }
|
||||
|
||||
|
||||
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user