mirror of
https://github.com/ckaczor/sqltoolsservice.git
synced 2026-02-06 17:24:59 -05:00
Unit tests for Azure scenarios (#495)
* Test firewall rule handling is able to process through the service layer * Additional tests for authentication and the resource wrapper code * Positive test case for CreateFirewallRule * Fixed copyright and usings
This commit is contained in:
@@ -158,7 +158,7 @@ namespace Microsoft.SqlTools.ResourceProvider.Core.Firewall
|
||||
|
||||
if (subscriptions == null)
|
||||
{
|
||||
throw new FirewallRuleException(SR.FirewallRuleCreationFailed);
|
||||
throw new FirewallRuleException(SR.NoSubscriptionsFound);
|
||||
}
|
||||
|
||||
ServiceResponse<FirewallRuleResource> response = await AzureUtil.ExecuteGetAzureResourceAsParallel((object)null,
|
||||
|
||||
@@ -27,7 +27,15 @@ namespace Microsoft.SqlTools.ResourceProvider.Core
|
||||
Keys.Culture = value;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
public static string NoSubscriptionsFound
|
||||
{
|
||||
get
|
||||
{
|
||||
return Keys.GetString(Keys.NoSubscriptionsFound);
|
||||
}
|
||||
}
|
||||
|
||||
public static string AzureServerNotFound
|
||||
{
|
||||
@@ -35,7 +43,7 @@ namespace Microsoft.SqlTools.ResourceProvider.Core
|
||||
{
|
||||
return Keys.GetString(Keys.AzureServerNotFound);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public static string AzureSubscriptionFailedErrorMessage
|
||||
{
|
||||
@@ -43,7 +51,7 @@ namespace Microsoft.SqlTools.ResourceProvider.Core
|
||||
{
|
||||
return Keys.GetString(Keys.AzureSubscriptionFailedErrorMessage);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public static string DatabaseDiscoveryFailedErrorMessage
|
||||
{
|
||||
@@ -51,7 +59,7 @@ namespace Microsoft.SqlTools.ResourceProvider.Core
|
||||
{
|
||||
return Keys.GetString(Keys.DatabaseDiscoveryFailedErrorMessage);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public static string FirewallRuleAccessForbidden
|
||||
{
|
||||
@@ -59,7 +67,7 @@ namespace Microsoft.SqlTools.ResourceProvider.Core
|
||||
{
|
||||
return Keys.GetString(Keys.FirewallRuleAccessForbidden);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public static string FirewallRuleCreationFailed
|
||||
{
|
||||
@@ -67,7 +75,7 @@ namespace Microsoft.SqlTools.ResourceProvider.Core
|
||||
{
|
||||
return Keys.GetString(Keys.FirewallRuleCreationFailed);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public static string FirewallRuleCreationFailedWithError
|
||||
{
|
||||
@@ -75,7 +83,7 @@ namespace Microsoft.SqlTools.ResourceProvider.Core
|
||||
{
|
||||
return Keys.GetString(Keys.FirewallRuleCreationFailedWithError);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public static string InvalidIpAddress
|
||||
{
|
||||
@@ -83,7 +91,7 @@ namespace Microsoft.SqlTools.ResourceProvider.Core
|
||||
{
|
||||
return Keys.GetString(Keys.InvalidIpAddress);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public static string InvalidServerTypeErrorMessage
|
||||
{
|
||||
@@ -91,7 +99,7 @@ namespace Microsoft.SqlTools.ResourceProvider.Core
|
||||
{
|
||||
return Keys.GetString(Keys.InvalidServerTypeErrorMessage);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public static string LoadingExportableFailedGeneralErrorMessage
|
||||
{
|
||||
@@ -99,7 +107,7 @@ namespace Microsoft.SqlTools.ResourceProvider.Core
|
||||
{
|
||||
return Keys.GetString(Keys.LoadingExportableFailedGeneralErrorMessage);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public static string FirewallRuleUnsupportedConnectionType
|
||||
{
|
||||
@@ -107,7 +115,7 @@ namespace Microsoft.SqlTools.ResourceProvider.Core
|
||||
{
|
||||
return Keys.GetString(Keys.FirewallRuleUnsupportedConnectionType);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
[System.Runtime.CompilerServices.CompilerGeneratedAttribute()]
|
||||
public class Keys
|
||||
@@ -115,37 +123,40 @@ namespace Microsoft.SqlTools.ResourceProvider.Core
|
||||
static ResourceManager resourceManager = new ResourceManager("Microsoft.SqlTools.ResourceProvider.Core.Localization.SR", typeof(SR).GetTypeInfo().Assembly);
|
||||
|
||||
static CultureInfo _culture = null;
|
||||
|
||||
|
||||
public const string AzureServerNotFound = "AzureServerNotFound";
|
||||
|
||||
|
||||
public const string AzureSubscriptionFailedErrorMessage = "AzureSubscriptionFailedErrorMessage";
|
||||
|
||||
|
||||
public const string DatabaseDiscoveryFailedErrorMessage = "DatabaseDiscoveryFailedErrorMessage";
|
||||
|
||||
|
||||
public const string FirewallRuleAccessForbidden = "FirewallRuleAccessForbidden";
|
||||
|
||||
|
||||
public const string FirewallRuleCreationFailed = "FirewallRuleCreationFailed";
|
||||
|
||||
|
||||
public const string FirewallRuleCreationFailedWithError = "FirewallRuleCreationFailedWithError";
|
||||
|
||||
|
||||
public const string InvalidIpAddress = "InvalidIpAddress";
|
||||
|
||||
|
||||
public const string InvalidServerTypeErrorMessage = "InvalidServerTypeErrorMessage";
|
||||
|
||||
|
||||
public const string LoadingExportableFailedGeneralErrorMessage = "LoadingExportableFailedGeneralErrorMessage";
|
||||
|
||||
|
||||
public const string FirewallRuleUnsupportedConnectionType = "FirewallRuleUnsupportedConnectionType";
|
||||
|
||||
|
||||
|
||||
public const string NoSubscriptionsFound = "NoSubscriptionsFound";
|
||||
|
||||
|
||||
public const string AzureServerNotFound = "AzureServerNotFound";
|
||||
|
||||
|
||||
public const string AzureSubscriptionFailedErrorMessage = "AzureSubscriptionFailedErrorMessage";
|
||||
|
||||
|
||||
public const string DatabaseDiscoveryFailedErrorMessage = "DatabaseDiscoveryFailedErrorMessage";
|
||||
|
||||
|
||||
public const string FirewallRuleAccessForbidden = "FirewallRuleAccessForbidden";
|
||||
|
||||
|
||||
public const string FirewallRuleCreationFailed = "FirewallRuleCreationFailed";
|
||||
|
||||
|
||||
public const string FirewallRuleCreationFailedWithError = "FirewallRuleCreationFailedWithError";
|
||||
|
||||
|
||||
public const string InvalidIpAddress = "InvalidIpAddress";
|
||||
|
||||
|
||||
public const string InvalidServerTypeErrorMessage = "InvalidServerTypeErrorMessage";
|
||||
|
||||
|
||||
public const string LoadingExportableFailedGeneralErrorMessage = "LoadingExportableFailedGeneralErrorMessage";
|
||||
|
||||
|
||||
public const string FirewallRuleUnsupportedConnectionType = "FirewallRuleUnsupportedConnectionType";
|
||||
|
||||
|
||||
private Keys()
|
||||
{ }
|
||||
@@ -166,7 +177,7 @@ namespace Microsoft.SqlTools.ResourceProvider.Core
|
||||
{
|
||||
return resourceManager.GetString(key, _culture);
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -117,44 +117,48 @@
|
||||
<resheader name="writer">
|
||||
<value>System.Resources.ResXResourceWriter, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value>
|
||||
</resheader>
|
||||
<data name="NoSubscriptionsFound" xml:space="preserve">
|
||||
<value>No subscriptions were found for the currently logged in user account.</value>
|
||||
<comment></comment>
|
||||
</data>
|
||||
<data name="AzureServerNotFound" xml:space="preserve">
|
||||
<value>The server you specified {0} does not exist in any subscription in {1}. Either you have signed in with an incorrect account or your server was removed from subscription(s) in this account. Please check your account and try again.</value>
|
||||
<comment></comment>
|
||||
</data>
|
||||
</data>
|
||||
<data name="AzureSubscriptionFailedErrorMessage" xml:space="preserve">
|
||||
<value>An error occurred while getting Azure subscriptions</value>
|
||||
<comment></comment>
|
||||
</data>
|
||||
</data>
|
||||
<data name="DatabaseDiscoveryFailedErrorMessage" xml:space="preserve">
|
||||
<value>An error occurred while getting databases from servers of type {0} from {1}</value>
|
||||
<comment></comment>
|
||||
</data>
|
||||
</data>
|
||||
<data name="FirewallRuleAccessForbidden" xml:space="preserve">
|
||||
<value>{0} does not have permission to change the server firewall rule. Try again with a different account that is an Owner or Contributor of the Azure subscription or the server.</value>
|
||||
<comment></comment>
|
||||
</data>
|
||||
</data>
|
||||
<data name="FirewallRuleCreationFailed" xml:space="preserve">
|
||||
<value>An error occurred while creating a new firewall rule.</value>
|
||||
<comment></comment>
|
||||
</data>
|
||||
</data>
|
||||
<data name="FirewallRuleCreationFailedWithError" xml:space="preserve">
|
||||
<value>An error occurred while creating a new firewall rule: '{0}'</value>
|
||||
<comment></comment>
|
||||
</data>
|
||||
</data>
|
||||
<data name="InvalidIpAddress" xml:space="preserve">
|
||||
<value>Invalid IP address</value>
|
||||
<comment></comment>
|
||||
</data>
|
||||
</data>
|
||||
<data name="InvalidServerTypeErrorMessage" xml:space="preserve">
|
||||
<value>Server Type is invalid.</value>
|
||||
<comment></comment>
|
||||
</data>
|
||||
</data>
|
||||
<data name="LoadingExportableFailedGeneralErrorMessage" xml:space="preserve">
|
||||
<value>A required dll cannot be loaded. Please repair your application.</value>
|
||||
<comment></comment>
|
||||
</data>
|
||||
</data>
|
||||
<data name="FirewallRuleUnsupportedConnectionType" xml:space="preserve">
|
||||
<value>Cannot open a firewall rule for the specified connection type</value>
|
||||
<comment></comment>
|
||||
</data>
|
||||
</root>
|
||||
</data>
|
||||
</root>
|
||||
|
||||
@@ -22,6 +22,7 @@
|
||||
|
||||
############################################################################
|
||||
# Azure Core DLL
|
||||
NoSubscriptionsFound = No subscriptions were found for the currently logged in user account.
|
||||
AzureServerNotFound = The server you specified {0} does not exist in any subscription in {1}. Either you have signed in with an incorrect account or your server was removed from subscription(s) in this account. Please check your account and try again.
|
||||
AzureSubscriptionFailedErrorMessage = An error occurred while getting Azure subscriptions
|
||||
DatabaseDiscoveryFailedErrorMessage = An error occurred while getting databases from servers of type {0} from {1}
|
||||
|
||||
@@ -52,6 +52,11 @@
|
||||
<target state="new">An error occurred while creating a new firewall rule: '{0}'</target>
|
||||
<note></note>
|
||||
</trans-unit>
|
||||
<trans-unit id="NoSubscriptionsFound">
|
||||
<source>No subscriptions were found for the currently logged in user account.</source>
|
||||
<target state="new">No subscriptions were found for the currently logged in user account.</target>
|
||||
<note></note>
|
||||
</trans-unit>
|
||||
</body>
|
||||
</file>
|
||||
</xliff>
|
||||
Reference in New Issue
Block a user