Skip to content

Commit

Permalink
Merge branch 'develop'
Browse files Browse the repository at this point in the history
  • Loading branch information
jamie-mh committed Feb 27, 2024
2 parents 4526bcd + 50ed74c commit 4927b76
Show file tree
Hide file tree
Showing 9 changed files with 83 additions and 55 deletions.
12 changes: 10 additions & 2 deletions AuthenticatorPro.Core/src/Converter/TwoFasBackupConverter.cs
Original file line number Diff line number Diff line change
Expand Up @@ -194,13 +194,21 @@ public Authenticator Convert(IIconResolver iconResolver)
username = Otp.Account;
}

var digits = Otp.Digits > 0
? Otp.Digits
: type.GetDefaultDigits();

var period = Otp.Period > 0
? Otp.Period
: type.GetDefaultPeriod();

return new Authenticator
{
Secret = SecretUtil.Clean(Secret, type),
Issuer = issuer.Truncate(Authenticator.IssuerMaxLength),
Username = username.Truncate(Authenticator.UsernameMaxLength),
Digits = Otp.Digits,
Period = Otp.Period,
Digits = digits,
Period = period,
Counter = Otp.Counter,
Type = type,
Algorithm = algorithm,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@ namespace AuthenticatorPro.Core.Persistence
{
public interface IIconPackEntryRepository : IAsyncRepository<IconPackEntry, ValueTuple<string, string>>
{
public Task CreateManyAsync(List<IconPackEntry> items);
public Task<List<IconPackEntry>> GetAllForPackAsync(IconPack pack);
public Task DeleteAllForPackAsync(IconPack pack);
}
Expand Down
7 changes: 4 additions & 3 deletions AuthenticatorPro.Core/src/Service/Impl/IconPackService.cs
Original file line number Diff line number Diff line change
Expand Up @@ -40,11 +40,12 @@ public async Task ImportPackAsync(IconPack pack)
await _iconPackEntryRepository.DeleteAllForPackAsync(pack);
}

await Parallel.ForEachAsync(pack.Icons, async (entry, _) =>
foreach (var entry in pack.Icons)
{
entry.IconPackName = pack.Name;
await _iconPackEntryRepository.CreateAsync(entry);
});
}

await _iconPackEntryRepository.CreateManyAsync(pack.Icons);
}

