diff --git a/WebService.Test/v1/Controllers/DeviceModelScriptsControllerTest.cs b/WebService.Test/v1/Controllers/DeviceModelScriptsControllerTest.cs index bfe28999..893f2c4b 100644 --- a/WebService.Test/v1/Controllers/DeviceModelScriptsControllerTest.cs +++ b/WebService.Test/v1/Controllers/DeviceModelScriptsControllerTest.cs @@ -176,6 +176,9 @@ namespace WebService.Test.v1.Controllers { // Arrange var fileMock = new Mock(); + const string FILE_NAME = "test.docx"; + + fileMock.Setup(x => x.FileName).Returns(FILE_NAME); // Act & Assert Assert.Throws(() => this.target.Validate(fileMock.Object)); diff --git a/WebService/v1/Controllers/DeviceModelScriptsController.cs b/WebService/v1/Controllers/DeviceModelScriptsController.cs index 0866124b..911fe7eb 100644 --- a/WebService/v1/Controllers/DeviceModelScriptsController.cs +++ b/WebService/v1/Controllers/DeviceModelScriptsController.cs @@ -58,7 +58,7 @@ namespace Microsoft.Azure.IoTSolutions.DeviceSimulation.WebService.v1.Controller throw new BadRequestException("No data provided."); } - if (file.ContentType != TEXT_JAVASCRIPT) + if (file.ContentType != TEXT_JAVASCRIPT && !file.FileName.EndsWith(".js")) { this.log.Warn("Wrong content type provided", () => new { file.ContentType }); throw new BadRequestException("Wrong content type provided."); @@ -93,7 +93,7 @@ namespace Microsoft.Azure.IoTSolutions.DeviceSimulation.WebService.v1.Controller throw new BadRequestException("No data provided."); } - if (file.ContentType != TEXT_JAVASCRIPT) + if (file.ContentType != TEXT_JAVASCRIPT && !file.FileName.EndsWith(".js")) { this.log.Warn("Wrong content type provided", () => new { file.ContentType }); throw new BadRequestException("Wrong content type provided.");