@@ -1068,6 +1068,7 @@ def test_create_organization_custom_type(self):
10681068
10691069
10701070@pytest .mark .usefixtures ("clean_db" , "with_request_context" )
1071+ @pytest .mark .ckan_config ("ckan.auth.create_user_via_web" , True )
10711072class TestUserCreate (object ):
10721073 def test_user_create_with_password_hash (self ):
10731074 sysadmin = factories .Sysadmin ()
@@ -1381,6 +1382,7 @@ def test_create_user_not_found(self):
13811382
13821383
13831384@pytest .mark .usefixtures ("clean_db" )
1385+ @pytest .mark .ckan_config ("ckan.auth.create_user_via_web" , True )
13841386class TestUserPluginExtras (object ):
13851387
13861388 def test_stored_on_create_if_sysadmin (self ):
@@ -1479,7 +1481,7 @@ def test_external_picture(self):
14791481 user_dict ["image_display_url" ] == "https://example.com/mypic.png"
14801482 )
14811483
1482- def test_upload_non_picture_works_without_extra_config (
1484+ def test_upload_non_picture_not_works_without_extra_config (
14831485 self , create_with_upload ):
14841486 params = {
14851487 "name" : "test_user_1" ,
@@ -1488,7 +1490,35 @@ def test_upload_non_picture_works_without_extra_config(
14881490 "action" : "user_create" ,
14891491 "upload_field_name" : "image_upload" ,
14901492 }
1491- assert create_with_upload ("hello world" , "file.txt" , ** params )
1493+ with pytest .raises (
1494+ logic .ValidationError , match = "Unsupported upload type" ):
1495+ assert create_with_upload ("hello world" , "file.txt" , ** params )
1496+
1497+ def test_upload_svg_fails_without_extra_config (
1498+ self , create_with_upload ):
1499+ params = {
1500+ "name" : "test_user_1" ,
1501+ 1502+ "password" : "12345678" ,
1503+ "action" : "user_create" ,
1504+ "upload_field_name" : "image_upload" ,
1505+ }
1506+ with pytest .raises (
1507+ logic .ValidationError , match = "Unsupported upload type" ):
1508+ create_with_upload ('<svg xmlns="http://www.w3.org/2000/svg"></svg>' , "file.svg" , ** params )
1509+
1510+ def test_upload_svg_wrong_extension_fails_without_extra_config (
1511+ self , create_with_upload ):
1512+ params = {
1513+ "name" : "test_user_1" ,
1514+ 1515+ "password" : "12345678" ,
1516+ "action" : "user_create" ,
1517+ "upload_field_name" : "image_upload" ,
1518+ }
1519+ with pytest .raises (
1520+ logic .ValidationError , match = "Unsupported upload type" ):
1521+ create_with_upload ('<svg xmlns="http://www.w3.org/2000/svg"></svg>' , "file.png" , ** params )
14921522
14931523 @pytest .mark .ckan_config ("ckan.upload.user.types" , "image" )
14941524 def test_upload_non_picture (self , create_with_upload ):
@@ -1517,7 +1547,6 @@ def test_upload_non_picture_with_png_extension(
15171547 logic .ValidationError , match = "Unsupported upload type" ):
15181548 create_with_upload ("hello world" , "file.png" , ** params )
15191549
1520- @pytest .mark .ckan_config ("ckan.upload.user.types" , "image" )
15211550 def test_upload_picture (self , create_with_upload ):
15221551 params = {
15231552 "name" : "test_user_1" ,
0 commit comments