From 1b085f06111c2f95f91b487ce33990a88d44d3d5 Mon Sep 17 00:00:00 2001 From: Neelam Kumari Date: Mon, 11 May 2026 23:07:06 +0530 Subject: [PATCH 1/6] Implemented goal icon support in backend API --- CommBank-Server/Controllers/GoalController.cs | 17 +++++++++++++++++ CommBank-Server/Models/Goal.cs | 2 ++ CommBank-Server/Secrets.json | 2 +- 3 files changed, 20 insertions(+), 1 deletion(-) diff --git a/CommBank-Server/Controllers/GoalController.cs b/CommBank-Server/Controllers/GoalController.cs index 98271a5f..f8a27a71 100644 --- a/CommBank-Server/Controllers/GoalController.cs +++ b/CommBank-Server/Controllers/GoalController.cs @@ -85,6 +85,23 @@ public async Task Update(string id, Goal updatedGoal) return NoContent(); } + [HttpPut("{id:length(24)}/icon")] + public async Task UpdateIcon(string id, [FromBody] UpdatedIcon updatedIcon) + { + var goal = await _goalsService.GetAsync(id); + + if (goal is null) + { + return NotFound(); + } + + goal.Icon = updatedIcon.Icon; + + await _goalsService.UpdateAsync(id, goal); + + return NoContent(); + } + [HttpDelete("{id:length(24)}")] public async Task Delete(string id) { diff --git a/CommBank-Server/Models/Goal.cs b/CommBank-Server/Models/Goal.cs index 77ff1ad5..20b9b5d4 100644 --- a/CommBank-Server/Models/Goal.cs +++ b/CommBank-Server/Models/Goal.cs @@ -27,4 +27,6 @@ public class Goal [BsonRepresentation(BsonType.ObjectId)] public string? UserId { get; set; } + + public string? Icon { get; set; } } \ No newline at end of file diff --git a/CommBank-Server/Secrets.json b/CommBank-Server/Secrets.json index 0e5bf949..e0596e3c 100644 --- a/CommBank-Server/Secrets.json +++ b/CommBank-Server/Secrets.json @@ -1,5 +1,5 @@ { "ConnectionStrings": { - "CommBank": "{CONNECTION_STRING}" + "CommBank": "mongodb+srv://Neelam:7QbS4PmjCAcKdqcw@cluster0.8bwg7vk.mongodb.net/CommBank" } } \ No newline at end of file From c14f32d6cd89ac70b910b808e2e2312d8ff6ceb3 Mon Sep 17 00:00:00 2001 From: Neelam Kumari Date: Tue, 12 May 2026 00:33:08 +0530 Subject: [PATCH 2/6] Added unit tests for GetGoalsForUser route --- CommBank.Tests/Fake/FakeCollections.cs | 9 ++++++--- CommBank.Tests/Fake/FakeGoalsService.cs | 2 +- CommBank.Tests/GoalControllerTests.cs | 21 +++++++++++++++++++-- 3 files changed, 26 insertions(+), 6 deletions(-) diff --git a/CommBank.Tests/Fake/FakeCollections.cs b/CommBank.Tests/Fake/FakeCollections.cs index 28452832..b40ddf7b 100644 --- a/CommBank.Tests/Fake/FakeCollections.cs +++ b/CommBank.Tests/Fake/FakeCollections.cs @@ -33,19 +33,22 @@ public FakeCollections() new() { Id = "1", - Name = "House Down Payment" + Name = "House Down Payment", + UserId = "1" }, new() { Id = "2", - Name = "Tesla Model Y" + Name = "Tesla Model Y", + UserId = "1" }, new() { Id = "3", - Name = "Trip to London" + Name = "Trip to London", + UserId = "2" }, }; diff --git a/CommBank.Tests/Fake/FakeGoalsService.cs b/CommBank.Tests/Fake/FakeGoalsService.cs index 643a27e6..603ec2a0 100644 --- a/CommBank.Tests/Fake/FakeGoalsService.cs +++ b/CommBank.Tests/Fake/FakeGoalsService.cs @@ -19,7 +19,7 @@ public async Task> GetAsync() => await Task.FromResult(_goals); public async Task?> GetForUserAsync(string id) => - await Task.FromResult(_goals); + await Task.FromResult(_goals.Where(g => g.UserId == id).ToList()); public async Task GetAsync(string id) => await Task.FromResult(_goal); diff --git a/CommBank.Tests/GoalControllerTests.cs b/CommBank.Tests/GoalControllerTests.cs index 8380181f..7466d991 100644 --- a/CommBank.Tests/GoalControllerTests.cs +++ b/CommBank.Tests/GoalControllerTests.cs @@ -66,9 +66,26 @@ public async void Get() public async void GetForUser() { // Arrange - + var goals = collections.GetGoals(); + var users = collections.GetUsers(); + IGoalsService goalsService = new FakeGoalsService(goals, goals[0]); + IUsersService usersService = new FakeUsersService(users, users[0]); + GoalController controller = new(goalsService, usersService); + // Act - + var httpContext = new Microsoft.AspNetCore.Http.DefaultHttpContext(); + controller.ControllerContext.HttpContext = httpContext; + var result = await controller.GetForUser(goals[0].UserId!); + // Assert + Assert.NotNull(result); + + var index = 0; + foreach (Goal goal in result!) + { + Assert.IsAssignableFrom(goal); + Assert.Equal(goals[0].UserId, goal.UserId); + index++; + } } } \ No newline at end of file From 44482da363a72e216a1ba54cacd01c0ac86a2893 Mon Sep 17 00:00:00 2001 From: Neelam Kumari Date: Tue, 12 May 2026 00:50:10 +0530 Subject: [PATCH 3/6] remove-hardcoded-secrets --- .gitignore | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/.gitignore b/.gitignore index 67697151..eab8877e 100644 --- a/.gitignore +++ b/.gitignore @@ -405,3 +405,8 @@ ASALocalRun/ .localhistory/ +.env + +Secrets.json + + From bded0080ed32401063171d056844560c6ba118ba Mon Sep 17 00:00:00 2001 From: Neelam Kumari Date: Tue, 12 May 2026 01:00:42 +0530 Subject: [PATCH 4/6] correction --- .gitignore | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/.gitignore b/.gitignore index eab8877e..0bc33115 100644 --- a/.gitignore +++ b/.gitignore @@ -406,7 +406,14 @@ ASALocalRun/ .env +.env.local +.env.*.local Secrets.json +# Test/Mock Data Files +getAll.json +getId.json +getId_withIcon.json + From 2a2923c08aa6e1727c80e690ee6bfb51be8105c2 Mon Sep 17 00:00:00 2001 From: Neelam Kumari Date: Tue, 12 May 2026 01:09:39 +0530 Subject: [PATCH 5/6] Removed secret file from tracking --- CommBank-Server/Secrets.json | 5 ----- 1 file changed, 5 deletions(-) delete mode 100644 CommBank-Server/Secrets.json diff --git a/CommBank-Server/Secrets.json b/CommBank-Server/Secrets.json deleted file mode 100644 index e0596e3c..00000000 --- a/CommBank-Server/Secrets.json +++ /dev/null @@ -1,5 +0,0 @@ -{ - "ConnectionStrings": { - "CommBank": "mongodb+srv://Neelam:7QbS4PmjCAcKdqcw@cluster0.8bwg7vk.mongodb.net/CommBank" - } -} \ No newline at end of file From eb1febc5e8c03c10544971e20f5e19c5747193d2 Mon Sep 17 00:00:00 2001 From: Neelam Kumari Date: Tue, 12 May 2026 01:57:18 +0530 Subject: [PATCH 6/6] Remove comment and add .DS_Store to .gitignore --- .gitignore | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.gitignore b/.gitignore index 0bc33115..49302c74 100644 --- a/.gitignore +++ b/.gitignore @@ -16,7 +16,7 @@ test-results/ *.app # content below from: https://github.com/github/gitignore/blob/main/Global/macOS.gitignore -# General + .DS_Store .AppleDouble .LSOverride