Skip to content

Commit d36f8bc

Browse files
committed
Version 6.1.2
1 parent 9c023f2 commit d36f8bc

File tree

5 files changed

+36
-10
lines changed

5 files changed

+36
-10
lines changed

ReleaseNotes.md

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,12 @@
11
# Release notes
22

3+
## 6.0.2
4+
5+
- Fixed error in FasterPostgreSqlEnsureClean - needed password injected
6+
7+
## 6.0.1
8+
9+
- Microsoft.Data.SqlClient vulnerable update
310

411
## 6.0.0
512

Test/appsettings.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
{
22
"ConnectionStrings": {
33
"UnitTestConnection": "Server=(localdb)\\mssqllocaldb;Database=EfCore.TestSupport-Test;Trusted_Connection=True;MultipleActiveResultSets=true",
4-
"PostgreSqlConnection": "host=127.0.0.1;Database=Test-Test;Username=postgres;Password=LetMeIn",
4+
"PostgreSqlConnection": "Host=127.0.0.1;Port=5432;Database=Test-Test;Username=postgres;Password=LetMeIn",
55
"BookOrderConnection": "Data Source=(localdb)\\mssqllocaldb;Initial Catalog=EfCore.TestSupport-Test_ComparerBooksAndOrders;Integrated Security=True;MultipleActiveResultSets=True"
66
},
77
"MyInt": 1,

TestSupport/EfHelpers/CleanDatabaseExtensions.cs

Lines changed: 11 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,9 +3,13 @@
33
// Licensed under the Apache License, Version 2.0. See License.txt in the project root for license information.
44

55
using System;
6+
using System.Reflection;
67
using Microsoft.EntityFrameworkCore;
78
using Microsoft.EntityFrameworkCore.Infrastructure;
9+
using Microsoft.Extensions.Configuration;
10+
using Npgsql;
811
using TestSupport.EfHelpers.Internal;
12+
using TestSupport.Helpers;
913

1014
namespace TestSupport.EfHelpers
1115
{
@@ -28,8 +32,14 @@ public static void EnsureClean(this DatabaseFacade databaseFacade, bool setUpSch
2832
databaseFacade.CreateExecutionStrategy()
2933
.Execute(databaseFacade, database => new SqlServerDatabaseCleaner(databaseFacade).Clean(database, setUpSchema));
3034
else if (databaseFacade.IsNpgsql())
35+
{
3136
//PostgreSQL
32-
databaseFacade.FasterPostgreSqlEnsureClean(setUpSchema);
37+
38+
//The databaseFacade doesn't have the Password, so we need to get it from the connection string in the appsettings.json file
39+
var config = AppSettings.GetConfiguration(Assembly.GetCallingAssembly());
40+
var password = new NpgsqlConnectionStringBuilder(config.GetConnectionString(AppSettings.PostgreSqlConnectionString)).Password;
41+
databaseFacade.FasterPostgreSqlEnsureClean(password, setUpSchema);
42+
}
3343
else
3444
throw new InvalidOperationException("The EnsureClean method only works with SQL Server or PostgreSQL databases.");
3545
}

TestSupport/EfHelpers/Internal/PostgreSqlDropSchemaEnsureClean.cs

Lines changed: 12 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,8 @@
1-
using Microsoft.EntityFrameworkCore;
1+
using System.Reflection;
2+
using Microsoft.EntityFrameworkCore;
23
using Microsoft.EntityFrameworkCore.Infrastructure;
34
using Npgsql;
5+
using TestSupport.Helpers;
46

57
namespace TestSupport.EfHelpers.Internal
68
{
@@ -12,10 +14,16 @@ internal static class PostgreSqlDropSchemaEnsureClean
1214
/// The SQL in this method was provided by Shay Rojansky, github @roji
1315
/// </summary>
1416
/// <param name="databaseFacade"></param>
17+
/// <param name="password"></param>
1518
/// <param name="setUpSchema"></param>
16-
public static void FasterPostgreSqlEnsureClean(this DatabaseFacade databaseFacade, bool setUpSchema = true)
19+
public static void FasterPostgreSqlEnsureClean(this DatabaseFacade databaseFacade, string password, bool setUpSchema = true)
1720
{
18-
var connectionString = databaseFacade.GetDbConnection().ConnectionString;
21+
var builder = new NpgsqlConnectionStringBuilder(databaseFacade.GetDbConnection().ConnectionString)
22+
{
23+
Password = password
24+
};
25+
var connectionString = builder.ToString();
26+
1927
if (connectionString.DatabaseExists())
2028
{
2129
using var conn = new NpgsqlConnection(connectionString);
@@ -24,6 +32,7 @@ public static void FasterPostgreSqlEnsureClean(this DatabaseFacade databaseFacad
2432
var dropPublicSchemaCommand = new NpgsqlCommand
2533
{
2634
Connection = conn,
35+
2736
CommandText = @"
2837
DO $$
2938
DECLARE

TestSupport/TestSupport.csproj

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -60,15 +60,15 @@
6060

6161
<PropertyGroup>
6262
<PackageId>EfCore.TestSupport</PackageId>
63-
<PackageVersion>6.0.1</PackageVersion>
64-
<Version>6.0.1</Version>
65-
<AssemblyVersion>6.0.1.0</AssemblyVersion>
66-
<FileVersion>6.0.1.0</FileVersion>
63+
<PackageVersion>6.0.2</PackageVersion>
64+
<Version>6.0.2</Version>
65+
<AssemblyVersion>6.0.2.0</AssemblyVersion>
66+
<FileVersion>6.0.2.0</FileVersion>
6767
<Authors>Jon P Smith</Authors>
6868
<Description>Useful tools when unit testing applications that use Entity Framework Core. See readme file on github.</Description>
6969
<PackageRequireLicenseAcceptance>false</PackageRequireLicenseAcceptance>
7070
<PackageReleaseNotes>
71-
- Microsoft.Data.SqlClient vulnerable update
71+
- Fixed error in FasterPostgreSqlEnsureClean - needed password injected
7272
</PackageReleaseNotes>
7373
<Copyright>Copyright (c) 2020 Jon P Smith. Licenced under MIT licence</Copyright>
7474
<PackageTags>Entity Framework Core, xUnit</PackageTags>

0 commit comments

Comments
 (0)