diff --git a/.forgejo/workflows/buildAndTest.yml b/.forgejo/workflows/buildAndTest.yml index ea58d2fe..cb18656d 100644 --- a/.forgejo/workflows/buildAndTest.yml +++ b/.forgejo/workflows/buildAndTest.yml @@ -44,8 +44,4 @@ jobs: - name: Test run: | echo "🚀 Lancement des tests..." - cd /src/_src && dotnet test \ - --verbosity normal \ - --filter="Category!=Platform-Android" \ - --logger "xunit;LogFileName=test-results.xml" \ - && echo "✅ Success !" || echo "❌ Fail ($?)!" + cd /src/_src && dotnet test --verbosity normal && echo "✅ Success !" || echo "❌ Fail ($?)!" diff --git a/.github/workflows/docker-publish-backend.yml b/.github/workflows/docker-publish-backend.yml index d8466bdb..6c2431ae 100644 --- a/.github/workflows/docker-publish-backend.yml +++ b/.github/workflows/docker-publish-backend.yml @@ -26,7 +26,7 @@ jobs: username: ${{ secrets.DOCKERHUB_USERNAME }} password: ${{ secrets.DOCKERHUB_TOKEN }} - name: Test - run: dotnet test --no-build --verbosity normal --filter="Category!=Platform-Android" + run: dotnet test --no-build --verbosity normal # 4. Build et Push de l'image de production finale - name: Build and push production image uses: docker/build-push-action@v7 diff --git a/src/PostIt/PostIt.Tests/AndroidAppLaunchTests.cs b/src/PostIt/PostIt.Tests/AndroidAppLaunchTests.cs index 25630c83..d4980d26 100644 --- a/src/PostIt/PostIt.Tests/AndroidAppLaunchTests.cs +++ b/src/PostIt/PostIt.Tests/AndroidAppLaunchTests.cs @@ -12,7 +12,6 @@ namespace PostIt.Tests; /// Skip conditions: the package is not installed on the connected device, /// or no device is connected via adb. /// -[Trait("Category", "Platform-Android")] public class AndroidAppLaunchTests { private const string PackageName = "fr.pschneider.postit"; @@ -24,8 +23,8 @@ public class AndroidAppLaunchTests _output = output; } - // TODO https://twosixtech.com/blog/integrating-docker-and-adb/ - [Fact] + // https://twosixtech.com/blog/integrating-docker-and-adb/ + // FIXME ala hosted shared resource adb server - [Fact] public void PostIt_starts_and_draws_a_first_frame_on_the_emulator() { if (!IsPackageInstalledOnAnyDevice()) diff --git a/src/Yavsc.Abstract/Authentication/RegisterModel.cs b/src/Yavsc.Abstract/Authentication/RegisterModel.cs index 3bf9876b..2ebb3297 100644 --- a/src/Yavsc.Abstract/Authentication/RegisterModel.cs +++ b/src/Yavsc.Abstract/Authentication/RegisterModel.cs @@ -12,8 +12,8 @@ namespace Yavsc.ViewModels.Account public string UserName { get; set; } [Required()] - [StringLength(maximumLength: 102, MinimumLength = 5)] - [EmailAddress(ErrorMessage = "L'adresse e-mail n'est pas valide.")] + [StringLength( maximumLength:102, MinimumLength = 5)] + // [EmailAddress] [Display(Name = "Email", Description = "E-Mail")] public string Email { get; set; } diff --git a/src/Yavsc.Org.Tests/NonRegression/EMailling.cs b/src/Yavsc.Org.Tests/NonRegression/EMailling.cs index fd1fe501..5b1b33e9 100644 --- a/src/Yavsc.Org.Tests/NonRegression/EMailling.cs +++ b/src/Yavsc.Org.Tests/NonRegression/EMailling.cs @@ -1,19 +1,8 @@ -using System.ComponentModel.DataAnnotations; -using System.Globalization; -using MailKit.Net.Smtp; using Microsoft.Extensions.DependencyInjection; -using Microsoft.Extensions.Localization; using Microsoft.Extensions.Logging; -using Microsoft.Extensions.Logging.Abstractions; -using Microsoft.Extensions.Options; -using MimeKit; using Yavsc.Interface; using Yavsc.Interfaces; -using Yavsc.Models.Relationship; using Yavsc.Org.Tests.Fakes; -using Yavsc.Services; -using Yavsc.Settings; -using Yavsc.ViewModels.Account; namespace Yavsc.Org.Tests { @@ -67,96 +56,5 @@ namespace Yavsc.Org.Tests Assert.Equal(_serverFixture.SiteSettings.Owner.EMail, client.LastSentMessage?.To.Mailboxes.First().Address); } - [Fact] - public void RegisterModel_rejects_invalid_email_format() - { - var model = new RegisterModel - { - UserName = "alice", - Email = "this is not an email", - Password = "Password123!", - ConfirmPassword = "Password123!" - }; - - var results = new List(); - var valid = Validator.TryValidateObject( - model, - new ValidationContext(model), - results, - validateAllProperties: true); - - Assert.False(valid); - Assert.Contains(results, r => r.MemberNames.Contains(nameof(RegisterModel.Email))); - } - - [Fact] - public async Task SendEmailAsync_ignores_smtp_recipient_rejection() - { - var sender = new MailSender( - Options.Create(new SiteSettings - { - Title = "Test", - Authority = "example.com", - Owner = new StaticContact { Name = "Test Owner", EMail = "owner@example.com" } - }), - Options.Create(new SmtpSettings - { - Host = "smtp.test.local", - Port = 465, - UserName = "test-user", - Password = "secret" - }), - NullLoggerFactory.Instance, - new TestStringLocalizer(), - new RejectingSmtpClientFactory()); - - var result = await sender.SendEmailAsync( - "Alice", - "contact@pschneider.fr", - "Welcome", - "hello"); - - Assert.Equal(string.Empty, result); - } - - private sealed class RejectingSmtpClientFactory : ISmtpClientFactory - { - public Yavsc.Interfaces.ISmtpClient CreateClient() => new RejectingSmtpClient(); - } - - private sealed class RejectingSmtpClient : Yavsc.Interfaces.ISmtpClient - { - public int Timeout { get; set; } - public void Connect(string host, int port, MailKit.Security.SecureSocketOptions options) { } - public void Authenticate(string userName, string password) { } - public Task SendAsync(MimeMessage message, CancellationToken cancellationToken = default) - { - throw new SmtpCommandException( - SmtpErrorCode.RecipientNotAccepted, - SmtpStatusCode.MailboxUnavailable, - "Recipient address rejected: User unknown in local recipient table"); - } - public void Disconnect(bool quit) { } - public void Dispose() { } - } - - private sealed class TestStringLocalizer : IStringLocalizer - { - public LocalizedString this[string name] => new(name, name); - public LocalizedString this[string name, params object[] arguments] => new(name, string.Format(CultureInfo.InvariantCulture, name, arguments)); - - public IEnumerable GetAllStrings(bool includeParentCultures) - => Enumerable.Empty(); - - public LocalizedString GetString(string name) - => new(name, name); - - public LocalizedString GetString(string name, params object[] arguments) - => new(name, string.Format(CultureInfo.InvariantCulture, name, arguments)); - - public IStringLocalizer WithCulture(CultureInfo culture) - => this; - } - } } diff --git a/src/Yavsc.Org/Controllers/Accounting/AccountController.cs b/src/Yavsc.Org/Controllers/Accounting/AccountController.cs index 05cb55b5..c562736d 100644 --- a/src/Yavsc.Org/Controllers/Accounting/AccountController.cs +++ b/src/Yavsc.Org/Controllers/Accounting/AccountController.cs @@ -564,8 +564,6 @@ IHtmlLocalizerFactory htmlLocalizerFactory, [ValidateAntiForgeryToken] public async Task Register(RegisterModel model) { - model.Email = model.Email?.Trim(); - if (ModelState.IsValid) { var user = new ApplicationUser { UserName = model.UserName, Email = model.Email }; diff --git a/src/Yavsc.Server/Services/MailSender.cs b/src/Yavsc.Server/Services/MailSender.cs index 592a43ba..d8b3c46c 100644 --- a/src/Yavsc.Server/Services/MailSender.cs +++ b/src/Yavsc.Server/Services/MailSender.cs @@ -1,4 +1,3 @@ -using MailKit.Net.Smtp; using MailKit.Security; using Microsoft.Extensions.Logging; using Microsoft.Extensions.Options; @@ -115,7 +114,7 @@ namespace Yavsc.Services msg.MessageId = MimeKit.Utils.MimeUtils.GenerateMessageId( siteSettings.Authority ); - using Yavsc.Interfaces.ISmtpClient sc = _smtpClientFactory.CreateClient(); + using ISmtpClient sc = _smtpClientFactory.CreateClient(); { sc.Timeout = 30000; sc.Connect( @@ -140,11 +139,6 @@ namespace Yavsc.Services logger.LogError(ex, "Refusing to send email because the recipient or sender address is malformed. To={To}, From={From}", email, siteSettings.Owner.EMail); return string.Empty; } - catch (SmtpCommandException ex) - { - logger.LogError(ex, "SMTP rejected the recipient or sender address. To={To}, Subject={Subject}, Status={Status}, Error={Error}", email, subject, ex.StatusCode, ex.Message); - return string.Empty; - } catch (Exception ex) { logger.LogError(ex, "Failed to send email. To={To}, Subject={Subject}", email, subject);