@@ -2621,3 +2621,33 @@ def test_supported_file_upload(client):
26212621 resp .json ["detail" ]
26222622 == f"Unsupported file type detected: { spoof_name } . Please remove the file or try compressing it into a ZIP file before uploading."
26232623 )
2624+
2625+
2626+ def test_locked_project (client , diff_project ):
2627+ """Users cannot push to the locked project. Moreover, it does not count to the storage and project count67"""
2628+ # before project is locked
2629+ orig_p_count = diff_project .workspace .project_count ()
2630+ orig_storage = diff_project .workspace .disk_usage ()
2631+ # after locking the project
2632+ diff_project .locked_until = datetime .datetime .utcnow () + datetime .timedelta (
2633+ weeks = 26
2634+ )
2635+ db .session .commit ()
2636+ assert diff_project .workspace .project_count () == orig_p_count - 1
2637+ assert diff_project .workspace .disk_usage () == orig_storage - diff_project .disk_usage
2638+ # push is not possible to the locked project
2639+ changes = _get_changes_without_added (test_project_dir )
2640+ project_path = get_project_path (diff_project )
2641+ data = {"version" : "v1" , "changes" : changes }
2642+ resp = client .post (
2643+ f"/v1/project/push/{ project_path } " ,
2644+ data = json .dumps (data , cls = DateTimeEncoder ).encode ("utf-8" ),
2645+ headers = json_headers ,
2646+ )
2647+ assert resp .status_code == 423
2648+ # to play safe push finish is also blocked
2649+ upload , upload_dir = create_transaction ("mergin" , changes )
2650+ url = "/v1/project/push/finish/{}" .format (upload .id )
2651+
2652+ resp = client .post (url , headers = json_headers )
2653+ assert resp .status_code == 423
0 commit comments