Skip to content
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

#3076 - Add support for private blob storages #3159

Merged
merged 26 commits into from
Aug 26, 2024
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
Show all changes
26 commits
Select commit Hold shift + click to select a range
4c97eca
WIP-Update ImageUrl to a type string
Metal-Mighty Jun 27, 2024
d92c0be
wip storage as base64 images
Metal-Mighty Aug 5, 2024
c6f82fa
Finish support of images as base64 strings
Metal-Mighty Aug 12, 2024
c1734dd
WIP-Update ImageUrl to a type string
Metal-Mighty Jun 27, 2024
b2ff0f8
wip storage as base64 images
Metal-Mighty Aug 5, 2024
914ed93
Finish support of images as base64 strings
Metal-Mighty Aug 12, 2024
4e037a4
Fix unit tests build
Metal-Mighty Aug 12, 2024
cecfc27
WIP-Update ImageUrl to a type string
Metal-Mighty Jun 27, 2024
10eced0
wip storage as base64 images
Metal-Mighty Aug 5, 2024
9287758
Finish support of images as base64 strings
Metal-Mighty Aug 12, 2024
70ff8a6
WIP-Update ImageUrl to a type string
Metal-Mighty Jun 27, 2024
5509c5d
wip storage as base64 images
Metal-Mighty Aug 5, 2024
92ee9bc
Finish support of images as base64 strings
Metal-Mighty Aug 12, 2024
cb57207
Add missing file header
Metal-Mighty Aug 20, 2024
af405ac
Update commented out code for new image management
Metal-Mighty Aug 21, 2024
89481b8
Update unit tests for new model image management
Metal-Mighty Aug 21, 2024
5701622
Fix bad replace in file header
Metal-Mighty Aug 21, 2024
68b8e7e
Fix unit tests
Metal-Mighty Aug 21, 2024
265aea4
Fix unit tests and bugs
Metal-Mighty Aug 22, 2024
dcb49b0
Fix build issues after rebase
Metal-Mighty Aug 26, 2024
2d23db2
using cleanup
Metal-Mighty Aug 26, 2024
9dda953
Code quality cleanup
Metal-Mighty Aug 26, 2024
598e86f
Rename remaining `*imageUri` to `*image`
Metal-Mighty Aug 26, 2024
5f5dbe1
Code quality fixes
Metal-Mighty Aug 26, 2024
1ae2840
Remove usage of Redis
Metal-Mighty Aug 26, 2024
7af291a
Remove unused parameter
Metal-Mighty Aug 26, 2024
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Next Next commit
Fix unit tests and bugs
  • Loading branch information
Metal-Mighty committed Aug 26, 2024
commit 265aea4465d1a54894f7bcf85ab3c02d5ce097a9
Original file line number Diff line number Diff line change
@@ -1,12 +1,9 @@
@page "/edge/models/new"

@using IoTHub.Portal.Client.Dialogs.EdgeModels.EdgeModule
@using IoTHub.Portal.Models
@using IoTHub.Portal.Models.v10
@using IoTHub.Portal.Shared.Models.v10
@using IoTHub.Portal.Client.Validators
@using System.Net.Http.Headers
@using IoTHub.Portal.Models.v10
@using IoTHub.Portal.Shared.Constants

