Fix invalid dacpac version crashing sqltoolsservice (#789)

* fix invalid dacpac version crashing sqltoolsservice
This commit is contained in:
kisantia
2019-04-03 17:30:10 -07:00
committed by GitHub
parent 49cecaf72a
commit dc5ab60df5
9 changed files with 68 additions and 8 deletions

View File

@@ -132,7 +132,7 @@ CREATE TABLE [dbo].[table3]
DatabaseName = testdb.DatabaseName,
PackageFilePath = Path.Combine(folderPath, string.Format("{0}.dacpac", testdb.DatabaseName)),
ApplicationName = "test",
ApplicationVersion = new Version(1, 0)
ApplicationVersion = "1.0.0.0"
};
DacFxService service = new DacFxService();
@@ -162,7 +162,7 @@ CREATE TABLE [dbo].[table3]
DatabaseName = sourceDb.DatabaseName,
PackageFilePath = Path.Combine(folderPath, string.Format("{0}.dacpac", sourceDb.DatabaseName)),
ApplicationName = "test",
ApplicationVersion = new Version(1, 0)
ApplicationVersion = "1.0.0.0"
};
DacFxService service = new DacFxService();
@@ -233,6 +233,8 @@ CREATE TABLE [dbo].[table3]
return requestContext;
}
private async Task<Mock<RequestContext<DacFxResult>>> SendAndValidateGenerateDeployScriptRequest()
{
// first extract a dacpac
@@ -249,7 +251,7 @@ CREATE TABLE [dbo].[table3]
DatabaseName = sourceDb.DatabaseName,
PackageFilePath = Path.Combine(folderPath, string.Format("{0}.dacpac", sourceDb.DatabaseName)),
ApplicationName = "test",
ApplicationVersion = new Version(1, 0)
ApplicationVersion = "1.0.0.0"
};
DacFxService service = new DacFxService();
@@ -295,7 +297,7 @@ CREATE TABLE [dbo].[table3]
DatabaseName = sourceDb.DatabaseName,
PackageFilePath = Path.Combine(folderPath, string.Format("{0}.dacpac", sourceDb.DatabaseName)),
ApplicationName = "test",
ApplicationVersion = new Version(1, 0)
ApplicationVersion = "1.0.0.0"
};
ExtractOperation extractOperation = new ExtractOperation(extractParams, result.ConnectionInfo);

View File

@@ -369,7 +369,7 @@ CREATE TABLE [dbo].[table3]
DatabaseName = testdb.DatabaseName,
PackageFilePath = Path.Combine(folderPath, string.Format("{0}.dacpac", testdb.DatabaseName)),
ApplicationName = "test",
ApplicationVersion = new Version(1, 0)
ApplicationVersion = "1.0.0.0"
};
DacFxService service = new DacFxService();

View File

@@ -0,0 +1,21 @@
//
// Copyright (c) Microsoft. All rights reserved.
// Licensed under the MIT license. See LICENSE file in the project root for full license information.
//
using System;
using Microsoft.SqlTools.ServiceLayer.DacFx;
using Xunit;
namespace Microsoft.SqlTools.ServiceLayer.UnitTests.DacFx
{
public class DacFxTests
{
[Fact]
public void ExtractParseVersionShouldThrowExceptionGivenInvalidVersion()
{
string invalidVersion = "invalidVerison";
Assert.Throws<ArgumentException>(() => ExtractOperation.ParseVersion(invalidVersion));
}
}
}