X-Git-Url: https://git.arvados.org/arvados.git/blobdiff_plain/fea63ac8216b2a15101bc75cd02586d934897160..22e5442051df04f9e0d74b21bd36e44a6464e945:/services/api/test/unit/group_test.rb?ds=sidebyside diff --git a/services/api/test/unit/group_test.rb b/services/api/test/unit/group_test.rb index 892086b199..24d7333ab5 100644 --- a/services/api/test/unit/group_test.rb +++ b/services/api/test/unit/group_test.rb @@ -203,6 +203,13 @@ class GroupTest < ActiveSupport::TestCase col = collections(:collection_in_trashed_subproject) job = jobs(:job_in_trashed_project) cr = container_requests(:cr_in_trashed_project) + # Save how many objects were before the sweep + user_nr_was = User.all.length + coll_nr_was = Collection.all.length + group_nr_was = Group.where('group_class<>?', 'project').length + project_nr_was = Group.where(group_class: 'project').length + cr_nr_was = ContainerRequest.all.length + job_nr_was = Job.all.length assert_not_empty Group.where(uuid: g_foo.uuid) assert_not_empty Group.where(uuid: g_bar.uuid) assert_not_empty Group.where(uuid: g_baz.uuid) @@ -216,5 +223,37 @@ class GroupTest < ActiveSupport::TestCase assert_empty Collection.where(uuid: col.uuid) assert_empty Job.where(uuid: job.uuid) assert_empty ContainerRequest.where(uuid: cr.uuid) + # No unwanted deletions should have happened + assert_equal user_nr_was, User.all.length + assert_equal coll_nr_was-2, # collection_in_trashed_subproject + Collection.all.length # & deleted_on_next_sweep collections + assert_equal group_nr_was, Group.where('group_class<>?', 'project').length + assert_equal project_nr_was-3, Group.where(group_class: 'project').length + assert_equal cr_nr_was-1, ContainerRequest.all.length + assert_equal job_nr_was-1, Job.all.length + end + + test "project names must be displayable in a filesystem" do + set_user_from_auth :active + ["", "{SOLIDUS}"].each do |subst| + Rails.configuration.Collections.ForwardSlashNameSubstitution = subst + g = Group.create + [[nil, true], + ["", true], + [".", false], + ["..", false], + ["...", true], + ["..z..", true], + ["foo/bar", subst != ""], + ["../..", subst != ""], + ["/", subst != ""], + ].each do |name, valid| + g.name = name + g.group_class = "role" + assert_equal true, g.valid? + g.group_class = "project" + assert_equal valid, g.valid?, "#{name.inspect} should be #{valid ? "valid" : "invalid"}" + end + end end end