Skip to content

Commit 1d8a989

Browse files
authored
Merge pull request #536 from SCCapstone/main
528: Deploy landing page
2 parents 98349d8 + 3572a1e commit 1d8a989

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

60 files changed

+1369
-1088
lines changed

FU.API/FU.API.Tests/AccountServiceTests.cs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -48,7 +48,7 @@ public void Dispose()
4848
public async void CreateUser_WithValidCredentials_ReturnsUser()
4949
{
5050
// Arange
51-
Credentials credentials = new() { Username = "Test", Password = "Test" };
51+
Credentials credentials = new() { Username = "Test", Password = "Test12345" };
5252

5353
// Act
5454
ApplicationUser user = await _accountsService.Register(credentials);
@@ -62,7 +62,7 @@ public async void CreateUser_WithValidCredentials_ReturnsUser()
6262
public async void ChangeUsername_WithValidUsername_ChangesUsername()
6363
{
6464
// Arange
65-
Credentials credentials = new() { Username = "Username1", Password = "Test" };
65+
Credentials credentials = new() { Username = "Username1", Password = "Test12345" };
6666
string newUsername = "Username2";
6767
ApplicationUser user = await _accountsService.Register(credentials);
6868

FU.API/FU.API.Tests/PostServiceTests.cs

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -137,7 +137,7 @@ public async void GetPostUsers_WithMultipleUsers_ReturnsCorrectUserCount()
137137
// Arrange
138138
// Note: CreateTestPostAsync creates one user as part of creating a post
139139
Post post = await TestsHelper.CreateTestPostAsync(_dbContext);
140-
var user2 = await TestsHelper.CreateUserAsync(_dbContext, new Credentials() { Username = "user2", Password = "pass2", Email = "[email protected]" });
140+
var user2 = await TestsHelper.CreateUserAsync(_dbContext, new Credentials() { Username = "user2", Password = "Test12345", Email = "[email protected]" });
141141
await _postService.JoinPost(post.Id, user2);
142142

143143
// Act
@@ -166,7 +166,7 @@ public async void JoinPost_WhenAlreadyMember_ThrowsConflictException()
166166
{
167167
// Arrange
168168
Post post = await TestsHelper.CreateTestPostAsync(_dbContext);
169-
var user2 = await TestsHelper.CreateUserAsync(_dbContext, new Credentials() { Username = "user2", Password = "pass2", Email = "[email protected]" });
169+
var user2 = await TestsHelper.CreateUserAsync(_dbContext, new Credentials() { Username = "user2", Password = "Test12345", Email = "[email protected]" });
170170
await _postService.JoinPost(post.Id, user2);
171171

172172
// Act & Assert
@@ -180,7 +180,7 @@ public async void LeavePost_WhenMember_LeavesPost()
180180
{
181181
// Arrange
182182
Post post = await TestsHelper.CreateTestPostAsync(_dbContext);
183-
var user2 = await TestsHelper.CreateUserAsync(_dbContext, new Credentials() { Username = "user2", Password = "pass2", Email = "[email protected]" });
183+
var user2 = await TestsHelper.CreateUserAsync(_dbContext, new Credentials() { Username = "user2", Password = "Test12345", Email = "[email protected]" });
184184
await _postService.JoinPost(post.Id, user2);
185185

186186
// Act

FU.API/FU.API.Tests/SearchServiceSearchPostsTests.cs

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -159,7 +159,7 @@ public async Task Search_WithSearchStartDate_FiltersOne()
159159
// Act
160160
(List<Post> posts, var totalResults) = await _searchService.SearchPosts(new PostQuery()
161161
{
162-
StartOnOrAfterDate = searchDate,
162+
StartOnOrAfterDateTime = searchDate.ToDateTime(new TimeOnly(1, 1, 1)),
163163
});
164164

165165
// Assert
@@ -196,7 +196,7 @@ public async Task Search_WithSearchEndDateDate_FiltersOne()
196196
// Act
197197
(List<Post> posts, var totalResults) = await _searchService.SearchPosts(new PostQuery()
198198
{
199-
EndOnOrBeforeDate = searchDate,
199+
EndOnOrBeforeDateTime = searchDate.ToDateTime(new TimeOnly(1, 1, 1)),
200200
});
201201

202202
// Assert
@@ -232,7 +232,7 @@ public async Task Search_WithSearchDateAsToday_SearchesAfterNow()
232232
// Act
233233
(List<Post> posts, var totalResults) = await _searchService.SearchPosts(new PostQuery()
234234
{
235-
StartOnOrAfterDate = DateOnly.FromDateTime(DateTime.UtcNow),
235+
StartOnOrAfterDateTime = DateTime.UtcNow,
236236
});
237237

238238
// Assert

FU.API/FU.API.Tests/SearchServiceSearchUsersTests.cs

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -56,19 +56,19 @@ public async Task Search_WithKeyword_SearchesTitleAndBio()
5656
{
5757
Username = "User1",
5858
Email = "[email protected]",
59-
Password = "Pass1"
59+
Password = "Test12345"
6060
});
6161
var user2 = await TestsHelper.CreateUserAsync(_dbContext, new Credentials()
6262
{
6363
Username = "User2",
6464
Email = "[email protected]",
65-
Password = "Pass2"
65+
Password = "Test12345"
6666
});
6767
var user3 = await TestsHelper.CreateUserAsync(_dbContext, new Credentials()
6868
{
6969
Username = "User3",
7070
Email = "[email protected]",
71-
Password = "Pass3"
71+
Password = "Test12345"
7272
});
7373
await _userService.UpdateUserProfile(new UserProfile() { Bio = "Bio3", Id = user3.UserId });
7474

FU.API/FU.API.Tests/TestsHelper.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@ public static async Task<Game> CreateTestGameAsync(AppDbContext dbContext)
1717

1818
public static async Task<ApplicationUser> CreateUserAsync(AppDbContext context)
1919
{
20-
Credentials credentials = new() { Username = "Test", Password = "Test", Email = "[email protected]" };
20+
Credentials credentials = new() { Username = "Test", Password = "Test12345", Email = "[email protected]" };
2121
return await CreateUserAsync(context, credentials);
2222
}
2323

FU.API/FU.API/.dockerignore

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
bin/
2+
obj/
3+
Dockerfile
4+
docker-compose.yml
5+
README.md
6+
.env

FU.API/FU.API/Controllers/UsersController.cs

Lines changed: 25 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -18,11 +18,13 @@ public class UsersController : ControllerBase
1818
{
1919
private readonly IUserService _userService;
2020
private readonly ISearchService _searchService;
21+
private readonly IStorageService _storageService;
2122

22-
public UsersController(IUserService userService, ISearchService searchService)
23+
public UsersController(IUserService userService, ISearchService searchService, IStorageService storageService)
2324
{
2425
_userService = userService;
2526
_searchService = searchService;
27+
_storageService = storageService;
2628
}
2729

2830
[HttpGet]
@@ -74,7 +76,28 @@ public async Task<IActionResult> UpdateProfile([FromBody] UserProfile profileCha
7476
// Overrides any client given id that may differ from userId.
7577
profileChanges.Id = userId;
7678

77-
var newProfile = await _userService.UpdateUserProfile(profileChanges);
79+
// Make sure its an image already in our blob storage
80+
// Otherwise we are unure if the image is cropped, resized, and in the right format
81+
if (profileChanges?.PfpUrl is not null)
82+
{
83+
Uri avatarUri;
84+
85+
try
86+
{
87+
avatarUri = new(profileChanges.PfpUrl);
88+
}
89+
catch (UriFormatException)
90+
{
91+
throw new UnprocessableException("Invalid avatar url format.");
92+
}
93+
94+
if (!(await _storageService.IsInStorageAsync(avatarUri)))
95+
{
96+
throw new UnprocessableException("Invalid profile picture. The image must be uploaded to our storage system");
97+
}
98+
}
99+
100+
var newProfile = await _userService.UpdateUserProfile(profileChanges!);
78101

79102
return Ok(newProfile);
80103
}

FU.API/FU.API/DTOs/Search/PostSearchRequestDTO.cs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -11,10 +11,10 @@ public record PostSearchRequestDTO
1111
public string? Games { get; set; }
1212

1313
[FromQuery]
14-
public DateOnly? StartOnOrAfterDate { get; set; }
14+
public DateTime? StartOnOrAfterDateTime { get; set; }
1515

1616
[FromQuery]
17-
public DateOnly? EndOnOrBeforeDate { get; set; }
17+
public DateTime? EndOnOrBeforeDateTime { get; set; }
1818

1919
[FromQuery]
2020
public TimeOnly? StartOnOrAfterTime { get; set; }

FU.API/FU.API/Dockerfile

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
# https://hub.docker.com/_/microsoft-dotnet
2+
FROM mcr.microsoft.com/dotnet/sdk:7.0 AS build
3+
4+
# copy everything and build app
5+
WORKDIR /source
6+
COPY . .
7+
RUN mkdir /app
8+
RUN dotnet publish -o /app
9+
10+
# final stage/image
11+
FROM mcr.microsoft.com/dotnet/aspnet:7.0
12+
WORKDIR /app
13+
COPY --from=build /app ./
14+
ENTRYPOINT ["dotnet", "FU.API.dll"]
15+

FU.API/FU.API/FU.API.csproj

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,7 @@
2525
<IncludeAssets>runtime; build; native; contentfiles; analyzers; buildtransitive</IncludeAssets>
2626
</PackageReference>
2727
<PackageReference Include="Npgsql.EntityFrameworkCore.PostgreSQL" Version="7.0.11" />
28-
<PackageReference Include="SkiaSharp.NativeAssets.Linux" Version="2.88.7" />
28+
<PackageReference Include="SkiaSharp.NativeAssets.Linux.NoDependencies" Version="2.88.7" />
2929
<PackageReference Include="StyleCop.Analyzers" Version="1.1.118">
3030
<PrivateAssets>all</PrivateAssets>
3131
<IncludeAssets>runtime; build; native; contentfiles; analyzers; buildtransitive</IncludeAssets>

0 commit comments

Comments
 (0)