@attribute [Authorize]
Expand All @@ -25,7 +22,7 @@
<MudCardContent>
<div class="d-flex justify-center mb-4">
<MudAvatar Style="height:100px; width: auto; border-radius: 0; background: transparent">
<MudImage Src="@imageData" id="@(nameof(IoTEdgeModel.Image))" />
<MudImage Src="@imageData" id="model-image" />
</MudAvatar>
</div>
</MudCardContent>
Expand Down Expand Up @@ -94,7 +91,7 @@
<MudTextField id=@nameof(EdgeModelSystemModule.Name) @bind-Value="@sysModule.Name" Margin="Margin.Dense" Label="Module name" For="@(() => sysModule.Name )" Variant="Variant.Outlined" Disabled />
</MudTd>
<MudTd DataLabel="System module Image URI" Style="word-break: break-all;">
<MudTextField id=@nameof(EdgeModelSystemModule.Image) @bind-Value="@sysModule.Image" Margin="Margin.Dense" Label="Image" For="@(() => sysModule.Image )" Variant="Variant.Outlined" />
<MudTextField id=@($"{nameof(EdgeModelSystemModule.Name)}-image") @bind-Value="@sysModule.Image" Margin="Margin.Dense" Label="Image" For="@(() => sysModule.Image )" Variant="Variant.Outlined" />
</MudTd>
<MudTd DataLabel="See detail" Style="text-align: center;">
<MudButton Variant="Variant.Filled" id="@("editSystModuleButton_"+sysModule.Name)" OnClick="@(async () => await ShowSystemModuleDetail(sysModule))">Detail</MudButton>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@
<MudCardContent>
<div class="d-flex justify-center mb-4">
<MudAvatar Style="height:100px; width: auto; border-radius: 0; background: transparent">
<MudImage Src="@imageData" id="@(nameof(IoTEdgeModel.Image))" />
<MudImage Src="@imageData" id="model-image" />
</MudAvatar>
</div>
</MudCardContent>
Expand Down Expand Up @@ -101,7 +101,7 @@
<MudTextField id=@nameof(EdgeModelSystemModule.Name) @bind-Value="@sysModule.Name" Margin="Margin.Dense" Label="Module name" For="@(() => sysModule.Name )" Variant="Variant.Outlined" Disabled />
</MudTd>
<MudTd DataLabel="System module Image URI" Style="word-break: break-all;">
<MudTextField id=@nameof(EdgeModelSystemModule.Image) @bind-Value="@sysModule.Image" Margin="Margin.Dense" Label="Image" For="@(() => sysModule.Image)" Variant="Variant.Outlined" />
<MudTextField id=@($"{nameof(EdgeModelSystemModule.Name)}-image") @bind-Value="@sysModule.Image" Margin="Margin.Dense" Label="Image" For="@(() => sysModule.Image)" Variant="Variant.Outlined" />
</MudTd>
<MudTd DataLabel="See detail" Style="text-align: center;">
<MudButton Variant="Variant.Filled" id="@("editSystModuleButton_"+sysModule.Name)" OnClick="@(async () => await ShowSystemModuleDetail(sysModule))">Detail</MudButton>
Expand Down
Original file line number Diff line number Diff line change
@@ -1,10 +1,7 @@
@page "/edge/models"

@using IoTHub.Portal.Shared.Models.v10.Filters;
@using Microsoft.AspNetCore.Authorization
@using IoTHub.Portal.Models.v10
@using IoTHub.Portal.Client.Dialogs.EdgeModels.EdgeModule
@using Microsoft.AspNetCore.Components.WebAssembly.Authentication

@attribute [Authorize]
@inject IEdgeModelClientService EdgeModelService
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -78,6 +78,10 @@ public void ClickOnSaveShouldPostDeviceModelData()
service.SetDeviceModelModelProperties(It.IsAny<string>(), It.Is<List<DeviceProperty>>(list => list.Count.Equals(expectedProperties.Length))))
.Returns(Task.CompletedTask);

_ = this.mockDeviceModelsClientService.Setup(service =>
service.ChangeAvatarAsync(It.IsAny<string>(), It.IsAny<StringContent>()))
.Returns(Task.CompletedTask);

_ = this.mockSnackbarService.Setup(c => c.Add(It.IsAny<string>(), Severity.Success, It.IsAny<Action<SnackbarOptions>>(), It.IsAny<string>())).Returns((Snackbar)null);

// Act
Expand Down Expand Up @@ -193,6 +197,10 @@ public void ClickOnAddPropertyShouldAddNewProperty()
service.SetDeviceModelModelProperties(It.IsAny<string>(), It.Is<List<DeviceProperty>>(properties => properties.Count.Equals(1))))
.Returns(Task.CompletedTask);

