mirror of https://github.com/Squidex/squidex.git
45 changed files with 50 additions and 601 deletions
@ -1,70 +0,0 @@ |
|||||
// ==========================================================================
|
|
||||
// Squidex Headless CMS
|
|
||||
// ==========================================================================
|
|
||||
// Copyright (c) Squidex UG (haftungsbeschränkt)
|
|
||||
// All rights reserved. Licensed under the MIT license.
|
|
||||
// ==========================================================================
|
|
||||
|
|
||||
using System.Collections.Generic; |
|
||||
using FluentAssertions; |
|
||||
using Squidex.Domain.Apps.Rules.Action.Algolia; |
|
||||
using Squidex.Infrastructure; |
|
||||
using Xunit; |
|
||||
|
|
||||
namespace Squidex.Domain.Apps.Entities.Rules.Guards.Actions |
|
||||
{ |
|
||||
public class AlgoliaActionTests |
|
||||
{ |
|
||||
[Fact] |
|
||||
public void Should_add_error_if_app_id_not_defined() |
|
||||
{ |
|
||||
var action = new AlgoliaAction { AppId = null, ApiKey = "KEY", IndexName = "IDX" }; |
|
||||
|
|
||||
var errors = action.Validate(); |
|
||||
|
|
||||
errors.Should().BeEquivalentTo( |
|
||||
new List<ValidationError> |
|
||||
{ |
|
||||
new ValidationError("The Application Id field is required.", "AppId") |
|
||||
}); |
|
||||
} |
|
||||
|
|
||||
[Fact] |
|
||||
public void Should_add_error_if_api_key_not_defined() |
|
||||
{ |
|
||||
var action = new AlgoliaAction { AppId = "APP", ApiKey = null, IndexName = "IDX" }; |
|
||||
|
|
||||
var errors = action.Validate(); |
|
||||
|
|
||||
errors.Should().BeEquivalentTo( |
|
||||
new List<ValidationError> |
|
||||
{ |
|
||||
new ValidationError("The Api Key field is required.", "ApiKey") |
|
||||
}); |
|
||||
} |
|
||||
|
|
||||
[Fact] |
|
||||
public void Should_add_error_if_index_name_not_defined() |
|
||||
{ |
|
||||
var action = new AlgoliaAction { AppId = "APP", ApiKey = "KEY", IndexName = null }; |
|
||||
|
|
||||
var errors = action.Validate(); |
|
||||
|
|
||||
errors.Should().BeEquivalentTo( |
|
||||
new List<ValidationError> |
|
||||
{ |
|
||||
new ValidationError("The Index Name field is required.", "IndexName") |
|
||||
}); |
|
||||
} |
|
||||
|
|
||||
[Fact] |
|
||||
public void Should_not_add_error_everything_defined() |
|
||||
{ |
|
||||
var action = new AlgoliaAction { AppId = "APP", ApiKey = "KEY", IndexName = "IDX" }; |
|
||||
|
|
||||
var errors = action.Validate(); |
|
||||
|
|
||||
Assert.Empty(errors); |
|
||||
} |
|
||||
} |
|
||||
} |
|
||||
@ -1,70 +0,0 @@ |
|||||
// ==========================================================================
|
|
||||
// Squidex Headless CMS
|
|
||||
// ==========================================================================
|
|
||||
// Copyright (c) Squidex UG (haftungsbeschränkt)
|
|
||||
// All rights reserved. Licensed under the MIT license.
|
|
||||
// ==========================================================================
|
|
||||
|
|
||||
using System.Collections.Generic; |
|
||||
using FluentAssertions; |
|
||||
using Squidex.Domain.Apps.Rules.Action.AzureQueue; |
|
||||
using Squidex.Infrastructure; |
|
||||
using Xunit; |
|
||||
|
|
||||
namespace Squidex.Domain.Apps.Entities.Rules.Guards.Actions |
|
||||
{ |
|
||||
public class AzureQueueActionTests |
|
||||
{ |
|
||||
[Fact] |
|
||||
public void Should_add_error_if_connection_string_is_null() |
|
||||
{ |
|
||||
var action = new AzureQueueAction { ConnectionString = null, Queue = "squidex" }; |
|
||||
|
|
||||
var errors = action.Validate(); |
|
||||
|
|
||||
errors.Should().BeEquivalentTo( |
|
||||
new List<ValidationError> |
|
||||
{ |
|
||||
new ValidationError("The Connection String field is required.", "ConnectionString") |
|
||||
}); |
|
||||
} |
|
||||
|
|
||||
[Fact] |
|
||||
public void Should_add_error_if_queue_is_null() |
|
||||
{ |
|
||||
var action = new AzureQueueAction { ConnectionString = "connection", Queue = null }; |
|
||||
|
|
||||
var errors = action.Validate(); |
|
||||
|
|
||||
errors.Should().BeEquivalentTo( |
|
||||
new List<ValidationError> |
|
||||
{ |
|
||||
new ValidationError("The Queue field is required.", "Queue") |
|
||||
}); |
|
||||
} |
|
||||
|
|
||||
[Fact] |
|
||||
public void Should_add_error_if_queue_is_invalid() |
|
||||
{ |
|
||||
var action = new AzureQueueAction { ConnectionString = "connection", Queue = "Squidex" }; |
|
||||
|
|
||||
var errors = action.Validate(); |
|
||||
|
|
||||
errors.Should().BeEquivalentTo( |
|
||||
new List<ValidationError> |
|
||||
{ |
|
||||
new ValidationError("Queue must be valid azure queue name.", "Queue") |
|
||||
}); |
|
||||
} |
|
||||
|
|
||||
[Fact] |
|
||||
public void Should_not_add_error_if_values_are_valid() |
|
||||
{ |
|
||||
var action = new AzureQueueAction { ConnectionString = "connection", Queue = "squidex" }; |
|
||||
|
|
||||
var errors = action.Validate(); |
|
||||
|
|
||||
Assert.Empty(errors); |
|
||||
} |
|
||||
} |
|
||||
} |
|
||||
@ -1,85 +0,0 @@ |
|||||
// ==========================================================================
|
|
||||
// Squidex Headless CMS
|
|
||||
// ==========================================================================
|
|
||||
// Copyright (c) Squidex UG (haftungsbeschränkt)
|
|
||||
// All rights reserved. Licensed under the MIT license.
|
|
||||
// ==========================================================================
|
|
||||
|
|
||||
using System; |
|
||||
using System.Collections.Generic; |
|
||||
using FluentAssertions; |
|
||||
using Squidex.Domain.Apps.Rules.Action.ElasticSearch; |
|
||||
using Squidex.Infrastructure; |
|
||||
using Xunit; |
|
||||
|
|
||||
namespace Squidex.Domain.Apps.Entities.Rules.Guards.Actions |
|
||||
{ |
|
||||
public class ElasticSearchActionTests |
|
||||
{ |
|
||||
[Fact] |
|
||||
public void Should_add_error_if_host_is_null() |
|
||||
{ |
|
||||
var action = new ElasticSearchAction { Host = null, IndexName = "squidex", IndexType = "squidex" }; |
|
||||
|
|
||||
var errors = action.Validate(); |
|
||||
|
|
||||
errors.Should().BeEquivalentTo( |
|
||||
new List<ValidationError> |
|
||||
{ |
|
||||
new ValidationError("The Host field is required.", "Host") |
|
||||
}); |
|
||||
} |
|
||||
|
|
||||
[Fact] |
|
||||
public void Should_add_error_if_host_is_relative() |
|
||||
{ |
|
||||
var action = new ElasticSearchAction { Host = new Uri("/rel", UriKind.Relative), IndexName = "squidex", IndexType = "squidex" }; |
|
||||
|
|
||||
var errors = action.Validate(); |
|
||||
|
|
||||
errors.Should().BeEquivalentTo( |
|
||||
new List<ValidationError> |
|
||||
{ |
|
||||
new ValidationError("The Host field must be an absolute URL.", "Host") |
|
||||
}); |
|
||||
} |
|
||||
|
|
||||
[Fact] |
|
||||
public void Should_add_error_if_index_name_is_null() |
|
||||
{ |
|
||||
var action = new ElasticSearchAction { Host = new Uri("http://host", UriKind.Absolute), IndexName = null, IndexType = "squidex" }; |
|
||||
|
|
||||
var errors = action.Validate(); |
|
||||
|
|
||||
errors.Should().BeEquivalentTo( |
|
||||
new List<ValidationError> |
|
||||
{ |
|
||||
new ValidationError("The Index Name field is required.", "IndexName") |
|
||||
}); |
|
||||
} |
|
||||
|
|
||||
[Fact] |
|
||||
public void Should_add_error_if_index_type_is_null() |
|
||||
{ |
|
||||
var action = new ElasticSearchAction { Host = new Uri("http://host", UriKind.Absolute), IndexName = "squidex", IndexType = null }; |
|
||||
|
|
||||
var errors = action.Validate(); |
|
||||
|
|
||||
errors.Should().BeEquivalentTo( |
|
||||
new List<ValidationError> |
|
||||
{ |
|
||||
new ValidationError("The Index Type field is required.", "IndexType") |
|
||||
}); |
|
||||
} |
|
||||
|
|
||||
[Fact] |
|
||||
public void Should_not_add_error_if_values_are_valid() |
|
||||
{ |
|
||||
var action = new ElasticSearchAction { Host = new Uri("http://host", UriKind.Absolute), IndexName = "squidex", IndexType = "squidex" }; |
|
||||
|
|
||||
var errors = action.Validate(); |
|
||||
|
|
||||
Assert.Empty(errors); |
|
||||
} |
|
||||
} |
|
||||
} |
|
||||
@ -1,56 +0,0 @@ |
|||||
// ==========================================================================
|
|
||||
// Squidex Headless CMS
|
|
||||
// ==========================================================================
|
|
||||
// Copyright (c) Squidex UG (haftungsbeschränkt)
|
|
||||
// All rights reserved. Licensed under the MIT license.
|
|
||||
// ==========================================================================
|
|
||||
|
|
||||
using System.Collections.Generic; |
|
||||
using FluentAssertions; |
|
||||
using Squidex.Domain.Apps.Rules.Action.Fastly; |
|
||||
using Squidex.Infrastructure; |
|
||||
using Xunit; |
|
||||
|
|
||||
namespace Squidex.Domain.Apps.Entities.Rules.Guards.Actions |
|
||||
{ |
|
||||
public class FastlyActionTests |
|
||||
{ |
|
||||
[Fact] |
|
||||
public void Should_add_error_if_service_id_not_defined() |
|
||||
{ |
|
||||
var action = new FastlyAction { ServiceId = null, ApiKey = "KEY" }; |
|
||||
|
|
||||
var errors = action.Validate(); |
|
||||
|
|
||||
errors.Should().BeEquivalentTo( |
|
||||
new List<ValidationError> |
|
||||
{ |
|
||||
new ValidationError("The Service Id field is required.", "ServiceId") |
|
||||
}); |
|
||||
} |
|
||||
|
|
||||
[Fact] |
|
||||
public void Should_add_error_if_api_key_not_defined() |
|
||||
{ |
|
||||
var action = new FastlyAction { ServiceId = "APP", ApiKey = null }; |
|
||||
|
|
||||
var errors = action.Validate(); |
|
||||
|
|
||||
errors.Should().BeEquivalentTo( |
|
||||
new List<ValidationError> |
|
||||
{ |
|
||||
new ValidationError("The Api Key field is required.", "ApiKey") |
|
||||
}); |
|
||||
} |
|
||||
|
|
||||
[Fact] |
|
||||
public void Should_not_add_error_everything_defined() |
|
||||
{ |
|
||||
var action = new FastlyAction { ServiceId = "APP", ApiKey = "KEY" }; |
|
||||
|
|
||||
var errors = action.Validate(); |
|
||||
|
|
||||
Assert.Empty(errors); |
|
||||
} |
|
||||
} |
|
||||
} |
|
||||
@ -1,70 +0,0 @@ |
|||||
// ==========================================================================
|
|
||||
// Squidex Headless CMS
|
|
||||
// ==========================================================================
|
|
||||
// Copyright (c) Squidex UG (haftungsbeschränkt)
|
|
||||
// All rights reserved. Licensed under the MIT license.
|
|
||||
// ==========================================================================
|
|
||||
|
|
||||
using System.Collections.Generic; |
|
||||
using FluentAssertions; |
|
||||
using Squidex.Domain.Apps.Rules.Action.Medium; |
|
||||
using Squidex.Infrastructure; |
|
||||
using Xunit; |
|
||||
|
|
||||
namespace Squidex.Domain.Apps.Entities.Rules.Guards.Actions |
|
||||
{ |
|
||||
public class MediumActionTests |
|
||||
{ |
|
||||
[Fact] |
|
||||
public void Should_add_error_if_access_token_is_null() |
|
||||
{ |
|
||||
var action = new MediumAction { AccessToken = null, Title = "title", Content = "content" }; |
|
||||
|
|
||||
var errors = action.Validate(); |
|
||||
|
|
||||
errors.Should().BeEquivalentTo( |
|
||||
new List<ValidationError> |
|
||||
{ |
|
||||
new ValidationError("The Access Token field is required.", "AccessToken") |
|
||||
}); |
|
||||
} |
|
||||
|
|
||||
[Fact] |
|
||||
public void Should_add_error_if_title_null() |
|
||||
{ |
|
||||
var action = new MediumAction { AccessToken = "token", Title = null, Content = "content" }; |
|
||||
|
|
||||
var errors = action.Validate(); |
|
||||
|
|
||||
errors.Should().BeEquivalentTo( |
|
||||
new List<ValidationError> |
|
||||
{ |
|
||||
new ValidationError("The Title field is required.", "Title") |
|
||||
}); |
|
||||
} |
|
||||
|
|
||||
[Fact] |
|
||||
public void Should_add_error_if_content_is_null() |
|
||||
{ |
|
||||
var action = new MediumAction { AccessToken = "token", Title = "title", Content = null }; |
|
||||
|
|
||||
var errors = action.Validate(); |
|
||||
|
|
||||
errors.Should().BeEquivalentTo( |
|
||||
new List<ValidationError> |
|
||||
{ |
|
||||
new ValidationError("The Content field is required.", "Content") |
|
||||
}); |
|
||||
} |
|
||||
|
|
||||
[Fact] |
|
||||
public void Should_not_add_error_if_values_are_valid() |
|
||||
{ |
|
||||
var action = new MediumAction { AccessToken = "token", Title = "title", Content = "content" }; |
|
||||
|
|
||||
var errors = action.Validate(); |
|
||||
|
|
||||
Assert.Empty(errors); |
|
||||
} |
|
||||
} |
|
||||
} |
|
||||
@ -1,71 +0,0 @@ |
|||||
// ==========================================================================
|
|
||||
// Squidex Headless CMS
|
|
||||
// ==========================================================================
|
|
||||
// Copyright (c) Squidex UG (haftungsbeschränkt)
|
|
||||
// All rights reserved. Licensed under the MIT license.
|
|
||||
// ==========================================================================
|
|
||||
|
|
||||
using System; |
|
||||
using System.Collections.Generic; |
|
||||
using FluentAssertions; |
|
||||
using Squidex.Domain.Apps.Rules.Action.Slack; |
|
||||
using Squidex.Infrastructure; |
|
||||
using Xunit; |
|
||||
|
|
||||
namespace Squidex.Domain.Apps.Entities.Rules.Guards.Actions |
|
||||
{ |
|
||||
public class SlackActionTests |
|
||||
{ |
|
||||
[Fact] |
|
||||
public void Should_add_error_if_webhook_url_is_null() |
|
||||
{ |
|
||||
var action = new SlackAction { WebhookUrl = null, Text = "text" }; |
|
||||
|
|
||||
var errors = action.Validate(); |
|
||||
|
|
||||
errors.Should().BeEquivalentTo( |
|
||||
new List<ValidationError> |
|
||||
{ |
|
||||
new ValidationError("The Webhook Url field is required.", "WebhookUrl") |
|
||||
}); |
|
||||
} |
|
||||
|
|
||||
[Fact] |
|
||||
public void Should_add_error_if_webhook_url_is_relative() |
|
||||
{ |
|
||||
var action = new SlackAction { WebhookUrl = new Uri("/invalid", UriKind.Relative), Text = "text" }; |
|
||||
|
|
||||
var errors = action.Validate(); |
|
||||
|
|
||||
errors.Should().BeEquivalentTo( |
|
||||
new List<ValidationError> |
|
||||
{ |
|
||||
new ValidationError("The Webhook Url field must be an absolute URL.", "WebhookUrl") |
|
||||
}); |
|
||||
} |
|
||||
|
|
||||
[Fact] |
|
||||
public void Should_add_error_if_text_is_null() |
|
||||
{ |
|
||||
var action = new SlackAction { WebhookUrl = new Uri("https://squidex.io", UriKind.Absolute), Text = null }; |
|
||||
|
|
||||
var errors = action.Validate(); |
|
||||
|
|
||||
errors.Should().BeEquivalentTo( |
|
||||
new List<ValidationError> |
|
||||
{ |
|
||||
new ValidationError("The Text field is required.", "Text") |
|
||||
}); |
|
||||
} |
|
||||
|
|
||||
[Fact] |
|
||||
public void Should_not_add_error_if_webhook_url_is_absolute() |
|
||||
{ |
|
||||
var action = new SlackAction { WebhookUrl = new Uri("https://squidex.io", UriKind.Absolute), Text = "text" }; |
|
||||
|
|
||||
var errors = action.Validate(); |
|
||||
|
|
||||
Assert.Empty(errors); |
|
||||
} |
|
||||
} |
|
||||
} |
|
||||
@ -1,70 +0,0 @@ |
|||||
// ==========================================================================
|
|
||||
// Squidex Headless CMS
|
|
||||
// ==========================================================================
|
|
||||
// Copyright (c) Squidex UG (haftungsbeschränkt)
|
|
||||
// All rights reserved. Licensed under the MIT license.
|
|
||||
// ==========================================================================
|
|
||||
|
|
||||
using System.Collections.Generic; |
|
||||
using FluentAssertions; |
|
||||
using Squidex.Domain.Apps.Rules.Action.Twitter; |
|
||||
using Squidex.Infrastructure; |
|
||||
using Xunit; |
|
||||
|
|
||||
namespace Squidex.Domain.Apps.Entities.Rules.Guards.Actions |
|
||||
{ |
|
||||
public class TweetActionTests |
|
||||
{ |
|
||||
[Fact] |
|
||||
public void Should_add_error_if_access_token_is_null() |
|
||||
{ |
|
||||
var action = new TweetAction { AccessToken = null, AccessSecret = "secret", Text = "text" }; |
|
||||
|
|
||||
var errors = action.Validate(); |
|
||||
|
|
||||
errors.Should().BeEquivalentTo( |
|
||||
new List<ValidationError> |
|
||||
{ |
|
||||
new ValidationError("The Access Token field is required.", "AccessToken") |
|
||||
}); |
|
||||
} |
|
||||
|
|
||||
[Fact] |
|
||||
public void Should_add_error_if_access_secret_is_null() |
|
||||
{ |
|
||||
var action = new TweetAction { AccessToken = "token", AccessSecret = null, Text = "text" }; |
|
||||
|
|
||||
var errors = action.Validate(); |
|
||||
|
|
||||
errors.Should().BeEquivalentTo( |
|
||||
new List<ValidationError> |
|
||||
{ |
|
||||
new ValidationError("The Access Secret field is required.", "AccessSecret") |
|
||||
}); |
|
||||
} |
|
||||
|
|
||||
[Fact] |
|
||||
public void Should_add_error_if_text_is_null() |
|
||||
{ |
|
||||
var action = new TweetAction { AccessToken = "token", AccessSecret = "secret", Text = null }; |
|
||||
|
|
||||
var errors = action.Validate(); |
|
||||
|
|
||||
errors.Should().BeEquivalentTo( |
|
||||
new List<ValidationError> |
|
||||
{ |
|
||||
new ValidationError("The Text field is required.", "Text") |
|
||||
}); |
|
||||
} |
|
||||
|
|
||||
[Fact] |
|
||||
public void Should_not_add_error_if_access_token_and_secret_defined() |
|
||||
{ |
|
||||
var action = new TweetAction { AccessToken = "token", AccessSecret = "secret", Text = "text" }; |
|
||||
|
|
||||
var errors = action.Validate(); |
|
||||
|
|
||||
Assert.Empty(errors); |
|
||||
} |
|
||||
} |
|
||||
} |
|
||||
@ -1,57 +0,0 @@ |
|||||
// ==========================================================================
|
|
||||
// Squidex Headless CMS
|
|
||||
// ==========================================================================
|
|
||||
// Copyright (c) Squidex UG (haftungsbeschränkt)
|
|
||||
// All rights reserved. Licensed under the MIT license.
|
|
||||
// ==========================================================================
|
|
||||
|
|
||||
using System; |
|
||||
using System.Collections.Generic; |
|
||||
using FluentAssertions; |
|
||||
using Squidex.Domain.Apps.Rules.Action.Webhook; |
|
||||
using Squidex.Infrastructure; |
|
||||
using Xunit; |
|
||||
|
|
||||
namespace Squidex.Domain.Apps.Entities.Rules.Guards.Actions |
|
||||
{ |
|
||||
public class WebhookActionTests |
|
||||
{ |
|
||||
[Fact] |
|
||||
public void Should_add_error_if_url_is_null() |
|
||||
{ |
|
||||
var action = new WebhookAction { Url = null }; |
|
||||
|
|
||||
var errors = action.Validate(); |
|
||||
|
|
||||
errors.Should().BeEquivalentTo( |
|
||||
new List<ValidationError> |
|
||||
{ |
|
||||
new ValidationError("The Url field is required.", "Url") |
|
||||
}); |
|
||||
} |
|
||||
|
|
||||
[Fact] |
|
||||
public void Should_add_error_if_url_is_relative() |
|
||||
{ |
|
||||
var action = new WebhookAction { Url = new Uri("/invalid", UriKind.Relative) }; |
|
||||
|
|
||||
var errors = action.Validate(); |
|
||||
|
|
||||
errors.Should().BeEquivalentTo( |
|
||||
new List<ValidationError> |
|
||||
{ |
|
||||
new ValidationError("The Url field must be an absolute URL.", "Url") |
|
||||
}); |
|
||||
} |
|
||||
|
|
||||
[Fact] |
|
||||
public void Should_not_add_error_if_url_is_absolute() |
|
||||
{ |
|
||||
var action = new WebhookAction { Url = new Uri("https://squidex.io", UriKind.Absolute) }; |
|
||||
|
|
||||
var errors = action.Validate(); |
|
||||
|
|
||||
Assert.Empty(errors); |
|
||||
} |
|
||||
} |
|
||||
} |
|
||||
Loading…
Reference in new issue