-
Notifications
You must be signed in to change notification settings - Fork 10
FEAT: Integration Tests #87
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merged
Merged
Changes from 3 commits
Commits
Show all changes
14 commits
Select commit
Hold shift + click to select a range
d7b0c38
FEAT: Initial version of Integration Tests without template flags.
CesarD 9330f48
CHORE: Merged from main
CesarD a34819e
CHORE: Cleanup
CesarD 62236bf
Fixed AccessTokenDto constructor.
CesarD 089b38c
Added template flags.
CesarD 02f394b
Added WorkerServiceFactory for generating instances of WorkerServices.
CesarD f984cc3
Added missing flags in IntegrationTests project file.
CesarD 2460546
Fixes for PR comments.
CesarD daf615f
Missing fix for the comments.
CesarD 017d71d
Fixing PR comments.
CesarD 74170b1
Missing exclusions for flag combination.
CesarD fa9be13
Correcting exclusion flags and missing exclusions.
CesarD 1a80fcc
Fixed typo
CesarD e14bbea
Added missing exclusion.
CesarD File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
14 changes: 14 additions & 0 deletions
14
src/Content/Backend/Solution/Monaco.Template.Backend.IntegrationTests/AccessTokenDto.cs
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,14 @@ | ||
using System.Text.Json.Serialization; | ||
|
||
namespace Monaco.Template.Backend.IntegrationTests; | ||
|
||
public record AccessTokenDto | ||
{ | ||
public AccessTokenDto(string accessToken, int expiresIn) | ||
{ | ||
AccessToken = accessToken; | ||
} | ||
|
||
[JsonPropertyName("access_token")] | ||
public string AccessToken { get; init; } | ||
} |
92 changes: 92 additions & 0 deletions
92
src/Content/Backend/Solution/Monaco.Template.Backend.IntegrationTests/ApiRoutes.cs
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,92 @@ | ||
using Flurl; | ||
using Monaco.Template.Backend.Application.DTOs; | ||
|
||
namespace Monaco.Template.Backend.IntegrationTests; | ||
|
||
internal static class ApiRoutes | ||
{ | ||
private static readonly Url ApiVersion = "api/v1"; | ||
private const string ExpandParamName = "expand"; | ||
private const string OffsetParamName = "offset"; | ||
private const string LimitParamName = "limit"; | ||
|
||
private static Url Expand(this Url url, | ||
bool expand, | ||
string paramName) => | ||
expand | ||
? url.AppendQueryParam(ExpandParamName, paramName) | ||
: url; | ||
|
||
private static Url Offset(this Url url, int? offset = null) => | ||
offset.HasValue | ||
? url.SetQueryParam(OffsetParamName, offset.Value) | ||
: url; | ||
|
||
private static Url Limit(this Url url, int? limit = null) => | ||
limit.HasValue | ||
? url.SetQueryParam(LimitParamName, limit.Value) | ||
: url; | ||
|
||
public static class Companies | ||
{ | ||
private static Url Controller => ApiVersion.Clone() | ||
.AppendPathSegment(nameof(Companies)); | ||
|
||
public static Url Query(bool expandCountry = false, int? offset = null, int? limit = null) => | ||
Controller.Expand(expandCountry, nameof(CompanyDto.Country)) | ||
.Offset(offset) | ||
.Limit(limit); | ||
public static Url Get(Guid id) => Controller.AppendPathSegment(id); | ||
public static string Post() => Query(); | ||
public static string Put(Guid id) => Get(id); | ||
public static string Delete(Guid id) => Get(id); | ||
} | ||
|
||
public static class Countries | ||
{ | ||
private static Url Controller => ApiVersion.Clone() | ||
.AppendPathSegment(nameof(Countries)); | ||
|
||
public static Url Query() => Controller; | ||
public static Url Get(Guid id) => Controller.AppendPathSegment(id); | ||
} | ||
|
||
public static class Files | ||
{ | ||
private static Url Controller => ApiVersion.Clone() | ||
.AppendPathSegment(nameof(Files)); | ||
|
||
public static Url Post() => Controller; | ||
} | ||
|
||
public static class Products | ||
{ | ||
private static Url Controller => ApiVersion.Clone() | ||
.AppendPathSegment(nameof(Products)); | ||
|
||
public static Url Query(bool expandCompany = false, | ||
bool expandPictures = false, | ||
bool expandDefaultPicture = false, | ||
int? offset = null, | ||
int? limit = null) => | ||
Controller.Expand(expandCompany, nameof(ProductDto.Company)) | ||
.Expand(expandPictures, nameof(ProductDto.Pictures)) | ||
.Expand(expandDefaultPicture, nameof(ProductDto.DefaultPicture)) | ||
.Offset(offset) | ||
.Limit(limit); | ||
|
||
public static Url Get(Guid id) => Controller.AppendPathSegment(id); | ||
|
||
public static Url DownloadPicture(Guid productId, Guid pictureId, bool? isThumbnail = null) | ||
{ | ||
var url = Controller.AppendPathSegments(productId, "Pictures", pictureId); | ||
return isThumbnail.HasValue | ||
? url.SetQueryParam("thumbnail", isThumbnail.Value.ToString().ToLower()) | ||
: url; | ||
matthewtoghill marked this conversation as resolved.
Show resolved
Hide resolved
|
||
} | ||
|
||
public static string Post() => Query(); | ||
public static string Put(Guid id) => Get(id); | ||
public static string Delete(Guid id) => Get(id); | ||
} | ||
} |
43 changes: 43 additions & 0 deletions
43
...ent/Backend/Solution/Monaco.Template.Backend.IntegrationTests/ApiWebApplicationFactory.cs
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,43 @@ | ||
using Flurl; | ||
using Microsoft.AspNetCore.Hosting; | ||
using Microsoft.AspNetCore.Mvc.Testing; | ||
using Microsoft.Extensions.Configuration; | ||
|
||
namespace Monaco.Template.Backend.IntegrationTests; | ||
|
||
public class ApiWebApplicationFactory : WebApplicationFactory<Api.Program> | ||
{ | ||
public readonly string SqlConnectionString; | ||
public readonly Url RabbitMqHost; | ||
public readonly string RabbitMqUsername; | ||
public readonly string RabbitMqPassword; | ||
public readonly Url StorageConnectionString; | ||
public readonly Url KeycloakRealmUrl; | ||
|
||
public ApiWebApplicationFactory(AppFixture fixture) | ||
{ | ||
SqlConnectionString = fixture.SqlContainer.GetConnectionString(); | ||
Url rabbitMqConnString = fixture.RabbitMqContainer.GetConnectionString(); | ||
RabbitMqUsername = rabbitMqConnString.UserInfo.Split(':').First(); | ||
RabbitMqPassword = rabbitMqConnString.UserInfo.Split(':').Last(); | ||
RabbitMqHost = rabbitMqConnString.Root.Replace($"{rabbitMqConnString.UserInfo}@", string.Empty); | ||
StorageConnectionString = fixture.AzuriteContainer.GetConnectionString(); | ||
KeycloakRealmUrl = fixture.KeycloakContainer | ||
.GetBaseAddress() | ||
.AppendPathSegments("realms", AppFixture.KeycloakRealm); | ||
} | ||
|
||
protected override void ConfigureWebHost(IWebHostBuilder builder) | ||
{ | ||
builder.UseConfiguration(new ConfigurationManager | ||
{ | ||
["ConnectionStrings:AppDbContext"] = SqlConnectionString, | ||
["SSO:Authority"] = KeycloakRealmUrl, | ||
["BlobStorage:ConnectionString"] = StorageConnectionString, | ||
["MessageBus:RabbitMQ:Host"] = RabbitMqHost, | ||
["MessageBus:RabbitMQ:User"] = RabbitMqUsername, | ||
["MessageBus:RabbitMQ:Password"] = RabbitMqPassword | ||
}) | ||
.UseSetting("https_port", "8080"); | ||
} | ||
} |
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.