public async Task DeletePackAsync(IconPack pack)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@
<PrivateAssets>all</PrivateAssets>
</PackageReference>
<PackageReference Include="Newtonsoft.Json" Version="13.0.3"/>
<PackageReference Include="Xamarin.AndroidX.Preference" Version="1.2.1.3" />
<PackageReference Include="Xamarin.AndroidX.Preference" Version="1.2.1.4" />
</ItemGroup>
<ItemGroup>
<ProjectReference Include="..\AuthenticatorPro.Core\AuthenticatorPro.Core.csproj"/>
Expand Down
50 changes: 25 additions & 25 deletions AuthenticatorPro.Droid/AuthenticatorPro.Droid.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -27,49 +27,49 @@
<PackageReference Include="Microsoft.CodeAnalysis.NetAnalyzers" Version="8.0.0">
<PrivateAssets>all</PrivateAssets>
</PackageReference>
<PackageReference Include="Mono.AotProfiler.Android" Version="7.0.0"/>
<PackageReference Include="Newtonsoft.Json" Version="13.0.3"/>
<PackageReference Include="Mono.AotProfiler.Android" Version="7.0.0" />
<PackageReference Include="Newtonsoft.Json" Version="13.0.3" />
<PackageReference Include="Serilog" Version="3.1.1" />
<PackageReference Include="Serilog.Exceptions" Version="8.4.0" />
<PackageReference Include="Serilog.Sinks.File" Version="5.0.0" />
<PackageReference Include="sqlite-net-sqlcipher" Version="1.8.116"/>
<PackageReference Include="SQLitePCLRaw.bundle_e_sqlcipher" Version="2.1.7" />
<PackageReference Include="sqlite-net-sqlcipher" Version="1.8.116" />
<PackageReference Include="SQLitePCLRaw.bundle_e_sqlcipher" Version="2.1.8" />
<PackageReference Include="TinyIoC" Version="1.4.0-rc1">
<PrivateAssets>all</PrivateAssets>
</PackageReference>
<PackageReference Include="Xamarin.AndroidX.Biometric" Version="1.1.0.18" />
<PackageReference Include="Xamarin.AndroidX.Browser" Version="1.7.0.1" />
<PackageReference Include="Xamarin.AndroidX.Camera.Camera2" Version="1.3.1" />
<PackageReference Include="Xamarin.AndroidX.Camera.Core" Version="1.3.1" />
<PackageReference Include="Xamarin.AndroidX.Camera.View" Version="1.3.1" />
<PackageReference Include="Xamarin.AndroidX.ConstraintLayout" Version="2.1.4.9" />
<PackageReference Include="Xamarin.AndroidX.Lifecycle.Common" Version="2.6.2.3" />
<PackageReference Include="Xamarin.AndroidX.Lifecycle.Extensions" Version="2.2.0.22" />
<PackageReference Include="Xamarin.AndroidX.Lifecycle.LiveData" Version="2.6.2.3" />
<PackageReference Include="Xamarin.AndroidX.Lifecycle.Runtime" Version="2.6.2.3" />
<PackageReference Include="Xamarin.AndroidX.Preference" Version="1.2.1.3" />
<PackageReference Include="Xamarin.AndroidX.ViewPager2" Version="1.0.0.24" />
<PackageReference Include="Xamarin.AndroidX.Work.Runtime" Version="2.9.0" />
<PackageReference Include="Xamarin.Google.Android.Material" Version="1.10.0.2" />
<PackageReference Include="ZXing.Net" Version="0.16.9"/>
<PackageReference Include="Xamarin.AndroidX.Biometric" Version="1.1.0.19" />
<PackageReference Include="Xamarin.AndroidX.Browser" Version="1.7.0.2" />
<PackageReference Include="Xamarin.AndroidX.Camera.Camera2" Version="1.3.1.1" />
<PackageReference Include="Xamarin.AndroidX.Camera.Core" Version="1.3.1.1" />
<PackageReference Include="Xamarin.AndroidX.Camera.View" Version="1.3.1.1" />
<PackageReference Include="Xamarin.AndroidX.ConstraintLayout" Version="2.1.4.10" />
<PackageReference Include="Xamarin.AndroidX.Lifecycle.Common" Version="2.7.0.1" />
<PackageReference Include="Xamarin.AndroidX.Lifecycle.Extensions" Version="2.2.0.23" />
<PackageReference Include="Xamarin.AndroidX.Lifecycle.LiveData" Version="2.7.0.1" />
<PackageReference Include="Xamarin.AndroidX.Lifecycle.Runtime" Version="2.7.0.1" />
<PackageReference Include="Xamarin.AndroidX.Preference" Version="1.2.1.4" />
<PackageReference Include="Xamarin.AndroidX.ViewPager2" Version="1.0.0.25" />
<PackageReference Include="Xamarin.AndroidX.Work.Runtime" Version="2.9.0.1" />
<PackageReference Include="Xamarin.Google.Android.Material" Version="1.10.0.3" />
<PackageReference Include="ZXing.Net" Version="0.16.9" />
</ItemGroup>
<ItemGroup Condition="!$(DefineConstants.Contains(FDROID))">
<PackageReference Include="Xamarin.GooglePlayServices.Wearable" Version="118.1.0.2" />
</ItemGroup>
<ItemGroup Condition="$(DefineConstants.Contains(FDROID))">
<AndroidResource Remove="Resources\values\wear.xml"/>
<AndroidResource Remove="Resources\values\wear.xml" />
</ItemGroup>
<ItemGroup>
<ProjectReference Include="..\AuthenticatorPro.Droid.Shared\AuthenticatorPro.Droid.Shared.csproj"/>
<ProjectReference Include="..\AuthenticatorPro.Core\AuthenticatorPro.Core.csproj"/>
<ProjectReference Include="..\AuthenticatorPro.Droid.Shared\AuthenticatorPro.Droid.Shared.csproj" />
<ProjectReference Include="..\AuthenticatorPro.Core\AuthenticatorPro.Core.csproj" />
</ItemGroup>
<ItemGroup>
<AndroidAotProfile Include="custom.aprof"/>
<AndroidAotProfile Include="custom.aprof" />
</ItemGroup>
<ItemGroup>
<ProguardConfiguration Include="proguard.cfg"/>
<ProguardConfiguration Include="proguard.cfg" />
</ItemGroup>
<ItemGroup>
<LinkDescription Include="trim.xml"/>
<LinkDescription Include="trim.xml" />
</ItemGroup>
</Project>
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,12 @@ public async Task CreateAsync(IconPackEntry item)
await conn.InsertAsync(item);
}