_ = this.mockDeviceModelsClientService.Setup(service =>
service.ChangeAvatarAsync(It.IsAny<string>(), It.IsAny<StringContent>()))
.Returns(Task.CompletedTask);

_ = this.mockSnackbarService.Setup(c => c.Add(It.IsAny<string>(), Severity.Success, It.IsAny<Action<SnackbarOptions>>(), It.IsAny<string>())).Returns(value: null);

// Act
Expand Down Expand Up @@ -252,6 +260,10 @@ public void ClickOnRemovePropertyShouldRemoveTheProperty()
service.SetDeviceModelModelProperties(It.IsAny<string>(), It.Is<List<DeviceProperty>>(properties => properties.Count.Equals(0))))
.Returns(Task.CompletedTask);

_ = this.mockDeviceModelsClientService.Setup(service =>
service.ChangeAvatarAsync(It.IsAny<string>(), It.IsAny<StringContent>()))
.Returns(Task.CompletedTask);

_ = this.mockSnackbarService.Setup(c => c.Add(It.IsAny<string>(), Severity.Success, It.IsAny<Action<SnackbarOptions>>(), It.IsAny<string>())).Returns((Snackbar)null);

// Act
Expand Down Expand Up @@ -396,9 +408,6 @@ private DeviceModelDto SetupMockDeviceModel(DeviceProperty[] properties = null)
service.GetAvatar(this.mockModelId))
.ReturnsAsync(deviceModel.Image);

_ = this.mockDeviceModelsClientService.Setup(service =>
service.ChangeAvatarAsync(this.mockModelId, new StringContent(deviceModel.Image)));

return deviceModel;
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -247,8 +247,11 @@ public void ClickOnShowAddEdgeModuleDialogShouldShowDialog()

var editButton = cut.WaitForElement("#editButton");

cut.WaitForElement($"#{nameof(IoTEdgeModule.ModuleName)}").Change("module test");
cut.WaitForElement($"#{nameof(IoTEdgeModule.Image)}").Change("image test");
var moduleNameElement = cut.WaitForElement($"#{nameof(IoTEdgeModule.ModuleName)}");
var imageElement = cut.WaitForElement($"#{nameof(IoTEdgeModule.Image)}");

moduleNameElement.Change("module test");
imageElement.Change("image test");

editButton.Click();

Expand Down Expand Up @@ -307,7 +310,7 @@ public void ClickOnShowSystemModuleDetailShouldShowDialog()
var editEdgeAgentButton = cut.WaitForElement("#editSystModuleButton_edgeAgent");

cut.WaitForElement($"#{nameof(EdgeModelSystemModule.Name)}").Change("newTest");
cut.WaitForElement($"#{nameof(EdgeModelSystemModule.Image)}").Change("image/test");
cut.WaitForElement($"#{nameof(EdgeModelSystemModule.Name)}-image").Change("image/test");

editEdgeAgentButton.Click();

Expand All @@ -333,7 +336,7 @@ public void ClickOnShowSystemModuleDetailShouldShowDialogAndReturnIfAborted()

var editEdgeAgentButton = cut.WaitForElement("#editSystModuleButton_edgeAgent");

cut.WaitForElement($"#{nameof(EdgeModelSystemModule.Image)}").Change("image/test");
cut.WaitForElement($"#{nameof(EdgeModelSystemModule.Name)}-image").Change("image/test");

editEdgeAgentButton.Click();

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -78,6 +78,10 @@ public void ClickOnSaveChangesShouldUpdateTheData()
.Setup(c => c.Add("Edge model successfully updated.", Severity.Success, It.IsAny<Action<SnackbarOptions>>(), It.IsAny<string>()))
.Returns(value: null);

_ = this.mockEdgeModelService.Setup(service =>
service.ChangeAvatar(It.IsAny<string>(), It.IsAny<StringContent>()))
.Returns(Task.CompletedTask);

