Skip to content

Commit 1642a04

Browse files
committed
wip
1 parent 99df39e commit 1642a04

File tree

1 file changed

+28
-0
lines changed

1 file changed

+28
-0
lines changed

osu.Server.BeatmapSubmission.Tests/BeatmapSubmissionControllerTest.cs

Lines changed: 28 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1049,6 +1049,34 @@ await db.ExecuteAsync(
10491049
Assert.Contains("Beatmap has invalid ID inside", (await response.Content.ReadFromJsonAsync<ErrorResponse>())!.Error);
10501050
}
10511051

1052+
[Fact]
1053+
public async Task TestUploadFullPackage_FailsIfDuplicateFilename()
1054+
{
1055+
using var db = await DatabaseAccess.GetConnectionAsync();
1056+
await db.ExecuteAsync(
1057+
"INSERT INTO `phpbb_users` (`user_id`, `username`, `username_clean`, `country_acronym`, `user_permissions`, `user_sig`, `user_occ`, `user_interests`) VALUES (1000, 'test', 'test', 'JP', '', '', '', '')");
1058+
1059+
await db.ExecuteAsync(
1060+
@"INSERT INTO `osu_beatmapsets` (`beatmapset_id`, `user_id`, `creator`, `approved`, `thread_id`, `active`, `submit_date`) VALUES (241526, 1000, 'test user', -1, 0, -1, CURRENT_TIMESTAMP)");
1061+
1062+
// A different beatmap exists with a filename from the new upload.
1063+
// Filenames should be unique globally.
1064+
await db.ExecuteAsync(@"INSERT INTO `osu_beatmaps` (`beatmap_id`, `filename`) VALUES (@beatmapId, @filename)", new { beatmapId = 123456, filename = osu_filename });
1065+
1066+
var request = new HttpRequestMessage(HttpMethod.Put, "/beatmapsets/241526");
1067+
1068+
using var content = new MultipartFormDataContent($"{Guid.NewGuid()}----");
1069+
using var stream = TestResources.GetResource(osz_filename)!;
1070+
content.Add(new StreamContent(stream), "beatmapArchive", osz_filename);
1071+
request.Content = content;
1072+
request.Headers.Add(HeaderBasedAuthenticationHandler.USER_ID_HEADER, "1000");
1073+
1074+
var response = await Client.SendAsync(request);
1075+
Assert.False(response.IsSuccessStatusCode);
1076+
Assert.Equal(HttpStatusCode.UnprocessableEntity, response.StatusCode);
1077+
Assert.Contains("Beatmap has invalid ID inside", (await response.Content.ReadFromJsonAsync<ErrorResponse>())!.Error);
1078+
}
1079+
10521080
[Theory]
10531081
[InlineData("../suspicious")]
10541082
[InlineData("..\\suspicious")]

0 commit comments

Comments
 (0)