Skip to content

Commit 5630cca

Browse files
authored
Merge pull request #4 from shugaoye/master
Built for 1.2.2
2 parents b72e22a + 4065e3f commit 5630cca

14 files changed

+220
-55
lines changed

KPCLib.nuspec

Lines changed: 17 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -2,23 +2,26 @@
22
<package xmlns="http://schemas.microsoft.com/packaging/2010/07/nuspec.xsd">
33
<metadata>
44
<id>KPCLib</id>
5-
<version>0.1.0</version>
5+
<version>1.2.2</version>
66
<authors>Roger Ye</authors>
7-
<description>.NET Standard Library for KeePass</description>
7+
<owners>Roger Ye</owners>
8+
<requireLicenseAcceptance>false</requireLicenseAcceptance>
9+
<licenseUrl>https://github.com/passxyz/KPCLib/blob/master/LICENSE</licenseUrl>
10+
<projectUrl>https://github.com/passxyz/KPCLib</projectUrl>
11+
<description>This is the build of KeePassLib in Xamarin Portable Class Library. Three platforms, UWP, Android and iOS, are supported and tested.</description>
12+
<releaseNotes>-Support Markdown in Notes field
13+
- Support PassXYZ data format</releaseNotes>
14+
<copyright>Dominik Reichl is the author of the original KeePassLib on Windows platform. Roger Ye created this for UWP, Android and iOS platforms.</copyright>
15+
<repository url="https://github.com/passxyz/KPCLib" />
16+
<dependencies>
17+
<group targetFramework=".NETStandard2.0">
18+
<dependency id="SkiaSharp" version="1.68.0" exclude="Build,Analyzers" />
19+
</group>
20+
</dependencies>
821
<summary>A library to be built as .NET Standard Library to be used for Android, iOS and UWP</summary>
922
</metadata>
1023
<files>
11-
<!-- Android -->
12-
<!-- file src="KPCLib/bin/Release/MonoAndroid403/KPCLib.dll" target="lib/MonoAndroid403/KPCLib.dll" /-->
13-
<!-- iOS Unified API -->
14-
<!-- file src="KPCLib/bin/Release/Xamarin.iOS10/KPCLib.dll" target="lib/Xamarin.iOS10/KPCLib.dll" /-->
15-
<!-- Mac Mobile Unified API -->
16-
<!-- file src="KPCLib/bin/Release/Xamarin.Mac20/KPCLib.dll" target="lib/Xamarin.Mac20/KPCLib.dll" /-->
17-
<!-- Windows Universal -->
18-
<!--<file src="bin/Release/UAP10.0/KPCLib.dll" target="lib/UAP10/KPCLib.dll" />-->
19-
<!-- .NET 4.5 -->
20-
<!-- file src="KPCLib/bin/Release/Net45/KPCLib.dll" target="lib/Net45/KPCLib.dll" /-->
21-
<!-- Portable PCL -->
22-
<file src="KPCLib/bin/Release/netstandard2.0/KPCLib.dll" target="lib/netstandard2.0/KPCLib.dll" />
24+
<file src="PassXYZLib/bin/Release/netstandard2.0/KPCLib.dll" target="lib/netstandard2.0/KPCLib.dll" />
25+
<file src="PassXYZLib/bin/Release/netstandard2.0/PassXYZLib.dll" target="lib/netstandard2.0/PassXYZLib.dll" />
2326
</files>
2427
</package>

KPCLib.sln

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@ Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "KPCLib", "KPCLib\KPCLib.csp
77
EndProject
88
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "KPCLib.xunit", "KPCLib.xunit\KPCLib.xunit.csproj", "{4764BB09-267A-4760-AE2D-6979BDA5FB88}"
99
EndProject
10-
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "PassXYZLib", "PassXYZLib\PassXYZLib.csproj", "{E6F6B65A-6474-4978-9F9C-F22194688240}"
10+
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "PassXYZLib", "PassXYZLib\PassXYZLib.csproj", "{E6F6B65A-6474-4978-9F9C-F22194688240}"
1111
EndProject
1212
Global
1313
GlobalSection(SolutionConfigurationPlatforms) = preSolution

KPCLib.xunit/DeviceLockTests.cs

