mirror of
https://github.com/bitwarden/mobile
synced 2026-02-17 09:59:02 +00:00
reset for v2
This commit is contained in:
@@ -1,100 +0,0 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<Project ToolsVersion="14.0" DefaultTargets="Build" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
|
||||
<PropertyGroup>
|
||||
<Configuration Condition=" '$(Configuration)' == '' ">Debug</Configuration>
|
||||
<Platform Condition=" '$(Platform)' == '' ">AnyCPU</Platform>
|
||||
<ProjectGuid>{A300DCE1-8D10-4267-B96A-CB01AEB7C220}</ProjectGuid>
|
||||
<OutputType>Library</OutputType>
|
||||
<AppDesignerFolder>Properties</AppDesignerFolder>
|
||||
<RootNamespace>Bit.App.Test</RootNamespace>
|
||||
<AssemblyName>Bit.App.Test</AssemblyName>
|
||||
<TargetFrameworkVersion>v4.7.1</TargetFrameworkVersion>
|
||||
<FileAlignment>512</FileAlignment>
|
||||
<ProjectTypeGuids>{3AC096D0-A1C2-E12C-1390-A8335801FDAB};{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}</ProjectTypeGuids>
|
||||
<VisualStudioVersion Condition="'$(VisualStudioVersion)' == ''">10.0</VisualStudioVersion>
|
||||
<VSToolsPath Condition="'$(VSToolsPath)' == ''">$(MSBuildExtensionsPath32)\Microsoft\VisualStudio\v$(VisualStudioVersion)</VSToolsPath>
|
||||
<ReferencePath>$(ProgramFiles)\Common Files\microsoft shared\VSTT\$(VisualStudioVersion)\UITestExtensionPackages</ReferencePath>
|
||||
<IsCodedUITest>False</IsCodedUITest>
|
||||
<TestProjectType>UnitTest</TestProjectType>
|
||||
<NuGetPackageImportStamp>
|
||||
</NuGetPackageImportStamp>
|
||||
<TargetFrameworkProfile />
|
||||
</PropertyGroup>
|
||||
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Debug|AnyCPU' ">
|
||||
<DebugSymbols>true</DebugSymbols>
|
||||
<DebugType>full</DebugType>
|
||||
<Optimize>false</Optimize>
|
||||
<OutputPath>bin\Debug\</OutputPath>
|
||||
<DefineConstants>DEBUG;TRACE</DefineConstants>
|
||||
<ErrorReport>prompt</ErrorReport>
|
||||
<WarningLevel>4</WarningLevel>
|
||||
</PropertyGroup>
|
||||
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Release|AnyCPU' ">
|
||||
<DebugType>pdbonly</DebugType>
|
||||
<Optimize>true</Optimize>
|
||||
<OutputPath>bin\Release\</OutputPath>
|
||||
<DefineConstants>TRACE</DefineConstants>
|
||||
<ErrorReport>prompt</ErrorReport>
|
||||
<WarningLevel>4</WarningLevel>
|
||||
</PropertyGroup>
|
||||
<ItemGroup>
|
||||
<Reference Include="System" />
|
||||
</ItemGroup>
|
||||
<Choose>
|
||||
<When Condition="('$(VisualStudioVersion)' == '10.0' or '$(VisualStudioVersion)' == '') and '$(TargetFrameworkVersion)' == 'v3.5'">
|
||||
<ItemGroup>
|
||||
<Reference Include="Microsoft.VisualStudio.QualityTools.UnitTestFramework, Version=10.1.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a, processorArchitecture=MSIL" />
|
||||
</ItemGroup>
|
||||
</When>
|
||||
<Otherwise />
|
||||
</Choose>
|
||||
<ItemGroup>
|
||||
<Compile Include="PasswordGeneratorServiceTests.cs" />
|
||||
<Compile Include="CryptoServiceTests.cs" />
|
||||
<Compile Include="Properties\AssemblyInfo.cs" />
|
||||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
<None Include="app.config">
|
||||
<SubType>Designer</SubType>
|
||||
</None>
|
||||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
<ProjectReference Include="..\..\src\App\App.csproj">
|
||||
<Project>{8a279ee4-4537-4656-9c93-44945e594556}</Project>
|
||||
<Name>App</Name>
|
||||
</ProjectReference>
|
||||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
<PackageReference Include="NSubstitute">
|
||||
<Version>3.1.0</Version>
|
||||
</PackageReference>
|
||||
<PackageReference Include="xunit">
|
||||
<Version>2.4.1</Version>
|
||||
</PackageReference>
|
||||
<PackageReference Include="xunit.runner.console">
|
||||
<Version>2.4.1</Version>
|
||||
<IncludeAssets>runtime; build; native; contentfiles; analyzers</IncludeAssets>
|
||||
<PrivateAssets>all</PrivateAssets>
|
||||
</PackageReference>
|
||||
</ItemGroup>
|
||||
<Choose>
|
||||
<When Condition="'$(VisualStudioVersion)' == '10.0' And '$(IsCodedUITest)' == 'True'">
|
||||
<ItemGroup>
|
||||
<Reference Include="Microsoft.VisualStudio.QualityTools.CodedUITestFramework, Version=10.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a, processorArchitecture=MSIL">
|
||||
<Private>False</Private>
|
||||
</Reference>
|
||||
<Reference Include="Microsoft.VisualStudio.TestTools.UITest.Common, Version=10.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a, processorArchitecture=MSIL">
|
||||
<Private>False</Private>
|
||||
</Reference>
|
||||
<Reference Include="Microsoft.VisualStudio.TestTools.UITest.Extension, Version=10.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a, processorArchitecture=MSIL">
|
||||
<Private>False</Private>
|
||||
</Reference>
|
||||
<Reference Include="Microsoft.VisualStudio.TestTools.UITesting, Version=10.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a, processorArchitecture=MSIL">
|
||||
<Private>False</Private>
|
||||
</Reference>
|
||||
</ItemGroup>
|
||||
</When>
|
||||
</Choose>
|
||||
<Import Project="$(VSToolsPath)\TeamTest\Microsoft.TestTools.targets" Condition="Exists('$(VSToolsPath)\TeamTest\Microsoft.TestTools.targets')" />
|
||||
<Import Project="$(MSBuildToolsPath)\Microsoft.CSharp.targets" />
|
||||
</Project>
|
||||
@@ -1,40 +0,0 @@
|
||||
using System;
|
||||
using Bit.App.Abstractions;
|
||||
using Bit.App.Services;
|
||||
using NSubstitute;
|
||||
using Xunit;
|
||||
using Plugin.Settings.Abstractions;
|
||||
|
||||
namespace Bit.App.Test
|
||||
{
|
||||
public class CryptoServiceTests
|
||||
{
|
||||
[Fact]
|
||||
public void EncryptDecrypt()
|
||||
{
|
||||
var value = "hi";
|
||||
Assert.Equal(EncryptDecryptValue(value), value);
|
||||
}
|
||||
|
||||
[Fact]
|
||||
public void EncryptDecryptLongValue()
|
||||
{
|
||||
var value = "This is a really long value that should encrypt and decrypt just fine too.";
|
||||
Assert.Equal(EncryptDecryptValue(value), value);
|
||||
}
|
||||
|
||||
private string EncryptDecryptValue(string value)
|
||||
{
|
||||
var storageService = Substitute.For<ISecureStorageService>();
|
||||
var keyService = Substitute.For<IKeyDerivationService>();
|
||||
var settingsService = Substitute.For<ISettings>();
|
||||
storageService.Contains("key").Returns(true);
|
||||
storageService.Retrieve("key").Returns(
|
||||
Convert.FromBase64String("QpSYI5k0bLQXEygUEHn4wMII3ERatuWDFBszk7JAhbQ="));
|
||||
|
||||
var service = new CryptoService(settingsService, storageService, keyService);
|
||||
var encryptedValue = service.Encrypt(value);
|
||||
return service.Decrypt(encryptedValue);
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -1,177 +0,0 @@
|
||||
using System;
|
||||
using System.Linq;
|
||||
using Bit.App.Services;
|
||||
using NSubstitute;
|
||||
using Plugin.Settings.Abstractions;
|
||||
using Xunit;
|
||||
|
||||
namespace Bit.App.Test
|
||||
{
|
||||
public class PasswordGeneratorServiceTests
|
||||
{
|
||||
[Fact]
|
||||
public void GeneratesCorrectLength()
|
||||
{
|
||||
var settings = SetupDefaultSettings();
|
||||
settings.GetValueOrDefault(Constants.PasswordGeneratorLength, Arg.Any<int>()).Returns(25);
|
||||
|
||||
var service = new PasswordGenerationService(settings);
|
||||
int i = 0;
|
||||
while(i < 100)
|
||||
{
|
||||
var password = service.GeneratePassword();
|
||||
Assert.True(password.Length == 25);
|
||||
i++;
|
||||
}
|
||||
}
|
||||
|
||||
[Fact]
|
||||
public void GeneratesCorrectMinNumbers()
|
||||
{
|
||||
var settings = SetupDefaultSettings();
|
||||
settings.GetValueOrDefault(Constants.PasswordGeneratorMinNumbers, Arg.Any<int>()).Returns(25);
|
||||
|
||||
var service = new PasswordGenerationService(settings);
|
||||
int i = 0;
|
||||
while(i < 100)
|
||||
{
|
||||
var password = service.GeneratePassword();
|
||||
Assert.True(password.Count(char.IsDigit) >= 25);
|
||||
i++;
|
||||
}
|
||||
}
|
||||
|
||||
[Fact]
|
||||
public void GeneratesCorrectMinSpecial()
|
||||
{
|
||||
var settings = SetupDefaultSettings();
|
||||
settings.GetValueOrDefault(Constants.PasswordGeneratorMinSpecial, Arg.Any<int>()).Returns(25);
|
||||
|
||||
var service = new PasswordGenerationService(settings);
|
||||
int i = 0;
|
||||
while(i < 100)
|
||||
{
|
||||
var password = service.GeneratePassword();
|
||||
Assert.True(password.Count(c => !char.IsLetterOrDigit(c)) >= 25);
|
||||
i++;
|
||||
}
|
||||
}
|
||||
|
||||
[Fact]
|
||||
public void GeneratesCorrectNoUppercase()
|
||||
{
|
||||
var settings = SetupDefaultSettings();
|
||||
settings.GetValueOrDefault(Constants.PasswordGeneratorUppercase, Arg.Any<bool>()).Returns(false);
|
||||
|
||||
var service = new PasswordGenerationService(settings);
|
||||
int i = 0;
|
||||
while(i < 100)
|
||||
{
|
||||
var password = service.GeneratePassword();
|
||||
Assert.True(password.Count(char.IsUpper) == 0);
|
||||
i++;
|
||||
}
|
||||
}
|
||||
|
||||
[Fact]
|
||||
public void GeneratesCorrectUppercase()
|
||||
{
|
||||
var settings = SetupDefaultSettings();
|
||||
settings.GetValueOrDefault(Constants.PasswordGeneratorUppercase, Arg.Any<bool>()).Returns(true);
|
||||
settings.GetValueOrDefault(Constants.PasswordGeneratorLowercase, Arg.Any<bool>()).Returns(false);
|
||||
settings.GetValueOrDefault(Constants.PasswordGeneratorNumbers, Arg.Any<bool>()).Returns(false);
|
||||
settings.GetValueOrDefault(Constants.PasswordGeneratorSpecial, Arg.Any<bool>()).Returns(false);
|
||||
|
||||
var service = new PasswordGenerationService(settings);
|
||||
int i = 0;
|
||||
while(i < 100)
|
||||
{
|
||||
var password = service.GeneratePassword();
|
||||
Assert.True(password.Count(char.IsUpper) == 50);
|
||||
i++;
|
||||
}
|
||||
}
|
||||
|
||||
[Fact]
|
||||
public void GeneratesCorrectNoLowercase()
|
||||
{
|
||||
var settings = SetupDefaultSettings();
|
||||
settings.GetValueOrDefault(Constants.PasswordGeneratorLowercase, Arg.Any<bool>()).Returns(false);
|
||||
|
||||
var service = new PasswordGenerationService(settings);
|
||||
int i = 0;
|
||||
while(i < 100)
|
||||
{
|
||||
var password = service.GeneratePassword();
|
||||
Assert.True(password.Count(char.IsLower) == 0);
|
||||
i++;
|
||||
}
|
||||
}
|
||||
|
||||
[Fact]
|
||||
public void GeneratesCorrectLowercase()
|
||||
{
|
||||
var settings = SetupDefaultSettings();
|
||||
settings.GetValueOrDefault(Constants.PasswordGeneratorUppercase, Arg.Any<bool>()).Returns(false);
|
||||
settings.GetValueOrDefault(Constants.PasswordGeneratorLowercase, Arg.Any<bool>()).Returns(true);
|
||||
settings.GetValueOrDefault(Constants.PasswordGeneratorNumbers, Arg.Any<bool>()).Returns(false);
|
||||
settings.GetValueOrDefault(Constants.PasswordGeneratorSpecial, Arg.Any<bool>()).Returns(false);
|
||||
|
||||
var service = new PasswordGenerationService(settings);
|
||||
int i = 0;
|
||||
while(i < 100)
|
||||
{
|
||||
var password = service.GeneratePassword();
|
||||
Assert.True(password.Count(char.IsLower) == 50);
|
||||
i++;
|
||||
}
|
||||
}
|
||||
|
||||
[Fact]
|
||||
public void GeneratesCorrectMixed()
|
||||
{
|
||||
var settings = SetupDefaultSettings();
|
||||
var service = new PasswordGenerationService(settings);
|
||||
int i = 0;
|
||||
while(i < 100)
|
||||
{
|
||||
var password = service.GeneratePassword();
|
||||
Assert.True(password.Count(char.IsLower) >= 1);
|
||||
Assert.True(password.Count(char.IsDigit) >= 1);
|
||||
Assert.True(password.Count(char.IsUpper) >= 1);
|
||||
Assert.True(password.Count(c => !char.IsLetterOrDigit(c)) >= 1);
|
||||
i++;
|
||||
}
|
||||
}
|
||||
|
||||
[Fact]
|
||||
public void GeneratesCorrectNoAmbiguous()
|
||||
{
|
||||
var settings = SetupDefaultSettings();
|
||||
settings.GetValueOrDefault(Constants.PasswordGeneratorAmbiguous, Arg.Any<bool>()).Returns(false);
|
||||
|
||||
var service = new PasswordGenerationService(settings);
|
||||
int i = 0;
|
||||
while(i < 100)
|
||||
{
|
||||
var password = service.GeneratePassword();
|
||||
Assert.True(!password.Any(c => c == '1' || c == 'l' || c == '0' || c == 'O'));
|
||||
i++;
|
||||
}
|
||||
}
|
||||
|
||||
private ISettings SetupDefaultSettings()
|
||||
{
|
||||
var settings = Substitute.For<ISettings>();
|
||||
settings.GetValueOrDefault(Constants.PasswordGeneratorLength, Arg.Any<int>()).Returns(50);
|
||||
settings.GetValueOrDefault(Constants.PasswordGeneratorMinNumbers, Arg.Any<int>()).Returns(1);
|
||||
settings.GetValueOrDefault(Constants.PasswordGeneratorMinSpecial, Arg.Any<int>()).Returns(1);
|
||||
settings.GetValueOrDefault(Constants.PasswordGeneratorUppercase, Arg.Any<bool>()).Returns(true);
|
||||
settings.GetValueOrDefault(Constants.PasswordGeneratorLowercase, Arg.Any<bool>()).Returns(true);
|
||||
settings.GetValueOrDefault(Constants.PasswordGeneratorSpecial, Arg.Any<bool>()).Returns(true);
|
||||
settings.GetValueOrDefault(Constants.PasswordGeneratorNumbers, Arg.Any<bool>()).Returns(true);
|
||||
settings.GetValueOrDefault(Constants.PasswordGeneratorAmbiguous, Arg.Any<bool>()).Returns(false);
|
||||
return settings;
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -1,36 +0,0 @@
|
||||
using System.Reflection;
|
||||
using System.Runtime.CompilerServices;
|
||||
using System.Runtime.InteropServices;
|
||||
|
||||
// General Information about an assembly is controlled through the following
|
||||
// set of attributes. Change these attribute values to modify the information
|
||||
// associated with an assembly.
|
||||
[assembly: AssemblyTitle("App.Test")]
|
||||
[assembly: AssemblyDescription("")]
|
||||
[assembly: AssemblyConfiguration("")]
|
||||
[assembly: AssemblyCompany("")]
|
||||
[assembly: AssemblyProduct("App.Test")]
|
||||
[assembly: AssemblyCopyright("Copyright © 2016")]
|
||||
[assembly: AssemblyTrademark("")]
|
||||
[assembly: AssemblyCulture("")]
|
||||
|
||||
// Setting ComVisible to false makes the types in this assembly not visible
|
||||
// to COM components. If you need to access a type in this assembly from
|
||||
// COM, set the ComVisible attribute to true on that type.
|
||||
[assembly: ComVisible(false)]
|
||||
|
||||
// The following GUID is for the ID of the typelib if this project is exposed to COM
|
||||
[assembly: Guid("a300dce1-8d10-4267-b96a-cb01aeb7c220")]
|
||||
|
||||
// Version information for an assembly consists of the following four values:
|
||||
//
|
||||
// Major Version
|
||||
// Minor Version
|
||||
// Build Number
|
||||
// Revision
|
||||
//
|
||||
// You can specify all the values or you can default the Build and Revision Numbers
|
||||
// by using the '*' as shown below:
|
||||
// [assembly: AssemblyVersion("1.0.*")]
|
||||
[assembly: AssemblyVersion("1.0.0.0")]
|
||||
[assembly: AssemblyFileVersion("1.0.0.0")]
|
||||
@@ -1,6 +0,0 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<configuration>
|
||||
<startup>
|
||||
<supportedRuntime version="v4.0" sku=".NETFramework,Version=v4.7.1"/>
|
||||
</startup>
|
||||
</configuration>
|
||||
Reference in New Issue
Block a user