@@ -1572,6 +1572,75 @@ public async Task TestPatchPackage_FailsIfCreatorDoesNotMatchHostUsername()
15721572 Assert . Contains ( "At least one difficulty has a specified creator that isn't the beatmap host's username." , ( await response . Content . ReadFromJsonAsync < ErrorResponse > ( ) ) ! . Error ) ;
15731573 }
15741574
1575+ [ Theory ]
1576+ [ InlineData ( 0 , 0.3 , true ) ]
1577+ [ InlineData ( 0 , 10 , true ) ]
1578+ [ InlineData ( 3 , 2 , true ) ]
1579+ [ InlineData ( 3 , 7.5 , false ) ]
1580+ [ InlineData ( 3 , 18 , true ) ]
1581+ public async Task TestPatchPackage_FailsOnIncorrectCircleSize ( short playmode , float circleSize , bool shouldSucceed )
1582+ {
1583+ using var db = await DatabaseAccess . GetConnectionAsync ( ) ;
1584+ await db . ExecuteAsync ( "INSERT INTO `phpbb_users` (`user_id`, `username`, `username_clean`, `country_acronym`, `user_permissions`, `user_sig`, `user_occ`, `user_interests`) VALUES (1000, 'test', 'test', 'JP', '', '', '', '')" ) ;
1585+
1586+ await db . ExecuteAsync ( @"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)" ) ;
1587+
1588+ foreach ( uint beatmapId in new uint [ ] { 557815 , 557814 , 557821 , 557816 , 557817 , 557818 , 557812 , 557810 , 557811 , 557820 , 557813 , 557819 } )
1589+ await db . ExecuteAsync ( @"INSERT INTO `osu_beatmaps` (`beatmap_id`, `user_id`, `beatmapset_id`, `approved`) VALUES (@beatmapId, 1000, 241526, -1)" , new { beatmapId = beatmapId } ) ;
1590+
1591+ using ( var dstStream = File . OpenWrite ( Path . Combine ( beatmapStorage . BaseDirectory , "241526" ) ) )
1592+ using ( var srcStream = TestResources . GetResource ( osz_filename ) ! )
1593+ await srcStream . CopyToAsync ( dstStream ) ;
1594+ await db . ExecuteAsync ( @"INSERT INTO `beatmapset_versions` (`beatmapset_id`) VALUES (241526)" ) ;
1595+
1596+ var request = new HttpRequestMessage ( HttpMethod . Patch , "/beatmapsets/241526" ) ;
1597+
1598+ using var content = new MultipartFormDataContent ( $ "{ Guid . NewGuid ( ) } ----") ;
1599+ content . Add ( new StringContent (
1600+ $ """
1601+ osu file format v14
1602+
1603+ [General]
1604+ Mode:{ playmode }
1605+
1606+ [Metadata]
1607+ Title:Renatus
1608+ TitleUnicode:Renatus
1609+ Artist:Soleily
1610+ ArtistUnicode:Soleily
1611+ Creator:test
1612+ Version:Platter 2
1613+ Source:
1614+ Tags:MBC7 Unisphere 地球ヤバイEP Chikyu Yabai
1615+ BeatmapID:557810
1616+ BeatmapSetID:241526
1617+
1618+ [Difficulty]
1619+ HPDrainRate:5
1620+ CircleSize:{ circleSize }
1621+ OverallDifficulty:8
1622+ ApproachRate:8
1623+ SliderMultiplier:1.75
1624+ SliderTickRate:2
1625+ """
1626+ ) , "filesChanged" , osu_filename ) ;
1627+ content . Add ( new StringContent ( "Soleily - Renatus (test) [Platter].osu" ) , "filesDeleted" ) ;
1628+ request . Content = content ;
1629+ request . Headers . Add ( HeaderBasedAuthenticationHandler . USER_ID_HEADER , "1000" ) ;
1630+
1631+ var response = await Client . SendAsync ( request ) ;
1632+
1633+ if ( shouldSucceed )
1634+ Assert . True ( response . IsSuccessStatusCode ) ;
1635+ else
1636+ {
1637+ Assert . False ( response . IsSuccessStatusCode ) ;
1638+
1639+ Assert . Contains ( playmode == 3 ? "The key count of the beatmap is invalid." : "The circle size of the beatmap is out of range." ,
1640+ ( await response . Content . ReadFromJsonAsync < ErrorResponse > ( ) ) ! . Error ) ;
1641+ }
1642+ }
1643+
15751644 [ Fact ]
15761645 public async Task TestSubmitGuestDifficulty_OldStyle ( )
15771646 {
0 commit comments