1
0
mirror of https://github.com/bitwarden/server.git synced 2025-04-05 05:00:19 -05:00
bitwarden/test/Core.Test/Entities/OrganizationConnectionTests.cs
Thomas Rittson 82908b1fb7
[EC-826] Merge license sync feature branch to master (#2587)
* [EC-634] Extract GenerateLicenseAsync to a query (#2373)

* [EC-637] Add license sync to server (#2453)

* [EC-1036] Show correct license sync date (#2626)

* Update method name per new pattern
2023-01-31 07:42:10 +10:00

79 lines
2.5 KiB
C#

using Bit.Core.Entities;
using Bit.Core.Enums;
using Bit.Core.Models.OrganizationConnectionConfigs;
using Bit.Test.Common.AutoFixture.Attributes;
using Xunit;
namespace Bit.Core.Test.Entities;
public class OrganizationConnectionTests
{
[Theory]
[BitAutoData]
public void OrganizationConnection_CanUse_Success(Guid connectionId, Guid organizationId)
{
var connection = new OrganizationConnection<ScimConfig>()
{
Id = connectionId,
OrganizationId = organizationId,
Enabled = true,
Type = OrganizationConnectionType.Scim,
Config = new ScimConfig() { Enabled = true }
};
Assert.True(connection.Validate<ScimConfig>(out var exception));
Assert.True(string.IsNullOrEmpty(exception));
}
[Theory]
[BitAutoData]
public void OrganizationConnection_CanUse_WhenDisabled_ReturnsFalse(Guid connectionId, Guid organizationId)
{
var connection = new OrganizationConnection<ScimConfig>()
{
Id = connectionId,
OrganizationId = organizationId,
Enabled = false,
Type = OrganizationConnectionType.Scim,
Config = new ScimConfig() { Enabled = true }
};
Assert.False(connection.Validate<ScimConfig>(out var exception));
Assert.Contains("Connection disabled", exception);
}
[Theory]
[BitAutoData]
public void OrganizationConnection_CanUse_WhenNoConfig_ReturnsFalse(Guid connectionId, Guid organizationId)
{
var connection = new OrganizationConnection<ScimConfig>()
{
Id = connectionId,
OrganizationId = organizationId,
Enabled = true,
Type = OrganizationConnectionType.Scim,
};
Assert.False(connection.Validate<ScimConfig>(out var exception));
Assert.Contains("No saved Connection config", exception);
}
[Theory]
[BitAutoData]
public void OrganizationConnection_CanUse_WhenConfigInvalid_ReturnsFalse(Guid connectionId, Guid organizationId)
{
var connection = new OrganizationConnection<ScimConfig>()
{
Id = connectionId,
OrganizationId = organizationId,
Enabled = true,
Type = OrganizationConnectionType.Scim,
Config = new ScimConfig() { Enabled = false }
};
Assert.False(connection.Validate<ScimConfig>(out var exception));
Assert.Contains("Scim Config is disabled", exception);
}
}