Lines changed: 112 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,112 @@
1+
using System;
2+
using System.Collections.Generic;
3+
using System.Diagnostics;
4+
using System.Text;
5+
6+
using Xunit;
7+
using KeePassLib;
8+
using KeePassLib.Keys;
9+
using KeePassLib.Security;
10+
using KeePassLib.Serialization;
11+
using KeePassLib.Utility;
12+
using PassXYZLib;
13+
//using PassXYZ.Services;
14+
15+
namespace KPCLib.xunit
16+
{
17+
public class DeviceLockFixture : IDisposable
18+
{
19+
const string TEST_DB = "pass_e_JyHzpRxcopt.xyz";
20+
const string TEST_DB_KEY = "123123";
21+
22+
public DeviceLockFixture()
23+
{
24+
PxDb = new PassXYZLib.PxDatabase();
25+
PxDatabase.DefaultFolder = "../../..";
26+
PxDb.Open(TEST_DB, TEST_DB_KEY);
27+
}
28+
29+
public void Dispose()
30+
{
31+
PxDb.Close();
32+
}
33+
34+
public PassXYZLib.PxDatabase PxDb { get; private set; }
35+
36+
public string Username
37+
{
38+
get { return PxDefs.GetUserNameFromDataFile(TEST_DB); }
39+
}
40+
}
41+
42+
[CollectionDefinition("DeviceLock collection")]
43+
public class DeviceLockCollection : ICollectionFixture<DeviceLockFixture>
44+
{
45+
// This class has no code, and is never created. Its purpose is simply
46+
// to be the place to apply [CollectionDefinition] and all the
47+
// ICollectionFixture<> interfaces.
48+
}
49+
50+
[Collection("DeviceLock collection")]
51+
public class DeviceLockTests
52+
{
53+
DeviceLockFixture passxyz;
54+
55+
public DeviceLockTests(DeviceLockFixture deviceLockFixture)
56+
{
57+
this.passxyz = deviceLockFixture;
58+
}
59+
60+
[Fact]
61+
public void IsOpenDbTest()
62+
{
63+
Debug.WriteLine($"{passxyz.PxDb}, Username is {passxyz.Username}.");
64+
Assert.True((passxyz.PxDb.IsOpen));
65+
}
66+
67+
[Fact]
68+
public void CurrentGroupTests()
69+
{
70+
var currentGroup = passxyz.PxDb.CurrentGroup;
71+
Debug.WriteLine($"{currentGroup}");
72+
Assert.NotNull(currentGroup);
73+
}
74+
75+
[Fact]
76+
public void CurrentPathTests()
77+
{
78+
var currentPath = passxyz.PxDb.CurrentPath;
79+
Debug.WriteLine($"Current path is {currentPath}.");
80+
Assert.NotNull(currentPath);
81+
}
82+
83+
[Theory]
84+
[InlineData("/test1/WebDAV")]
85+
/// <summary>
86+
/// Change a protect field
87+
/// </summary>
88+
/// <param name="path">Destination path. Must not be <c>null</c>.</param>
89+
public void ChangeProtectedFieldTests(string path)
90+
{
91+
var entry = passxyz.PxDb.FindByPath<PwEntry>(path);
92+
93+
Debug.WriteLine($"Current path is {entry}.");
94+
// Update the existing protected field
95+
PxDefs.UpdatePxEntry(entry, PxDefs.PasswordField, "123456", true);
96+
Assert.True(entry.Strings.Get(PxDefs.FindEncodeKey(entry.Strings, PxDefs.PasswordField)).IsProtected);
97+
// Add a new protected field "PIN"
98+
PxDefs.UpdatePxEntry(entry, "PIN", "1234", true);
99+
Assert.True(entry.Strings.Get(PxDefs.FindEncodeKey(entry.Strings, "PIN")).IsProtected);
100+
// Remove a field
101+
PxDefs.UpdatePxEntry(entry, "002Email", String.Empty, false);
102+
foreach (KeyValuePair<string, ProtectedString> kvp in entry.Strings)
103+
{
104+
Debug.WriteLine($" {kvp.Key}={kvp.Value.ReadString()}, IsProtected={kvp.Value.IsProtected}");
105+
}
106+
107+
}
108+
109+
// The end of DeviceLockTests
110+
}
111+
112+
}

KPCLib.xunit/KPCLib.xunit.csproj

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -25,6 +25,8 @@
2525
<ItemGroup>
2626
<DataFiles Include="$(ProjectDir)\utdb.kdbx" />
2727
<DataFiles Include="$(ProjectDir)\pass_d_E8f4pEk.xyz" />
28+
<DataFiles Include="$(ProjectDir)\pass_e_JyHzpRxcopt.xyz" />
29+
<DataFiles Include="$(ProjectDir)\pass_k_JyHzpRxcopt.k4xyz" />
2830
</ItemGroup>
2931