var cut = RenderComponent<EdgeModelDetailPage>(ComponentParameter.CreateParameter("ModelID", this.mockEdgeModleId));

// Act
Expand Down Expand Up @@ -120,7 +124,7 @@ public void WhenRoutesRequiredFieldEmptyClickOnSaveShouldProcessValidationError(
{
// Arrange

var edgeModel = SetupLoadEdgeModel();
var edgeModel = SetupLoadEdgeModel();

_ = this.mockSnackbarService
.Setup(c => c.Add(It.IsAny<string>(), Severity.Error, It.IsAny<Action<SnackbarOptions>>(), It.IsAny<string>()))
Expand Down Expand Up @@ -323,7 +327,7 @@ public void ClickOnShowSystemModuleDetailShouldShowDialog()
cut.WaitForAssertion(() => Assert.AreEqual(1, cut.FindAll("#editSystModuleButton_edgeAgent").Count));
var editEdgeAgentButton = cut.WaitForElement("#editSystModuleButton_edgeAgent");

cut.WaitForElement($"#{nameof(EdgeModelSystemModule.Image)}").Change("image/test");
cut.WaitForElement($"#{nameof(EdgeModelSystemModule.Name)}-image").Change("image/test");

editEdgeAgentButton.Click();

Expand Down Expand Up @@ -351,7 +355,7 @@ public void ClickOnShowSystemModuleDetailShouldShowDialogAndReturnIfAborted()
cut.WaitForAssertion(() => Assert.AreEqual(1, cut.FindAll("#editSystModuleButton_edgeAgent").Count));
var editEdgeAgentButton = cut.WaitForElement("#editSystModuleButton_edgeAgent");

cut.WaitForElement($"#{nameof(EdgeModelSystemModule.Image)}").Change("image/test");
cut.WaitForElement($"#{nameof(EdgeModelSystemModule.Name)}-image").Change("image/test");

editEdgeAgentButton.Click();

Expand All @@ -369,7 +373,7 @@ public void DeleteAvatarShouldRemoveTheImage()
// Act
var cut = RenderComponent<EdgeModelDetailPage>(ComponentParameter.CreateParameter("ModelID", this.mockEdgeModleId));

cut.WaitForAssertion(() => Assert.IsFalse(string.IsNullOrEmpty(cut.Find($"#{nameof(IoTEdgeModel.Image)}").Attributes["src"]?.Value)));
cut.WaitForAssertion(() => Assert.IsFalse(string.IsNullOrEmpty(cut.Find($"#model-image").Attributes["src"]?.Value)));

var avatar = cut.WaitForElement($"#{nameof(IoTEdgeModel.Image)}");
Assert.IsNotNull(avatar);
Expand Down Expand Up @@ -409,10 +413,6 @@ private IoTEdgeModel SetupLoadEdgeModel()
.Setup(x => x.GetAvatar(It.Is<string>(c => c.Equals(this.mockEdgeModleId, StringComparison.Ordinal))))
.ReturnsAsync(edgeModel.Image);

_ = this.mockEdgeModelService.Setup(service =>
service.ChangeAvatar(It.IsAny<string>(), It.IsAny<StringContent>())).Returns(Task.CompletedTask);


return edgeModel;
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -175,8 +175,6 @@ public async Task SyncImagesCacheControlShouldUpdateBlobsCacheControls()
BaseUri = Fixture.Create<Uri>()
};

_ = this.mockDeviceModelImageOptions.Setup(x => x.Value).Returns(mockOptions);

_ = this.mockBlobServiceClient
.Setup(x => x.GetBlobContainerClient(It.IsAny<string>()))
.Returns(this.mockBlobContainerClient.Object);
Expand Down Expand Up @@ -226,8 +224,6 @@ public async Task InitializeDefaultImageBlob()
BaseUri = Fixture.Create<Uri>()
};

_ = this.mockDeviceModelImageOptions.Setup(x => x.Value).Returns(mockOptions);

// Act
await this.deviceModelImageManager.InitializeDefaultImageBlob();

Expand Down
Loading