public async Task CreateManyAsync(List<IconPackEntry> items)
{
var conn = await _database.GetConnectionAsync();
await conn.InsertAllAsync(items);
}

public async Task<IconPackEntry> GetAsync(ValueTuple<string, string> id)
{
var conn = await _database.GetConnectionAsync();
Expand Down
10 changes: 5 additions & 5 deletions AuthenticatorPro.Test/AuthenticatorPro.Test.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -7,18 +7,18 @@
<LangVersion>12</LangVersion>
</PropertyGroup>
<ItemGroup>
<PackageReference Include="coverlet.collector" Version="6.0.0">
<PackageReference Include="coverlet.collector" Version="6.0.1">
<PrivateAssets>all</PrivateAssets>
<IncludeAssets>runtime; build; native; contentfiles; analyzers; buildtransitive</IncludeAssets>
</PackageReference>
<PackageReference Include="HtmlAgilityPack" Version="1.11.57" />
<PackageReference Include="HtmlAgilityPack" Version="1.11.59" />
<PackageReference Include="Microsoft.CodeAnalysis.NetAnalyzers" Version="8.0.0">
<PrivateAssets>all</PrivateAssets>
</PackageReference>
<PackageReference Include="Microsoft.NET.Test.Sdk" Version="17.8.0" />
<PackageReference Include="Microsoft.NET.Test.Sdk" Version="17.9.0" />
<PackageReference Include="Moq" Version="4.20.70" />
<PackageReference Include="xunit" Version="2.6.6" />
<PackageReference Include="xunit.runner.visualstudio" Version="2.5.6">
<PackageReference Include="xunit" Version="2.7.0" />
<PackageReference Include="xunit.runner.visualstudio" Version="2.5.7">
<PrivateAssets>all</PrivateAssets>
</PackageReference>
<PackageReference Include="ZXing.Net" Version="0.16.9"/>
Expand Down
24 changes: 18 additions & 6 deletions AuthenticatorPro.Test/src/Service/IconPackServiceTest.cs
Original file line number Diff line number Diff line change
Expand Up @@ -51,14 +51,20 @@ public async Task ImportPackAsync_doesntExist()
_iconPackRepository.Setup(r => r.GetAsync(pack.Name)).ReturnsAsync((IconPack) null);
_iconPackRepository.Setup(r => r.CreateAsync(pack)).Verifiable();

var match = new CaptureMatch<IconPackEntry>(e => { Assert.Equal(pack.Name, e.IconPackName); });
var match = new CaptureMatch<List<IconPackEntry>>(e =>
{
foreach (var item in e)
{
Assert.Equal(pack.Name, item.IconPackName);
}
});

_iconPackEntryRepository.Setup(r => r.CreateAsync(Capture.With(match)));
_iconPackEntryRepository.Setup(r => r.CreateManyAsync(Capture.With(match)));

await _iconPackService.ImportPackAsync(pack);

_iconPackRepository.Verify(r => r.CreateAsync(pack), Times.Once());
_iconPackEntryRepository.Verify(r => r.CreateAsync(It.IsAny<IconPackEntry>()), Times.Once());
_iconPackEntryRepository.Verify(r => r.CreateManyAsync(It.IsAny<List<IconPackEntry>>()), Times.Once());
}

[Fact]
Expand All @@ -75,15 +81,21 @@ public async Task ImportPackAsync_exists()

_iconPackEntryRepository.Setup(r => r.DeleteAllForPackAsync(pack)).Verifiable();