3032
<Copy SourceFiles="@(DataFiles)" DestinationFolder="$(TargetDir)\" SkipUnchangedFiles="true" />

KPCLib.xunit/PassXYZLibTests.cs

Lines changed: 1 addition & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -20,12 +20,8 @@ public class PassXYZLibFixture : IDisposable
2020

2121
public PassXYZLibFixture()
2222
{
23-
Logger = new KPCLibLogger();
2423
PxDb = new PxDatabase();
25-
IOConnectionInfo ioc = IOConnectionInfo.FromPath(TEST_DB);
26-
CompositeKey cmpKey = new CompositeKey();
27-
cmpKey.AddUserKey(new KcpPassword(TEST_DB_KEY));
28-
PxDb.Open(ioc, cmpKey, Logger);
24+
PxDb.Open(TEST_DB, TEST_DB_KEY);
2925
}
3026

3127
public void Dispose()

KPCLib.xunit/PwDatabaseTests.cs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,7 @@
88
using KeePassLib.Keys;
99
using KeePassLib.Serialization;
1010
using KeePassLib.Utility;
11+
using PassXYZLib;
1112

1213
namespace KPCLib.xunit
1314
{

KPCLib.xunit/PxDatabaseTests.cs

Lines changed: 1 addition & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -19,12 +19,8 @@ public class PxDatabaseFixture : IDisposable
1919

2020
public PxDatabaseFixture()
2121
{
22-
Logger = new KPCLibLogger();
2322
PxDb = new PxDatabase();
24-
IOConnectionInfo ioc = IOConnectionInfo.FromPath(TEST_DB);
25-
CompositeKey cmpKey = new CompositeKey();
26-
cmpKey.AddUserKey(new KcpPassword(TEST_DB_KEY));
27-
PxDb.Open(ioc, cmpKey, Logger);
23+
PxDb.Open(TEST_DB, TEST_DB_KEY);
2824
}
2925

3026
public void Dispose()
4.58 KB
Binary file not shown.
1.47 KB
Binary file not shown.

KPCLib/KPCLib.csproj

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -6,24 +6,25 @@
66
<OutputType>Library</OutputType>
77
<StartupObject />
88
<GeneratePackageOnBuild>true</GeneratePackageOnBuild>
9-
<Version>1.2.1</Version>
9+
<Version>1.2.2</Version>
1010
<PackageLicenseUrl>https://github.com/passxyz/KPCLib/blob/master/LICENSE</PackageLicenseUrl>
1111
<PackageProjectUrl>https://github.com/passxyz/KPCLib</PackageProjectUrl>
1212
<RepositoryUrl>https://github.com/passxyz/KPCLib</RepositoryUrl>
1313
<Description>This is the build of KeePassLib in Xamarin Portable Class Library. Three platforms, UWP, Android and iOS, are supported and tested.</Description>
1414
<Copyright>Dominik Reichl is the author of the original KeePassLib on Windows platform. Roger Ye created this for UWP, Android and iOS platforms.</Copyright>
1515
<Authors>Roger Ye</Authors>
1616
<Company>PassXYZ Inc.</Company>
17-
<PackageReleaseNotes>1.2.0 - Enhanced KeePassLib
17+
<PackageReleaseNotes>1.2.2 - Release PassXYZLib
18+
1.2.0 - Enhanced KeePassLib
1819
1.1.9 - Removed dependency Xamarin.Forms
1920
1.1.8 - Replaced Splat with SkiaSharp.
2021

2122
1.1.7 - Removed code refering to KeePassLibC32.dll.
2223

2324
1.1.6 - KPCLib has been tested on all three platforms (Android, iOS and UWP).</PackageReleaseNotes>
2425
<NeutralLanguage>en-US</NeutralLanguage>
25-
<AssemblyVersion>1.2.1.0</AssemblyVersion>
26-
<FileVersion>1.2.1.0</FileVersion>
26+
<AssemblyVersion>1.2.2.2</AssemblyVersion>
27+
<FileVersion>1.2.2.2</FileVersion>
2728
</PropertyGroup>
2829

2930
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|AnyCPU'">

0 commit comments

Comments
 (0)