mirror of
https://github.com/bitwarden/server.git
synced 2025-02-16 01:51:21 +01:00
Relax nullable in test projects (#5379)
* Relax nullable in test projects * Fix xUnit Warnings * More xUnit fixes
This commit is contained in:
parent
f8b65e0477
commit
af07dffa6f
@ -8,6 +8,11 @@
|
|||||||
<RootNamespace>Bit.$(MSBuildProjectName)</RootNamespace>
|
<RootNamespace>Bit.$(MSBuildProjectName)</RootNamespace>
|
||||||
<ImplicitUsings>enable</ImplicitUsings>
|
<ImplicitUsings>enable</ImplicitUsings>
|
||||||
<IncludeSourceRevisionInInformationalVersion>false</IncludeSourceRevisionInInformationalVersion>
|
<IncludeSourceRevisionInInformationalVersion>false</IncludeSourceRevisionInInformationalVersion>
|
||||||
|
<!-- Treat it as a test project if the project hasn't set their own value and it follows our test project conventions -->
|
||||||
|
<IsTestProject Condition="'$(IsTestProject)' == '' and ($(MSBuildProjectName.EndsWith('.Test')) or $(MSBuildProjectName.EndsWith('.IntegrationTest')))">true</IsTestProject>
|
||||||
|
<Nullable Condition="'$(Nullable)' == '' and '$(IsTestProject)' == 'true'">annotations</Nullable>
|
||||||
|
<!-- Uncomment the below line when we are ready to enable nullable repo wide -->
|
||||||
|
<!-- <Nullable Condition="'$(Nullable)' == '' and '$(IsTestProject)' != 'true'">enable</Nullable> -->
|
||||||
</PropertyGroup>
|
</PropertyGroup>
|
||||||
|
|
||||||
<!--
|
<!--
|
||||||
|
@ -248,7 +248,7 @@ public class GroupsControllerTests : IClassFixture<ScimApplicationFactory>, IAsy
|
|||||||
[InlineData(null)]
|
[InlineData(null)]
|
||||||
[InlineData("")]
|
[InlineData("")]
|
||||||
[InlineData(" ")]
|
[InlineData(" ")]
|
||||||
public async Task Post_InvalidDisplayName_BadRequest(string displayName)
|
public async Task Post_InvalidDisplayName_BadRequest(string? displayName)
|
||||||
{
|
{
|
||||||
var organizationId = ScimApplicationFactory.TestOrganizationId1;
|
var organizationId = ScimApplicationFactory.TestOrganizationId1;
|
||||||
var model = new ScimGroupRequestModel
|
var model = new ScimGroupRequestModel
|
||||||
|
@ -324,7 +324,7 @@ public class UsersControllerTests : IClassFixture<ScimApplicationFactory>, IAsyn
|
|||||||
[InlineData(null)]
|
[InlineData(null)]
|
||||||
[InlineData("")]
|
[InlineData("")]
|
||||||
[InlineData(" ")]
|
[InlineData(" ")]
|
||||||
public async Task Post_InvalidEmail_BadRequest(string email)
|
public async Task Post_InvalidEmail_BadRequest(string? email)
|
||||||
{
|
{
|
||||||
var displayName = "Test User 5";
|
var displayName = "Test User 5";
|
||||||
var externalId = "UE";
|
var externalId = "UE";
|
||||||
|
@ -1,6 +1,5 @@
|
|||||||
<Project Sdk="Microsoft.NET.Sdk.Web">
|
<Project Sdk="Microsoft.NET.Sdk.Web">
|
||||||
<PropertyGroup>
|
<PropertyGroup>
|
||||||
<Nullable>enable</Nullable>
|
|
||||||
<IsPackable>false</IsPackable>
|
<IsPackable>false</IsPackable>
|
||||||
</PropertyGroup>
|
</PropertyGroup>
|
||||||
|
|
||||||
|
@ -41,8 +41,6 @@ using Xunit;
|
|||||||
using Organization = Bit.Core.AdminConsole.Entities.Organization;
|
using Organization = Bit.Core.AdminConsole.Entities.Organization;
|
||||||
using OrganizationUser = Bit.Core.Entities.OrganizationUser;
|
using OrganizationUser = Bit.Core.Entities.OrganizationUser;
|
||||||
|
|
||||||
#nullable enable
|
|
||||||
|
|
||||||
namespace Bit.Core.Test.Services;
|
namespace Bit.Core.Test.Services;
|
||||||
|
|
||||||
[SutProviderCustomize]
|
[SutProviderCustomize]
|
||||||
|
@ -109,7 +109,7 @@ public class OrgUserInviteTokenableTests
|
|||||||
[Theory]
|
[Theory]
|
||||||
[InlineData(null)]
|
[InlineData(null)]
|
||||||
[InlineData("")]
|
[InlineData("")]
|
||||||
public void Valid_NullOrEmptyOrgUserEmail_ReturnsFalse(string email)
|
public void Valid_NullOrEmptyOrgUserEmail_ReturnsFalse(string? email)
|
||||||
{
|
{
|
||||||
var token = new OrgUserInviteTokenable
|
var token = new OrgUserInviteTokenable
|
||||||
{
|
{
|
||||||
|
@ -271,7 +271,7 @@ public class CoreHelpersTests
|
|||||||
[InlineData("ascii.com", "ascii.com")]
|
[InlineData("ascii.com", "ascii.com")]
|
||||||
[InlineData("", "")]
|
[InlineData("", "")]
|
||||||
[InlineData(null, null)]
|
[InlineData(null, null)]
|
||||||
public void PunyEncode_Success(string text, string expected)
|
public void PunyEncode_Success(string? text, string? expected)
|
||||||
{
|
{
|
||||||
var actual = CoreHelpers.PunyEncode(text);
|
var actual = CoreHelpers.PunyEncode(text);
|
||||||
Assert.Equal(expected, actual);
|
Assert.Equal(expected, actual);
|
||||||
@ -435,7 +435,7 @@ public class CoreHelpersTests
|
|||||||
[InlineData("name@", "name@")] // @ symbol but no domain
|
[InlineData("name@", "name@")] // @ symbol but no domain
|
||||||
[InlineData("", "")] // Empty string
|
[InlineData("", "")] // Empty string
|
||||||
[InlineData(null, null)] // null
|
[InlineData(null, null)] // null
|
||||||
public void ObfuscateEmail_Success(string input, string expected)
|
public void ObfuscateEmail_Success(string? input, string? expected)
|
||||||
{
|
{
|
||||||
Assert.Equal(expected, CoreHelpers.ObfuscateEmail(input));
|
Assert.Equal(expected, CoreHelpers.ObfuscateEmail(input));
|
||||||
}
|
}
|
||||||
@ -456,7 +456,7 @@ public class CoreHelpersTests
|
|||||||
[InlineData("user@")]
|
[InlineData("user@")]
|
||||||
[InlineData("@example.com")]
|
[InlineData("@example.com")]
|
||||||
[InlineData("user@ex@ample.com")]
|
[InlineData("user@ex@ample.com")]
|
||||||
public void GetEmailDomain_ReturnsNull(string wrongEmail)
|
public void GetEmailDomain_ReturnsNull(string? wrongEmail)
|
||||||
{
|
{
|
||||||
Assert.Null(CoreHelpers.GetEmailDomain(wrongEmail));
|
Assert.Null(CoreHelpers.GetEmailDomain(wrongEmail));
|
||||||
}
|
}
|
||||||
|
@ -25,7 +25,7 @@ public class EncryptedStringAttributeTests
|
|||||||
[InlineData("Rsa2048_OaepSha256_HmacSha256_B64.QmFzZTY0UGFydA==|QmFzZTY0UGFydA==")] // Valid Rsa2048_OaepSha256_HmacSha256_B64 as a string
|
[InlineData("Rsa2048_OaepSha256_HmacSha256_B64.QmFzZTY0UGFydA==|QmFzZTY0UGFydA==")] // Valid Rsa2048_OaepSha256_HmacSha256_B64 as a string
|
||||||
[InlineData("6.QmFzZTY0UGFydA==|QmFzZTY0UGFydA==")] // Valid Rsa2048_OaepSha1_HmacSha256_B64 as a number
|
[InlineData("6.QmFzZTY0UGFydA==|QmFzZTY0UGFydA==")] // Valid Rsa2048_OaepSha1_HmacSha256_B64 as a number
|
||||||
[InlineData("Rsa2048_OaepSha1_HmacSha256_B64.QmFzZTY0UGFydA==|QmFzZTY0UGFydA==")]
|
[InlineData("Rsa2048_OaepSha1_HmacSha256_B64.QmFzZTY0UGFydA==|QmFzZTY0UGFydA==")]
|
||||||
public void IsValid_ReturnsTrue_WhenValid(string input)
|
public void IsValid_ReturnsTrue_WhenValid(string? input)
|
||||||
{
|
{
|
||||||
var sut = new EncryptedStringAttribute();
|
var sut = new EncryptedStringAttribute();
|
||||||
|
|
||||||
|
@ -47,7 +47,7 @@ public class StrictEmailAttributeTests
|
|||||||
[InlineData("hellothere@world.com-")] // domain ending in hyphen
|
[InlineData("hellothere@world.com-")] // domain ending in hyphen
|
||||||
[InlineData("hellö@world.com")] // unicode at end of local-part
|
[InlineData("hellö@world.com")] // unicode at end of local-part
|
||||||
[InlineData("héllo@world.com")] // unicode in middle of local-part
|
[InlineData("héllo@world.com")] // unicode in middle of local-part
|
||||||
public void IsValid_ReturnsFalseWhenInvalid(string email)
|
public void IsValid_ReturnsFalseWhenInvalid(string? email)
|
||||||
{
|
{
|
||||||
var sut = new StrictEmailAddressAttribute();
|
var sut = new StrictEmailAddressAttribute();
|
||||||
|
|
||||||
|
@ -42,7 +42,7 @@ public class StrictEmailAddressListAttributeTests
|
|||||||
[Theory]
|
[Theory]
|
||||||
[InlineData("single@email.com", false)]
|
[InlineData("single@email.com", false)]
|
||||||
[InlineData(null, false)]
|
[InlineData(null, false)]
|
||||||
public void IsValid_ReturnsTrue_WhenValid(string email, bool valid)
|
public void IsValid_ReturnsTrue_WhenValid(string? email, bool valid)
|
||||||
{
|
{
|
||||||
var sut = new StrictEmailAddressListAttribute();
|
var sut = new StrictEmailAddressListAttribute();
|
||||||
|
|
||||||
|
@ -3,7 +3,6 @@
|
|||||||
<PropertyGroup>
|
<PropertyGroup>
|
||||||
<TargetFramework>net8.0</TargetFramework>
|
<TargetFramework>net8.0</TargetFramework>
|
||||||
<ImplicitUsings>enable</ImplicitUsings>
|
<ImplicitUsings>enable</ImplicitUsings>
|
||||||
<Nullable>enable</Nullable>
|
|
||||||
<IsPackable>false</IsPackable>
|
<IsPackable>false</IsPackable>
|
||||||
<IsTestProject>true</IsTestProject>
|
<IsTestProject>true</IsTestProject>
|
||||||
</PropertyGroup>
|
</PropertyGroup>
|
||||||
|
@ -45,7 +45,7 @@ public class IconLinkTests
|
|||||||
[InlineData(" ", false)]
|
[InlineData(" ", false)]
|
||||||
[InlineData("unusable", false)]
|
[InlineData("unusable", false)]
|
||||||
[InlineData("ico", true)]
|
[InlineData("ico", true)]
|
||||||
public void WithNoRel_IsUsable(string extension, bool expectedResult)
|
public void WithNoRel_IsUsable(string? extension, bool expectedResult)
|
||||||
{
|
{
|
||||||
SetAttributeValue("href", $"/favicon.{extension}");
|
SetAttributeValue("href", $"/favicon.{extension}");
|
||||||
|
|
||||||
|
@ -1,7 +1,6 @@
|
|||||||
<Project Sdk="Microsoft.NET.Sdk">
|
<Project Sdk="Microsoft.NET.Sdk">
|
||||||
|
|
||||||
<PropertyGroup>
|
<PropertyGroup>
|
||||||
<Nullable>enable</Nullable>
|
|
||||||
<IsPackable>false</IsPackable>
|
<IsPackable>false</IsPackable>
|
||||||
</PropertyGroup>
|
</PropertyGroup>
|
||||||
|
|
||||||
|
@ -3,8 +3,6 @@
|
|||||||
<PropertyGroup>
|
<PropertyGroup>
|
||||||
<TargetFramework>net8.0</TargetFramework>
|
<TargetFramework>net8.0</TargetFramework>
|
||||||
<ImplicitUsings>enable</ImplicitUsings>
|
<ImplicitUsings>enable</ImplicitUsings>
|
||||||
<Nullable>enable</Nullable>
|
|
||||||
|
|
||||||
<IsPackable>false</IsPackable>
|
<IsPackable>false</IsPackable>
|
||||||
<IsTestProject>true</IsTestProject>
|
<IsTestProject>true</IsTestProject>
|
||||||
</PropertyGroup>
|
</PropertyGroup>
|
||||||
|
@ -1,7 +1,6 @@
|
|||||||
<Project Sdk="Microsoft.NET.Sdk">
|
<Project Sdk="Microsoft.NET.Sdk">
|
||||||
|
|
||||||
<PropertyGroup>
|
<PropertyGroup>
|
||||||
<Nullable>enable</Nullable>
|
|
||||||
<IsPackable>false</IsPackable>
|
<IsPackable>false</IsPackable>
|
||||||
<UserSecretsId>6570f288-5c2c-47ad-8978-f3da255079c2</UserSecretsId>
|
<UserSecretsId>6570f288-5c2c-47ad-8978-f3da255079c2</UserSecretsId>
|
||||||
</PropertyGroup>
|
</PropertyGroup>
|
||||||
|
Loading…
Reference in New Issue
Block a user