var match = new CaptureMatch<IconPackEntry>(e => { Assert.Equal(pack.Name, e.IconPackName); });
var match = new CaptureMatch<List<IconPackEntry>>(e =>
{
foreach (var item in e)
{
Assert.Equal(pack.Name, item.IconPackName);
}
});

_iconPackEntryRepository.Setup(r => r.CreateAsync(Capture.With(match)));
_iconPackEntryRepository.Setup(r => r.CreateManyAsync(Capture.With(match)));

await _iconPackService.ImportPackAsync(pack);

_iconPackRepository.Verify(r => r.UpdateAsync(pack), Times.Once());
_iconPackEntryRepository.Verify(r => r.DeleteAllForPackAsync(pack), Times.Once());
_iconPackEntryRepository.Verify(r => r.CreateAsync(It.IsAny<IconPackEntry>()), Times.Exactly(2));
_iconPackEntryRepository.Verify(r => r.CreateManyAsync(It.IsAny<List<IconPackEntry>>()), Times.Once());
}

[Fact]
Expand Down
26 changes: 13 additions & 13 deletions AuthenticatorPro.WearOS/AuthenticatorPro.WearOS.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -29,27 +29,27 @@
<PackageReference Include="Microsoft.CodeAnalysis.NetAnalyzers" Version="8.0.0">
<PrivateAssets>all</PrivateAssets>
</PackageReference>
<PackageReference Include="Mono.AotProfiler.Android" Version="7.0.0"/>
<PackageReference Include="Newtonsoft.Json" Version="13.0.3"/>
<PackageReference Include="Xamarin.AndroidX.Core.SplashScreen" Version="1.0.1.5" />
<PackageReference Include="Xamarin.AndroidX.Lifecycle.LiveData" Version="2.6.2.3" />
<PackageReference Include="Xamarin.AndroidX.Wear" Version="1.3.0.3" />
<PackageReference Include="Xamarin.AndroidX.Wear.Tiles" Version="1.2.0.2" />
<PackageReference Include="Xamarin.AndroidX.Wear.Tiles.Material" Version="1.2.0.2" />
<PackageReference Include="Xamarin.Google.Android.Material" Version="1.10.0.2" />
<PackageReference Include="Mono.AotProfiler.Android" Version="7.0.0" />
<PackageReference Include="Newtonsoft.Json" Version="13.0.3" />
<PackageReference Include="Xamarin.AndroidX.Core.SplashScreen" Version="1.0.1.6" />
<PackageReference Include="Xamarin.AndroidX.Lifecycle.LiveData" Version="2.7.0.1" />
<PackageReference Include="Xamarin.AndroidX.Wear" Version="1.3.0.4" />
<PackageReference Include="Xamarin.AndroidX.Wear.Tiles" Version="1.3.0.1" />
<PackageReference Include="Xamarin.AndroidX.Wear.Tiles.Material" Version="1.3.0.1" />
<PackageReference Include="Xamarin.Google.Android.Material" Version="1.10.0.3" />
<PackageReference Include="Xamarin.GooglePlayServices.Wearable" Version="118.1.0.2" />
</ItemGroup>
<ItemGroup>
<ProjectReference Include="..\AuthenticatorPro.Droid.Shared\AuthenticatorPro.Droid.Shared.csproj"/>
<ProjectReference Include="..\AuthenticatorPro.Core\AuthenticatorPro.Core.csproj"/>
<ProjectReference Include="..\AuthenticatorPro.Droid.Shared\AuthenticatorPro.Droid.Shared.csproj" />
<ProjectReference Include="..\AuthenticatorPro.Core\AuthenticatorPro.Core.csproj" />
</ItemGroup>
<ItemGroup>
<AndroidAotProfile Include="custom.aprof"/>
<AndroidAotProfile Include="custom.aprof" />
</ItemGroup>
<ItemGroup>
<ProguardConfiguration Include="proguard.cfg"/>
<ProguardConfiguration Include="proguard.cfg" />
</ItemGroup>
<ItemGroup>
<LinkDescription Include="trim.xml"/>
<LinkDescription Include="trim.xml" />
</ItemGroup>
</Project>

0 comments on commit 4927b76

Please sign in to comment.