C#Bot Release 2.6.2.0

Features

  • Added support for using remote drivers for Selenium tests.

Improvements

  • Update Serverside dependencies to their latest versions. This fixes the following security issues:
  • The EmailService now uses MailKit for sending emails as recommended by the .NET documentation.
    • In addition added a new method called SendEmailBackground that will send an email inside of a Hangfire job.
  • Added ability to configure the user credentials used for API tests.
  • Set the JWT Bearer Authority to the Server URL setting if it is not explicitly set.
  • Added a warning to the server console if an entity was not deleted when it was expected to be.
  • Added ability for the server application to run migrations against a database from the command line.
    • This can be done by calling dotnet run --mode migrate or by setting the ApplicationMode:Mode appsetting to migrate.
  • Added flag to enable data seeding in any environment. Added flag to appsettings.Development.xml to ensure it is enabled for dev builds.
    • The password for the seeded users can also be configured now.
    • These settings can be changed using the DataSeeding:DevSeedingEnabled and DataSeeding:DevAccountPassword appsettings.
  • Added setter to the groups property of serverside registration models.
  • Better distinguish errors in integration tests when creating a login token.
  • Updated clientside length validator for password fields to be 12 to match server production settings.

Resolved defects

  • Marked StatusCodes as a reserved word.
  • POST endpoints for user entities will now use the correct method.
  • Only return the ids of entities that were actually deleted when using the CrudService.
  • The entity collection bulk update callback function will now provide a list of ids instead of an incorrect list of models.
  • Fixed issue with not equal conditions on text form questions.
  • Fixed issue where a service provider was not passed to server side validators.
  • Fixed issue where an incorrect cookie name was used for XSRF validation.
  • Fixed test issue for strings that have a range validator with the same min and max value.
  • Fixed failing tests for user entities with image or file attributes.
  • Prevent batch update tests on entities with unique attribute causing failing tests.
  • Correctly URL encode username and password of test credentials in API and Selenium tests.
  • Fixed issue where validator tests would not handle multiple errors correctly.
  • Fixed failing filter test if an enum was not in the first 5 attributes of an entity.
  • Made Selenium page models use more specific XPaths to prevent incorrect selections.
  • Fixed possible infinite rerender in the useAsync hook.

Misc

  • Removed unused clientside user models.
  • Removed unused file writing utilities file.

Migration Path

Email Method Signature

With the updates to the EmailService to use MailKit, the calling signature for sending emails has changed, especially regarding attachments. For an example of sending an email on this version of C#Bot, see the following example.

var attachmentContents = new MemoryStream(Encoding.UTF8.GetBytes("The contents of the attachment"));
var email = new EmailEntity
{
	To = new[] { "alice@example.com", "bob@example.com" },
	Cc = new[] { "jack@example.com" },
	Bcc = new[] { "jill@example.com" },
	Subject = "Hello World!",
	Body = "This is the body of my message",
	Attachments = new[]
	{
		new EmailAttachment("test.txt", "text/plain", attachmentContents),
	},
};
await emailService.SendEmail(email, cancellation);
// or
emailService.SendEmailBackground(email);

In most cases using the new SendEmailBackground method is recommended over using the SendEmail method.

Swagger CLI Generation

Previously the application could generate a Swagger json file from the CLI by running dotnet run swagger. This has been changed to dotnet run --mode swagger.

1 Like