summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorHeiko Bernloehr <Heiko.Bernloehr@FreeIT.de>2017-03-11 03:26:34 +0100
committerHeiko Bernloehr <Heiko.Bernloehr@FreeIT.de>2017-03-11 03:26:34 +0100
commit53754d8ac112bbc28c68d703f1dfb6b6320f0250 (patch)
tree95a66b4529521a01930d1335fc506933947c39ce
parentc48b91be8d239eda408c21417e8014bac3350ba5 (diff)
downloadecs-53754d8ac112bbc28c68d703f1dfb6b6320f0250.tar.gz
ecs-53754d8ac112bbc28c68d703f1dfb6b6320f0250.zip
Initial test.
-rw-r--r--test/controllers/admin/participants_controller_test.rb46
-rw-r--r--test/controllers/configs_controller_test.rb8
-rw-r--r--test/controllers/events_controller_test.rb27
-rw-r--r--test/controllers/memberships_controller_test.rb35
-rw-r--r--test/controllers/messages_controller_test.rb491
-rw-r--r--test/controllers/queue_controller_test.rb26
-rw-r--r--test/controllers/subparticipants_controller_test.rb25
-rw-r--r--test/fixtures/auths.yml9
-rw-r--r--test/fixtures/communities.yml27
-rw-r--r--test/fixtures/community_messages.yml31
-rw-r--r--test/fixtures/ev_types.yml35
-rw-r--r--test/fixtures/events.yml19
-rw-r--r--test/fixtures/identities.yml43
-rw-r--r--test/fixtures/membership_messages.yml64
-rw-r--r--test/fixtures/memberships.yml52
-rw-r--r--test/fixtures/messages.yml86
-rw-r--r--test/fixtures/organizations.yml32
-rw-r--r--test/fixtures/participants.yml57
-rw-r--r--test/fixtures/ressources.yml49
-rw-r--r--test/fixtures/subparticipants.yml24
-rw-r--r--test/integration/community_messages_test.rb64
-rw-r--r--test/integration/ressource_test.rb332
-rw-r--r--test/models/auth_test.rb8
-rw-r--r--test/models/community_message_test.rb26
-rw-r--r--test/models/community_test.rb26
-rw-r--r--test/models/event_test.rb55
-rw-r--r--test/models/helpers/admin/communities_helper_test.rb22
-rw-r--r--test/models/helpers/admin/identities_helper_test.rb22
-rw-r--r--test/models/helpers/admin/organizations_helper_test.rb22
-rw-r--r--test/models/helpers/admin/participants_helper_test.rb22
-rw-r--r--test/models/helpers/admin/ressources_helper_test.rb22
-rw-r--r--test/models/helpers/configs_helper_test.rb4
-rw-r--r--test/models/helpers/events_helper_test.rb22
-rw-r--r--test/models/helpers/memberships_helper_test.rb22
-rw-r--r--test/models/helpers/messages_helper_test.rb22
-rw-r--r--test/models/helpers/queue_helper_test.rb22
-rw-r--r--test/models/helpers/subparticipants_helper_test.rb21
-rw-r--r--test/models/membership_message_test.rb36
-rw-r--r--test/models/message_test.rb113
-rw-r--r--test/models/participant_test.rb31
-rw-r--r--test/models/subparticipant_test.rb42
-rw-r--r--test/test_helper.rb58
42 files changed, 2196 insertions, 4 deletions
diff --git a/test/controllers/admin/participants_controller_test.rb b/test/controllers/admin/participants_controller_test.rb
new file mode 100644
index 0000000..a521ea6
--- /dev/null
+++ b/test/controllers/admin/participants_controller_test.rb
@@ -0,0 +1,46 @@
+# Copyright (C) 2007, 2008, 2009, 2010 Heiko Bernloehr (FreeIT.de).
+#
+# This file is part of ECS.
+#
+# ECS is free software: you can redistribute it and/or modify it
+# under the terms of the GNU Affero General Public License as
+# published by the Free Software Foundation, either version 3 of
+# the License, or (at your option) any later version.
+#
+# ECS is distributed in the hope that it will be useful, but
+# WITHOUT ANY WARRANTY; without even the implied warranty of
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+# Affero General Public License for more details.
+#
+# You should have received a copy of the GNU Affero General Public
+# License along with ECS. If not, see <http://www.gnu.org/licenses/>.
+
+
+require 'test_helper'
+
+
+class Admin::ParticipantsControllerTest < ActionController::TestCase
+ TTL = 3600 # seconds, how long an anonymous participant lives
+ test "create participant and postrouting" do
+ params = {
+ :participant => {
+ "name"=> "testclient",
+ "identities_attributes"=>{"0"=>{"name"=>"test", "description"=>"only for test"}},
+ "community_ids"=>[communities(:wuv).id],
+ "description"=>"Dieser Participant wird zum Testen kreiert.",
+ "dns"=>"N/A",
+ "organization_id"=>Organization.find_by_name("not available").id,
+ "email"=>"N/A",
+ "ttl"=> DateTime.now.utc + TTL.seconds,
+ "anonymous"=>false,
+ "community_selfrouting"=>false
+ }
+ }
+ assert_difference('Participant.count') do
+ post :create, params
+ end
+ assert_equal('Participant "testclient" was successfully created.',flash[:notice])
+ assert_equal(communities(:wuv).id, Participant.find_by_name("testclient").communities.first.id)
+ assert_equal(1,Participant.find_by_name("testclient").memberships.first.membership_messages.count)
+ end
+end
diff --git a/test/controllers/configs_controller_test.rb b/test/controllers/configs_controller_test.rb
new file mode 100644
index 0000000..049e561
--- /dev/null
+++ b/test/controllers/configs_controller_test.rb
@@ -0,0 +1,8 @@
+require 'test_helper'
+
+class ConfigsControllerTest < ActionController::TestCase
+ # Replace this with your real tests.
+ test "the truth" do
+ assert true
+ end
+end
diff --git a/test/controllers/events_controller_test.rb b/test/controllers/events_controller_test.rb
new file mode 100644
index 0000000..28e5fce
--- /dev/null
+++ b/test/controllers/events_controller_test.rb
@@ -0,0 +1,27 @@
+# Copyright (C) 2007, 2008, 2009, 2010 Heiko Bernloehr (FreeIT.de).
+#
+# This file is part of ECS.
+#
+# ECS is free software: you can redistribute it and/or modify it
+# under the terms of the GNU Affero General Public License as
+# published by the Free Software Foundation, either version 3 of
+# the License, or (at your option) any later version.
+#
+# ECS is distributed in the hope that it will be useful, but
+# WITHOUT ANY WARRANTY; without even the implied warranty of
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+# Affero General Public License for more details.
+#
+# You should have received a copy of the GNU Affero General Public
+# License along with ECS. If not, see <http://www.gnu.org/licenses/>.
+
+
+require 'test_helper'
+
+class EventsControllerTest < ActionController::TestCase
+ test "index" do
+ @request.env["X-EcsAuthId"] = identities(:ulm_id1).name
+ get :index
+ assert_response 200
+ end
+end
diff --git a/test/controllers/memberships_controller_test.rb b/test/controllers/memberships_controller_test.rb
new file mode 100644
index 0000000..9612d60
--- /dev/null
+++ b/test/controllers/memberships_controller_test.rb
@@ -0,0 +1,35 @@
+# Copyright (C) 2007, 2008, 2009, 2010 Heiko Bernloehr (FreeIT.de).
+#
+# This file is part of ECS.
+#
+# ECS is free software: you can redistribute it and/or modify it
+# under the terms of the GNU Affero General Public License as
+# published by the Free Software Foundation, either version 3 of
+# the License, or (at your option) any later version.
+#
+# ECS is distributed in the hope that it will be useful, but
+# WITHOUT ANY WARRANTY; without even the implied warranty of
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+# Affero General Public License for more details.
+#
+# You should have received a copy of the GNU Affero General Public
+# License along with ECS. If not, see <http://www.gnu.org/licenses/>.
+
+
+require 'test_helper'
+
+class MembershipsControllerTest < ActionController::TestCase
+
+ test "prettyfied memberships" do
+ @request.env["X-EcsAuthId"] = identities(:ulm_id1).name
+ @request.set_REQUEST_URI("/sys/memberships")
+ @request.env["ACCEPT"] = "application/json"
+ get :index
+ assert_response 200
+ f = StringIO.open @response.body
+ b = f.readlines
+ f.close
+ assert b.length > 1, "/memberships representation is not prettyfied json.\nMaybe json-pretty doesn't work.\nMaybe old gems ? Especially the json gem."
+ end
+
+end
diff --git a/test/controllers/messages_controller_test.rb b/test/controllers/messages_controller_test.rb
new file mode 100644
index 0000000..3497b93
--- /dev/null
+++ b/test/controllers/messages_controller_test.rb
@@ -0,0 +1,491 @@
+# Copyright (C) 2007, 2008, 2009, 2010 Heiko Bernloehr (FreeIT.de).
+#
+# This file is part of ECS.
+#
+# ECS is free software: you can redistribute it and/or modify it
+# under the terms of the GNU Affero General Public License as
+# published by the Free Software Foundation, either version 3 of
+# the License, or (at your option) any later version.
+#
+# ECS is distributed in the hope that it will be useful, but
+# WITHOUT ANY WARRANTY; without even the implied warranty of
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+# Affero General Public License for more details.
+#
+# You should have received a copy of the GNU Affero General Public
+# License along with ECS. If not, see <http://www.gnu.org/licenses/>.
+
+
+require 'test_helper'
+
+class MessagesControllerTest < ActionController::TestCase
+ test "index" do
+ @request.env["X-EcsAuthId"] = identities(:ulm_id1).name
+ @request.set_REQUEST_URI("/numlab/exercises")
+ get :index
+ assert_response 200
+ assert_equal [1,2], assigns(:list).map {|e| e.id}
+ end
+
+ test "show first exercise as a receiver" do
+ @request.env["X-EcsAuthId"] = identities(:ulm_id1).name
+ @request.set_REQUEST_URI("/numlab/exercises")
+ get :show, { :id => messages(:numlab_ex1).id }
+ assert_response 200
+ assert_equal "Hallo Ihr da im Radio.", @response.body.strip
+ assert_equal "X-EcsSender: "+memberships(:stgt_wuv).id.to_s, "X-EcsSender: "+@response.header['X-EcsSender']
+ assert_equal "X-EcsReceiverCommunities: "+communities(:wuv).id.to_s, "X-EcsReceiverCommunities: "+@response.header['X-EcsReceiverCommunities']
+ end
+
+ test "show solution" do
+ @request.env["X-EcsAuthId"] = identities(:ulm_id1).name
+ @request.set_REQUEST_URI("/numlab/solutions/3")
+ get :show, { :id => messages(:numlab_sol).id }
+ logger.debug "request.path = #{@request.path}"
+ logger.debug "app_namespace = #{assigns(:app_namespace)}"
+ logger.debug "ressource_name = #{assigns(:ressource_name)}"
+ assert_response 200
+ end
+
+ # not a receiver or sender of :numlab_ex1
+ test "show forbidden exercise" do
+ @request.env["X-EcsAuthId"] = identities(:numlab_comp_id1).name
+ @request.set_REQUEST_URI("/numlab/exercises/#{messages(:numlab_ulm_ex1).id.to_s}")
+ get :show, { :id => messages(:numlab_ulm_ex1).id }
+ logger.debug "request.path = #{@request.path}"
+ assert_response 403
+ end
+
+ test "show exercise as original sender but not as a receiver" do
+ @request.env["X-EcsAuthId"] = identities(:ulm_id1).name
+ @request.set_REQUEST_URI("/numlab/exercises")
+ get :show, { :id => messages(:numlab_ulm_ex1).id }
+ logger.debug "request.path = #{@request.path}"
+ assert_response 200
+ assert !@response.header.has_key?('X-EcsSender')
+ assert !@response.header.has_key?('X-EcsReceiverCommunities')
+ end
+
+ test "create_X-EcsReceiverMemberships" do
+ @request.env["RAW_POST_DATA"] = "hallole"
+ @request.env["CONTENT_TYPE"] = "text/html"
+ @request.env["X-EcsAuthId"] = identities(:stgt_id1).name
+ @request.env["X-EcsReceiverMemberships"] = memberships(:ulm_wuv).id.to_s
+ @request.set_REQUEST_URI("/numlab/exercises")
+ mm_count = MembershipMessage.all.count
+ post :create
+ assert_response 201
+ assert_equal assigns(:record).sender, assigns(:participant).id
+ assert_equal mm_count+1, MembershipMessage.all.count
+ assert_match /^.*\/numlab\/exercises\/[0-9]+$/, @response.header['LOCATION']
+ end
+
+ test "create_X-EcsReceiverCommunities_single" do
+ @request.env["RAW_POST_DATA"] = "hallole"
+ @request.env["CONTENT_TYPE"] = "text/html"
+ @request.env["X-EcsAuthId"] = identities(:stgt_id1).name
+ @request.env["X-EcsReceiverCommunities"] = communities(:suv).name
+ @request.set_REQUEST_URI("/numlab/exercises")
+ mm_count = MembershipMessage.all.count
+ post :create
+ assert_response 201
+ assert_equal assigns(:record).sender, assigns(:participant).id
+ assert_equal mm_count+1, MembershipMessage.all.count
+ end
+
+ test "create_X-EcsReceiverCommunities_multi" do
+ @request.env["RAW_POST_DATA"] = "hallole"
+ @request.env["CONTENT_TYPE"] = "text/html"
+ @request.env["X-EcsAuthId"] = identities(:stgt_id1).name
+ @request.env["X-EcsReceiverCommunities"] = communities(:suv).name + "," + communities(:public).name
+ @request.set_REQUEST_URI("/numlab/exercises")
+ mm_count = MembershipMessage.all.count
+ post :create
+ assert_response 201
+ assert_equal assigns(:record).sender, assigns(:participant).id
+ assert_equal mm_count+3, MembershipMessage.all.count
+ end
+
+ test "create_X-EcsReceiverCommunities_multi_string_and_number" do
+ @request.env["RAW_POST_DATA"] = "hallole"
+ @request.env["CONTENT_TYPE"] = "text/html"
+ @request.env["X-EcsAuthId"] = identities(:stgt_id1).name
+ @request.env["X-EcsReceiverCommunities"] = communities(:suv).name + "," + communities(:public).id.to_s
+ @request.set_REQUEST_URI("/numlab/exercises")
+ mm_count = MembershipMessage.all.count
+ post :create
+ assert_response 201
+ assert_equal assigns(:record).sender, assigns(:participant).id
+ assert_equal mm_count+3, MembershipMessage.all.count
+ end
+
+ test "create without content-type header" do
+ @request.env["RAW_POST_DATA"] = "hallole"
+ @request.env["X-EcsAuthId"] = identities(:stgt_id1).name
+ @request.env["X-EcsReceiverMemberships"] = memberships(:ulm_wuv).id.to_s
+ @request.set_REQUEST_URI("/numlab/exercises")
+ post :create
+ assert_response 400
+ end
+
+ test "create without body" do
+ @request.env["CONTENT_TYPE"] = "text/html"
+ @request.env["X-EcsAuthId"] = identities(:stgt_id1).name
+ @request.env["X-EcsReceiverMemberships"] = memberships(:ulm_wuv).id.to_s
+ @request.set_REQUEST_URI("/numlab/exercises")
+ post :create
+ assert_response 400
+ end
+
+ test "update" do
+ @request.env["RAW_POST_DATA"] = "neuer Text"
+ @request.env["CONTENT_TYPE"] = "text/html"
+ @request.env["X-EcsAuthId"] = identities(:stgt_id1).name
+ @request.env["X-EcsReceiverMemberships"] = memberships(:ulm_wuv).id.to_s
+ @request.set_REQUEST_URI("/numlab/exercises")
+ post :update, { :id => messages(:numlab_ex2).id }
+ assert_response 200
+ end
+
+ test "update with event generation" do
+ @request.env["RAW_POST_DATA"] = "neuer Text"
+ @request.env["CONTENT_TYPE"] = "text/html"
+ @request.env["X-EcsAuthId"] = identities(:stgt_id1).name
+ @request.env["X-EcsReceiverMemberships"] = memberships(:ulm_wuv).id.to_s
+ @request.set_REQUEST_URI("/numlab/exercises")
+ ev_count = Event.all.count
+ m= Message.find(messages(:numlab_ex2).id)
+ m.ressource.events= true
+ m.save
+ post :update, { :id => messages(:numlab_ex2).id }
+ assert_response 200
+ assert_equal ev_count+1, Event.all.count
+ ev= Event.find(:last, :order => "id")
+ assert_equal ev.ev_type_id, 3
+ m= Message.find(messages(:numlab_ex2).id)
+ m.ressource.events= false
+ m.save
+ end
+
+ test "update without ownership" do
+ @request.env["RAW_POST_DATA"] = "neuer Text"
+ @request.env["CONTENT_TYPE"] = "text/html"
+ @request.env["X-EcsAuthId"] = identities(:ulm_id1).name
+ @request.env["X-EcsReceiverMemberships"] = memberships(:ulm_wuv).id.to_s
+ @request.set_REQUEST_URI("/numlab/exercises")
+ post :update, { :id => messages(:numlab_ex2).id }
+ assert_response 403
+ end
+
+ # not a receiver or sender of :numlab_sol
+ test "delete_forbidden_solution" do
+ @request.env["X-EcsAuthId"] = identities(:numlab_comp_id1).name
+ @request.set_REQUEST_URI("/numlab/solutions/#{messages(:numlab_sol).id.to_s}")
+ post :destroy, { :id => messages(:numlab_sol).id }
+ logger.debug "request.path = #{@request.path}"
+ assert_response 404
+ end
+
+ # Owner deletes his message for which he is concurrently a receiver.
+ # This should only be possible until he clears its receiver queue. Then the
+ # next delete operation removes the message from ECS and also destroys all other
+ # receiver references.
+ test "delete_postrouted_message_as_owner_and_receiver_with_references_in_place" do
+ @request.set_REQUEST_URI("/numlab/exercises/99999")
+ @request.env["X-EcsAuthId"] = identities(:stgt_id1).name
+ refscount= MembershipMessage.find_all_by_message_id(messages(:numlab_ex1)).count
+ assert refscount > 1
+ post :destroy, { :id => messages(:numlab_ex1).id }
+ logger.debug "@request.path = "+@request.path
+ assert_response 200
+ get :show, { :id => messages(:numlab_ex1).id }
+ assert_response 200
+ assert MembershipMessage.find_all_by_message_id(messages(:numlab_ex1)).count == refscount - 1
+ # message is only tagged as removed (events on). physically it's still there.
+ assert_nothing_raised(ActiveRecord::RecordNotFound) { Message.find(messages(:numlab_ex1)) }
+ # This destroy is processed as role "sender", because the receiver quueue of the sender
+ # participant is now empty. Therefore all receiver references were deleted.
+ post :destroy, { :id => messages(:numlab_ex1).id }
+ assert_response 200
+ get :show, { :id => messages(:numlab_ex1).id }
+ assert_response 404
+ assert_equal 0, MembershipMessage.find_all_by_message_id(messages(:numlab_ex1)).count
+ # message is only tagged as removed (events on). physically it's still there.
+ assert_nothing_raised(ActiveRecord::RecordNotFound) { Message.find(messages(:numlab_ex1)) }
+ end
+
+ test "delete_postrouted_message_as_owner_with_references_in_place" do
+ @request.set_REQUEST_URI("/numlab/exercises/99999")
+ @request.env["X-EcsAuthId"] = identities(:ulm_id1).name
+ assert MembershipMessage.find_all_by_message_id(messages(:numlab_ulm_ex1)).count > 0
+ post :destroy, { :id => messages(:numlab_ulm_ex1).id }
+ logger.debug "@request.path = "+@request.path
+ assert_response 200
+ get :show, { :id => messages(:numlab_ulm_ex1).id }
+ assert_response 404
+ assert_equal 0, MembershipMessage.find_all_by_message_id(messages(:numlab_ulm_ex1)).count
+ # message is only tagged as removed (events on). physically it's still there.
+ assert_nothing_raised(ActiveRecord::RecordNotFound) { Message.find(messages(:numlab_ulm_ex1)) }
+ end
+
+ test "delete_postrouted_message_as_none_owner_with_references_in_place" do
+ @request.set_REQUEST_URI("/numlab/exercises/99999")
+ @request.env["X-EcsAuthId"] = identities(:stgt_id1).name
+ mm_count = MembershipMessage.all.count
+ # destroy message through receiver and none owner
+ post :destroy, { :id => messages(:numlab_ulm_ex1).id }
+ logger.debug "@request.path = "+@request.path
+ assert_response 200
+ assert_nothing_raised(ActiveRecord::RecordNotFound) { Message.find(@request.parameters[:id]) }
+ assert_equal 0, MembershipMessage.find_all_by_message_id(@request.parameters[:id]).count
+ assert_equal Membership.find_by_participant_id_and_community_id(participants(:ilias_ulm),communities(:wuv)).id.to_s, @response["X-EcsSender"]
+ assert_equal communities(:wuv).id.to_s, @response["X-EcsReceiverCommunities"]
+ end
+
+ test "delete_none_postrouted_message_as_none_owner_with_last_reference_in_place" do
+ @request.env["RAW_POST_DATA"] = "Diese Nachricht ist volatil.\r\n"
+ @request.env["CONTENT_TYPE"] = "text/plain"
+ @request.env["X-EcsAuthId"] = identities(:stgt_id1).name
+ @request.env["X-EcsReceiverMemberships"] = memberships(:numlab_comp).id.to_s
+ @request.set_REQUEST_URI("/numlab/solutions")
+ mm_count = MembershipMessage.all.count
+ post :create
+ assert_response 201
+ assert_equal assigns(:record).sender, assigns(:participant).id
+ assert_equal mm_count+1, MembershipMessage.all.count
+ # destroy message through receiver
+ @request.set_REQUEST_URI("/numlab/solutions")
+ @request.env["X-EcsAuthId"] = identities(:numlab_comp_id1).name
+ /[0-9]+$/ =~ @response.header['LOCATION']
+ memberships = Membership.receiver(identities(:numlab_comp_id1).participant, $~.to_s.to_i)
+ post :destroy, { :id => $~.to_s.to_i }
+ assert_response 200
+ assert_equal $~.to_s, @request.parameters[:id]
+ assert_nothing_raised(ActiveRecord::RecordNotFound) { Message.find(@request.parameters[:id]) }
+ assert_nil MembershipMessage.find_by_message_id(@request.parameters[:id])
+ assert_equal Membership.find_by_participant_id_and_community_id(participants(:ilias_stgt),communities(:public)).id.to_s, @response["X-EcsSender"]
+ assert_equal communities(:public).id.to_s, @response["X-EcsReceiverCommunities"]
+ end
+
+ test "delete_none_postrouted_message_as_none_owner_with_references_in_place" do
+ @request.env["RAW_POST_DATA"] = "Diese Nachricht ist volatil.\r\n"
+ @request.env["CONTENT_TYPE"] = "text/plain"
+ @request.env["X-EcsAuthId"] = identities(:stgt_id1).name
+ @request.env["X-EcsReceiverMemberships"] = memberships(:numlab_comp).id.to_s+","+memberships(:numlab_teacher).id.to_s
+ @request.set_REQUEST_URI("/numlab/solutions")
+ mm_count = MembershipMessage.all.count
+ post :create
+ assert_response 201
+ assert_equal assigns(:record).sender, assigns(:participant).id
+ assert_equal mm_count+2, MembershipMessage.all.count
+ /[0-9]+$/ =~ @response.header['LOCATION']
+ assert_equal 2, MembershipMessage.find_all_by_message_id($~.to_s.to_i).count
+ # destroy message through receiver
+ @request.set_REQUEST_URI("/numlab/solutions")
+ @request.env["X-EcsAuthId"] = identities(:numlab_comp_id1).name
+ post :destroy, { :id => $~.to_s.to_i }
+ assert_response 200
+ assert_equal $~.to_s, @request.parameters[:id]
+ assert_nothing_raised(ActiveRecord::RecordNotFound) { Message.find(@request.parameters[:id]) }
+ assert_equal 1, MembershipMessage.find_all_by_message_id($~.to_s.to_i).count
+ end
+
+ # Queue tests
+ #
+ test "fifo get idempotent" do
+ @request.env["X-EcsAuthId"] = identities(:ulm_id1).name
+ @request.set_REQUEST_URI("/numlab/exercises")
+ get :fifo
+ assert_response 200
+ assert_equal "Hallo Ihr da im Radio.", @response.body.strip
+ get :fifo
+ assert_response 200
+ assert_equal "Hallo Ihr da im Radio.", @response.body.strip
+ assert_equal Membership.find_by_participant_id_and_community_id(participants(:ilias_stgt),communities(:wuv)).id.to_s, @response["X-EcsSender"]
+ assert_equal communities(:wuv).id.to_s, @response["X-EcsReceiverCommunities"]
+ end
+
+ test "fifo get not idempotent" do
+ @request.env["X-EcsAuthId"] = identities(:ulm_id1).name
+ @request.set_REQUEST_URI("/numlab/exercises")
+ post :fifo
+ assert_response 200
+ assert_equal "Hallo Ihr da im Radio.", @response.body.strip
+ assert_equal Membership.find_by_participant_id_and_community_id(participants(:ilias_stgt),communities(:wuv)).id.to_s, @response["X-EcsSender"]
+ assert_equal communities(:wuv).id.to_s, @response["X-EcsReceiverCommunities"]
+ get :fifo
+ assert_response 200
+ assert_not_equal "Hallo Ihr da im Radio.", @response.body.strip
+ assert_equal "Achtung ein Kartoon.", @response.body.strip
+ end
+
+ test "lifo get idempotent" do
+ @request.env["X-EcsAuthId"] = identities(:ulm_id1).name
+ @request.set_REQUEST_URI("/numlab/exercises")
+ get :lifo
+ assert_response 200
+ assert_equal "Achtung ein Kartoon.", @response.body.strip
+ get :lifo
+ assert_response 200
+ assert_equal "Achtung ein Kartoon.", @response.body.strip
+ end
+
+ test "lifo get not idempotent" do
+ @request.env["X-EcsAuthId"] = identities(:ulm_id1).name
+ @request.set_REQUEST_URI("/numlab/exercises")
+ post :lifo
+ assert_response 200
+ assert_equal "Achtung ein Kartoon.", @response.body.strip
+ get :lifo
+ assert_response 200
+ assert_not_equal "Achtung ein Kartoon.", @response.body.strip
+ assert_equal "Hallo Ihr da im Radio.", @response.body.strip
+ end
+
+# Auths tests
+#
+
+ test "create_auths_url" do
+ @request.env["RAW_POST_DATA"] = <<-'HERE'
+ {
+ "url":"https://ilias.uni-stuttgart.de/goto.php?target=crs_95034&client_id=USTGT"
+ }
+ HERE
+ @request.env["CONTENT_TYPE"] = "application/json"
+ @request.env["X-EcsAuthId"] = identities(:stgt_id1).name
+ @request.env["X-EcsReceiverMemberships"] = memberships(:ulm_wuv).id.to_s
+ @request.set_REQUEST_URI("/sys/auths")
+ mm_count = MembershipMessage.all.count
+ post :create
+ assert_response 201
+ end
+
+ test "create_auths_realm" do
+ @request.env["RAW_POST_DATA"] = <<-'HERE'
+ {
+ "realm":"https://ilias.uni-stuttgart.de/goto.php?target=crs_95034&client_id=USTGT"
+ }
+ HERE
+ @request.env["CONTENT_TYPE"] = "application/json"
+ @request.env["X-EcsAuthId"] = identities(:stgt_id1).name
+ @request.env["X-EcsReceiverMemberships"] = memberships(:ulm_wuv).id.to_s
+ @request.set_REQUEST_URI("/sys/auths")
+ mm_count = MembershipMessage.all.count
+ post :create
+ assert_response 201
+ end
+
+ test "create_auths_invalid_json_mimetype" do
+ @request.env["RAW_POST_DATA"] = <<-'HERE'
+ {
+ "realm":"https://ilias.uni-stuttgart.de/goto.php?target=crs_95034&client_id=USTGT"
+ }
+ HERE
+ @request.env["CONTENT_TYPE"] = "text/html"
+ @request.env["X-EcsAuthId"] = identities(:stgt_id1).name
+ @request.env["X-EcsReceiverMemberships"] = memberships(:ulm_wuv).id.to_s
+ @request.set_REQUEST_URI("/sys/auths")
+ mm_count = MembershipMessage.all.count
+ post :create
+ assert_response 415
+ assert_equal "Body format has to be in JSON", assigns(:http_error).to_s
+ end
+
+ test "create_auths_invalid_json_body" do
+ @request.env["RAW_POST_DATA"] = <<-'HERE'
+ {
+ "realm"::"https://ilias.uni-stuttgart.de/goto.php?target=crs_95034&client_id=USTGT"
+ }
+ HERE
+ @request.env["CONTENT_TYPE"] = "application/json"
+ @request.env["X-EcsAuthId"] = identities(:stgt_id1).name
+ @request.env["X-EcsReceiverMemberships"] = memberships(:ulm_wuv).id.to_s
+ @request.set_REQUEST_URI("/sys/auths")
+ mm_count = MembershipMessage.all.count
+ post :create
+ assert_response 400
+ assert_equal "Invalid JSON body", assigns(:http_error).to_s
+ end
+
+ test "create_auths_eov_younger_than_sov" do
+ @request.env["RAW_POST_DATA"] = <<-'HERE'
+ {
+ "realm":"https://ilias.uni-stuttgart.de/goto.php?target=crs_95034&client_id=USTGT",
+ "sov": "2011-03-08T23:25:27+01:00",
+ "eov": "2011-03-08T23:25:17+01:00"
+ }
+ HERE
+ @request.env["CONTENT_TYPE"] = "application/json"
+ @request.env["X-EcsAuthId"] = identities(:stgt_id1).name
+ @request.env["X-EcsReceiverMemberships"] = memberships(:ulm_wuv).id.to_s
+ @request.set_REQUEST_URI("/sys/auths")
+ mm_count = MembershipMessage.all.count
+ post :create
+ assert_response 400
+ assert_equal "invalid times either in sov or eov", assigns(:http_error).to_s
+ end
+
+ test "create_auths_sov_younger_than_current_time" do
+ @request.env["RAW_POST_DATA"] = <<-'HERE'
+ {
+ "realm":"https://ilias.uni-stuttgart.de/goto.php?target=crs_95034&client_id=USTGT",
+ "sov": "2011-03-08T23:25:27+01:00"
+ }
+ HERE
+ @request.env["CONTENT_TYPE"] = "application/json"
+ @request.env["X-EcsAuthId"] = identities(:stgt_id1).name
+ @request.env["X-EcsReceiverMemberships"] = memberships(:ulm_wuv).id.to_s
+ @request.set_REQUEST_URI("/sys/auths")
+ mm_count = MembershipMessage.all.count
+ post :create
+ assert_response 400
+ assert_equal "sov time is younger then current time", assigns(:http_error).to_s
+ end
+
+ test "create_auths_eov_too_young" do
+ @request.env["RAW_POST_DATA"] = <<-"HERE"
+ {
+ "realm":"https://ilias.uni-stuttgart.de/goto.php?target=crs_95034&client_id=USTGT",
+ "eov": "#{(Time.now + 1.second).xmlschema}"
+ }
+ HERE
+ @request.env["CONTENT_TYPE"] = "application/json"
+ @request.env["X-EcsAuthId"] = identities(:stgt_id1).name
+ @request.env["X-EcsReceiverMemberships"] = memberships(:ulm_wuv).id.to_s
+ @request.set_REQUEST_URI("/sys/auths")
+ mm_count = MembershipMessage.all.count
+ post :create
+ assert_response 400
+ assert_equal "eov time is too young", assigns(:http_error).to_s
+ end
+
+ test "delete_auths" do
+ @request.env["X-EcsAuthId"] = identities(:ulm_id1).name
+ @request.set_REQUEST_URI("/sys/auths/#{auths(:valid).one_touch_hash}")
+ auths_count= Auth.all.length
+ messages_count= Message.all.length
+ auth_valid_id= auths(:valid).id
+ message_auth_valid_id= messages(:auth_valid).id
+ post :destroy, { :id => auths(:valid).one_touch_hash }
+ assert_response 200
+ assert_equal messages_count-1, Message.all.length
+ assert_equal auths_count-1, Auth.all.length
+ assert_raise(ActiveRecord::RecordNotFound){Auth.find(auth_valid_id)}
+ assert_raise(ActiveRecord::RecordNotFound){Message.find(message_auth_valid_id)}
+ end
+
+# anonymous clients
+#
+
+ test "create anonymous client" do
+ @request.env["CONTENT_TYPE"] = "application/json"
+ @request.set_REQUEST_URI("/numlab/exercises")
+ mm_count = MembershipMessage.all.count
+ get :index
+ assert_response 200
+ assert_match /ecs_anonymous=.*/, @response.headers["Set-Cookie"].to_s
+ assert_equal mm_count+1, MembershipMessage.all.count
+ end if ECS_CONFIG["participants"]["allow_anonymous"]
+
+
+end
diff --git a/test/controllers/queue_controller_test.rb b/test/controllers/queue_controller_test.rb
new file mode 100644
index 0000000..024d366
--- /dev/null
+++ b/test/controllers/queue_controller_test.rb
@@ -0,0 +1,26 @@
+# Copyright (C) 2007, 2008, 2009, 2010 Heiko Bernloehr (FreeIT.de).
+#
+# This file is part of ECS.
+#
+# ECS is free software: you can redistribute it and/or modify it
+# under the terms of the GNU Affero General Public License as
+# published by the Free Software Foundation, either version 3 of
+# the License, or (at your option) any later version.
+#
+# ECS is distributed in the hope that it will be useful, but
+# WITHOUT ANY WARRANTY; without even the implied warranty of
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+# Affero General Public License for more details.
+#
+# You should have received a copy of the GNU Affero General Public
+# License along with ECS. If not, see <http://www.gnu.org/licenses/>.
+
+
+require 'test_helper'
+
+class QueueControllerTest < ActionController::TestCase
+ # Replace this with your real tests.
+ test "the truth" do
+ assert true
+ end
+end
diff --git a/test/controllers/subparticipants_controller_test.rb b/test/controllers/subparticipants_controller_test.rb
new file mode 100644
index 0000000..717fe52
--- /dev/null
+++ b/test/controllers/subparticipants_controller_test.rb
@@ -0,0 +1,25 @@
+# Copyright (C) 2014 Heiko Bernloehr (FreeIT.de).
+#
+# This file is part of ECS.
+#
+# ECS is free software: you can redistribute it and/or modify it
+# under the terms of the GNU Affero General Public License as
+# published by the Free Software Foundation, either version 3 of
+# the License, or (at your option) any later version.
+#
+# ECS is distributed in the hope that it will be useful, but
+# WITHOUT ANY WARRANTY; without even the implied warranty of
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+# Affero General Public License for more details.
+#
+# You should have received a copy of the GNU Affero General Public
+# License along with ECS. If not, see <http://www.gnu.org/licenses/>.
+
+require 'test_helper'
+
+class SubparticipantsControllerTest < ActionController::TestCase
+ # Replace this with your real tests.
+ test "the truth" do
+ assert true
+ end
+end
diff --git a/test/fixtures/auths.yml b/test/fixtures/auths.yml
new file mode 100644
index 0000000..7d9bda3
--- /dev/null
+++ b/test/fixtures/auths.yml
@@ -0,0 +1,9 @@
+# Read about fixtures at http://ar.rubyonrails.org/classes/Fixtures.html
+
+outtimed:
+ one_touch_hash: <%= Digest::SHA1.hexdigest 'one touch hash outtimed' %>
+ message_id: 7
+
+valid:
+ one_touch_hash: <%= Digest::SHA1.hexdigest 'one touch hash valid' %>
+ message_id: 8
diff --git a/test/fixtures/communities.yml b/test/fixtures/communities.yml
new file mode 100644
index 0000000..a2a3f1d
--- /dev/null
+++ b/test/fixtures/communities.yml
@@ -0,0 +1,27 @@
+# Copyright (C) 2007, 2008, 2009, 2010 Heiko Bernloehr (FreeIT.de).
+#
+# This file is part of ECS.
+#
+# ECS is free software: you can redistribute it and/or modify it
+# under the terms of the GNU Affero General Public License as
+# published by the Free Software Foundation, either version 3 of
+# the License, or (at your option) any later version.
+#
+# ECS is distributed in the hope that it will be useful, but
+# WITHOUT ANY WARRANTY; without even the implied warranty of
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+# Affero General Public License for more details.
+#
+# You should have received a copy of the GNU Affero General Public
+# License along with ECS. If not, see <http://www.gnu.org/licenses/>.
+
+
+public:
+ name: public
+ description: "Community for anonymous participants."
+suv:
+ name: SUV
+ description: "SĂĽddeutscher Uni-Verbund\r\nAlle Unis sĂĽdlich des Mains."
+wuv:
+ name: WUV
+ description: "Westdeutscher Uni-Verbund. Mal sehen, wie lange man hier die Zeilen\r\nmachen kann und wie sie nachher umgebrochen werden. Das kann wahrscheinlich\r\nbeliebig lange gehen, bis dass die Zeile aus dem Bildschirm hängt :)"
diff --git a/test/fixtures/community_messages.yml b/test/fixtures/community_messages.yml
new file mode 100644
index 0000000..6892df4
--- /dev/null
+++ b/test/fixtures/community_messages.yml
@@ -0,0 +1,31 @@
+# Copyright (C) 2007, 2008, 2009, 2010 Heiko Bernloehr (FreeIT.de).
+#
+# This file is part of ECS.
+#
+# ECS is free software: you can redistribute it and/or modify it
+# under the terms of the GNU Affero General Public License as
+# published by the Free Software Foundation, either version 3 of
+# the License, or (at your option) any later version.
+#
+# ECS is distributed in the hope that it will be useful, but
+# WITHOUT ANY WARRANTY; without even the implied warranty of
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+# Affero General Public License for more details.
+#
+# You should have received a copy of the GNU Affero General Public
+# License along with ECS. If not, see <http://www.gnu.org/licenses/>.
+
+
+# Read about fixtures at http://ar.rubyonrails.org/classes/Fixtures.html
+numlab_ex1_to_suv:
+ message_id: 1
+ community: suv
+
+numlab_ex1_to_wuv:
+ message_id: 1
+ community: wuv
+
+numlab_ex1_to_public:
+ message_id: 1
+ community: public
+
diff --git a/test/fixtures/ev_types.yml b/test/fixtures/ev_types.yml
new file mode 100644
index 0000000..365c316
--- /dev/null
+++ b/test/fixtures/ev_types.yml
@@ -0,0 +1,35 @@
+# Copyright (C) 2007, 2008, 2009, 2010 Heiko Bernloehr (FreeIT.de).
+#
+# This file is part of ECS.
+#
+# ECS is free software: you can redistribute it and/or modify it
+# under the terms of the GNU Affero General Public License as
+# published by the Free Software Foundation, either version 3 of
+# the License, or (at your option) any later version.
+#
+# ECS is distributed in the hope that it will be useful, but
+# WITHOUT ANY WARRANTY; without even the implied warranty of
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+# Affero General Public License for more details.
+#
+# You should have received a copy of the GNU Affero General Public
+# License along with ECS. If not, see <http://www.gnu.org/licenses/>.
+
+
+# Read about fixtures at http://ar.rubyonrails.org/classes/Fixtures.html
+
+created:
+ id: 1
+ name: created
+
+destroyed:
+ id: 2
+ name: destroyed
+
+updated:
+ id: 3
+ name: updated
+
+notlinked:
+ id: 4
+ name: notlinked
diff --git a/test/fixtures/events.yml b/test/fixtures/events.yml
new file mode 100644
index 0000000..017a7ff
--- /dev/null
+++ b/test/fixtures/events.yml
@@ -0,0 +1,19 @@
+# Copyright (C) 2007, 2008, 2009, 2010 Heiko Bernloehr (FreeIT.de).
+#
+# This file is part of ECS.
+#
+# ECS is free software: you can redistribute it and/or modify it
+# under the terms of the GNU Affero General Public License as
+# published by the Free Software Foundation, either version 3 of
+# the License, or (at your option) any later version.
+#
+# ECS is distributed in the hope that it will be useful, but
+# WITHOUT ANY WARRANTY; without even the implied warranty of
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+# Affero General Public License for more details.
+#
+# You should have received a copy of the GNU Affero General Public
+# License along with ECS. If not, see <http://www.gnu.org/licenses/>.
+
+
+# Read about fixtures at http://ar.rubyonrails.org/classes/Fixtures.html
diff --git a/test/fixtures/identities.yml b/test/fixtures/identities.yml
new file mode 100644
index 0000000..3c87c80
--- /dev/null
+++ b/test/fixtures/identities.yml
@@ -0,0 +1,43 @@
+# Copyright (C) 2007, 2008, 2009, 2010 Heiko Bernloehr (FreeIT.de).
+#
+# This file is part of ECS.
+#
+# ECS is free software: you can redistribute it and/or modify it
+# under the terms of the GNU Affero General Public License as
+# published by the Free Software Foundation, either version 3 of
+# the License, or (at your option) any later version.
+#
+# ECS is distributed in the hope that it will be useful, but
+# WITHOUT ANY WARRANTY; without even the implied warranty of
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+# Affero General Public License for more details.
+#
+# You should have received a copy of the GNU Affero General Public
+# License along with ECS. If not, see <http://www.gnu.org/licenses/>.
+
+
+stgt_id1:
+ name: my_secret_identity
+ description: "Einfach eine Dummy Identiy."
+ participant_id: 1
+
+stgt_id2:
+ name: myid
+ description: "Zertifikats-ID\r\nZentrale E-Lernplattform am Rechenzentrum."
+ participant_id: 1
+
+ulm_id1:
+ name: ulama
+ description: "LDAP Authentication ID."
+ participant_id: 2
+
+numlab_comp_id1:
+ name: sunito
+ description:
+ participant_id: 3
+
+numlab_teacher_id1:
+ name: trulane
+ description:
+ participant_id: 4
+
diff --git a/test/fixtures/membership_messages.yml b/test/fixtures/membership_messages.yml
new file mode 100644
index 0000000..0fd8e13
--- /dev/null
+++ b/test/fixtures/membership_messages.yml
@@ -0,0 +1,64 @@
+# Copyright (C) 2007, 2008, 2009, 2010 Heiko Bernloehr (FreeIT.de).
+#
+# This file is part of ECS.
+#
+# ECS is free software: you can redistribute it and/or modify it
+# under the terms of the GNU Affero General Public License as
+# published by the Free Software Foundation, either version 3 of
+# the License, or (at your option) any later version.
+#
+# ECS is distributed in the hope that it will be useful, but
+# WITHOUT ANY WARRANTY; without even the implied warranty of
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+# Affero General Public License for more details.
+#
+# You should have received a copy of the GNU Affero General Public
+# License along with ECS. If not, see <http://www.gnu.org/licenses/>.
+
+
+# Read about fixtures at http://ar.rubyonrails.org/classes/Fixtures.html
+
+1:
+ id: 1
+ membership_id: 1 #stuttgart_suv
+ message_id: 1 #numlab_exercise_1
+
+2:
+ id: 2
+ membership_id: 2 #ulm_wuv
+ message_id: 2 #numlab_exercise_2
+
+3:
+ id: 3
+ membership_id: 4 #ulm_suv_4
+ message_id: 3 #numlab_sol_3
+
+4:
+ id: 4
+ membership_id: 2 #ulm_wuv
+ message_id: 4 #cc_courselink_1
+
+5:
+ id: 5
+ membership_id: 3 #stuttgart_wuv
+ message_id: 6 #numlab_ulm_exercise_1
+
+6:
+ id: 6
+ membership_id: 2 #ulm_wuv
+ message_id: 1 #numlab_exercise_1
+
+7:
+ id: 7
+ membership_id: 4 #ulm_suv
+ message_id: 2 #numlab_exercise_2
+
+8:
+ id: 8
+ membership_id: 2 #ulm_wuv
+ message_id: 7 #auth_outtimed
+
+9:
+ id: 9
+ membership_id: 2 #ulm_wuv
+ message_id: 8 #auth_valid
diff --git a/test/fixtures/memberships.yml b/test/fixtures/memberships.yml
new file mode 100644
index 0000000..934f411
--- /dev/null
+++ b/test/fixtures/memberships.yml
@@ -0,0 +1,52 @@
+# Copyright (C) 2007, 2008, 2009, 2010 Heiko Bernloehr (FreeIT.de).
+#
+# This file is part of ECS.
+#
+# ECS is free software: you can redistribute it and/or modify it
+# under the terms of the GNU Affero General Public License as
+# published by the Free Software Foundation, either version 3 of
+# the License, or (at your option) any later version.
+#
+# ECS is distributed in the hope that it will be useful, but
+# WITHOUT ANY WARRANTY; without even the implied warranty of
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+# Affero General Public License for more details.
+#
+# You should have received a copy of the GNU Affero General Public
+# License along with ECS. If not, see <http://www.gnu.org/licenses/>.
+
+
+stgt_suv:
+ id: 1
+ participant_id: 1
+ community: suv
+
+ulm_wuv:
+ id: 2
+ participant_id: 2
+ community: wuv
+
+stgt_wuv:
+ id: 3
+ participant_id: 1
+ community: wuv
+
+ulm_suv:
+ id: 4
+ participant_id: 2
+ community: suv
+
+numlab_comp:
+ id: 5
+ participant_id: 3
+ community: public
+
+stgt_public:
+ id: 6
+ participant_id: 1
+ community: public
+
+numlab_teacher:
+ id: 7
+ participant_id: 4
+ community: public
diff --git a/test/fixtures/messages.yml b/test/fixtures/messages.yml
new file mode 100644
index 0000000..3a1c46c
--- /dev/null
+++ b/test/fixtures/messages.yml
@@ -0,0 +1,86 @@
+# Copyright (C) 2007, 2008, 2009, 2010 Heiko Bernloehr (FreeIT.de).
+#
+# This file is part of ECS.
+#
+# ECS is free software: you can redistribute it and/or modify it
+# under the terms of the GNU Affero General Public License as
+# published by the Free Software Foundation, either version 3 of
+# the License, or (at your option) any later version.
+#
+# ECS is distributed in the hope that it will be useful, but
+# WITHOUT ANY WARRANTY; without even the implied warranty of
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+# Affero General Public License for more details.
+#
+# You should have received a copy of the GNU Affero General Public
+# License along with ECS. If not, see <http://www.gnu.org/licenses/>.
+
+
+# Read about fixtures at http://ar.rubyonrails.org/classes/Fixtures.html
+
+numlab_ex1:
+ id: 1
+ ressource: numlab_ex
+ content_type: application/json
+ sender: 1
+ body: "Hallo Ihr da im Radio.\r\n"
+
+numlab_ex2:
+ id: 2
+ ressource: numlab_ex
+ content_type: application/json
+ sender: 1
+ body: "Achtung ein Kartoon.\r\n"
+
+numlab_sol:
+ id: 3
+ ressource: numlab_solutions
+ content_type: application/json
+ sender: 1
+ body: "Eine gute Loesung.\r\n"
+
+cc_course1:
+ id: 4
+ ressource: cc_course
+ content_type: application/json
+ sender: 1
+ body: "Der ultimative Kurs.\r\n"
+
+no_rec:
+ id: 5
+ ressource: cc_course
+ content_type: application/json
+ sender: 19900
+ body: "Dieser Kurslink hat keinen Empfänger."
+
+numlab_ulm_ex1:
+ id: 6
+ ressource: numlab_ex
+ content_type: application/json
+ sender: 2
+ body: "Ne superschwere Aufgabe aus Ulm.\r\n"
+
+auth_outtimed:
+ id: 7
+ ressource: sys_auths
+ content_type: application/json
+ sender: 1
+ body: "{
+ \"pid\": 2,
+ \"sov\": \"2012-11-28T03:59:05+01:00\",
+ \"eov\": \"2012-11-28T04:00:10+01:00\",
+ \"realm\": \"<%= Digest::SHA1.hexdigest 'https://freeit.de/doc1.html' %>\"
+ }"
+
+auth_valid:
+ id: 8
+ ressource: sys_auths
+ content_type: application/json
+ sender: 1
+ body: "{
+ \"pid\": 2,
+ \"sov\": \"2012-11-28T03:59:05+01:00\",
+ \"eov\": \"2030-11-28T04:00:10+01:00\",
+ \"realm\": \"<%= Digest::SHA1.hexdigest 'https://freeit.de/doc2.html' %>\"
+ }"
+
diff --git a/test/fixtures/organizations.yml b/test/fixtures/organizations.yml
new file mode 100644
index 0000000..288b9ca
--- /dev/null
+++ b/test/fixtures/organizations.yml
@@ -0,0 +1,32 @@
+# Copyright (C) 2007, 2008, 2009, 2010 Heiko Bernloehr (FreeIT.de).
+#
+# This file is part of ECS.
+#
+# ECS is free software: you can redistribute it and/or modify it
+# under the terms of the GNU Affero General Public License as
+# published by the Free Software Foundation, either version 3 of
+# the License, or (at your option) any later version.
+#
+# ECS is distributed in the hope that it will be useful, but
+# WITHOUT ANY WARRANTY; without even the implied warranty of
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+# Affero General Public License for more details.
+#
+# You should have received a copy of the GNU Affero General Public
+# License along with ECS. If not, see <http://www.gnu.org/licenses/>.
+
+
+NA:
+ name: not available
+ abrev: N/A
+ description: This is epecially for anonymous participants.
+
+uni_stgt:
+ name: Universität Stuttgart
+ abrev: S
+ description: Technische Universität Stuttgart
+
+uni_ulm:
+ name: Universität Ulm
+ abrev: U
+ description: Universität Stuttgart
diff --git a/test/fixtures/participants.yml b/test/fixtures/participants.yml
new file mode 100644
index 0000000..97e3a0b
--- /dev/null
+++ b/test/fixtures/participants.yml
@@ -0,0 +1,57 @@
+# Copyright (C) 2007, 2008, 2009, 2010 Heiko Bernloehr (FreeIT.de).
+#
+# This file is part of ECS.
+#
+# ECS is free software: you can redistribute it and/or modify it
+# under the terms of the GNU Affero General Public License as
+# published by the Free Software Foundation, either version 3 of
+# the License, or (at your option) any later version.
+#
+# ECS is distributed in the hope that it will be useful, but
+# WITHOUT ANY WARRANTY; without even the implied warranty of
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+# Affero General Public License for more details.
+#
+# You should have received a copy of the GNU Affero General Public
+# License along with ECS. If not, see <http://www.gnu.org/licenses/>.
+
+
+ilias_stgt:
+ id: 1
+ name: Ilias Uni Stuttgart
+ dns: ilias3.uni-stuttgart.de
+ email: klaus.vorkauf@uni-stuttgart.de
+ description: Zentrale Lernplattform
+ organization: uni_stgt
+ ttl: <%= Time.gm(1970,1,1).to_s(:db) %>
+ anonymous: false
+
+ilias_ulm:
+ id: 2
+ name: Ilias Uni Ulm
+ dns: ilias3.uni-ulm.de
+ email: matthias.schneiderhahn@uni-ulm.de.de
+ description: Zentrale Lernplattform
+ organization: uni_ulm
+ ttl: <%= Time.gm(1970,1,1).to_s(:db) %>
+ anonymous: false
+
+numlab_comp:
+ id: 3
+ name: Computation client
+ dns: N/A
+ email: rudlof@rus.uni-stuttgart.de
+ description: Computation client of NumLab service.
+ organization: uni_stgt
+ ttl: <%= Time.gm(1970,1,1).to_s(:db) %>
+ anonymous: false
+
+numlab_teacher:
+ id: 4
+ name: Teacher client
+ dns: N/A
+ email: adjibadji@rus.uni-stuttgart.de
+ description: Teacher client of NumLab service.
+ organization: uni_stgt
+ ttl: <%= Time.gm(1970,1,1).to_s(:db) %>
+ anonymous: false
diff --git a/test/fixtures/ressources.yml b/test/fixtures/ressources.yml
new file mode 100644
index 0000000..f3869d1
--- /dev/null
+++ b/test/fixtures/ressources.yml
@@ -0,0 +1,49 @@
+# Copyright (C) 2007, 2008, 2009, 2010 Heiko Bernloehr (FreeIT.de).
+#
+# This file is part of ECS.
+#
+# ECS is free software: you can redistribute it and/or modify it
+# under the terms of the GNU Affero General Public License as
+# published by the Free Software Foundation, either version 3 of
+# the License, or (at your option) any later version.
+#
+# ECS is distributed in the hope that it will be useful, but
+# WITHOUT ANY WARRANTY; without even the implied warranty of
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+# Affero General Public License for more details.
+#
+# You should have received a copy of the GNU Affero General Public
+# License along with ECS. If not, see <http://www.gnu.org/licenses/>.
+
+
+# Read about fixtures at http://ar.rubyonrails.org/classes/Fixtures.html
+numlab_ex:
+ namespace: numlab
+ ressource: exercises
+ postroute: true
+ events: true
+
+
+numlab_results:
+ namespace: numlab
+ ressource: results
+ postroute: false
+ events: true
+
+numlab_solutions:
+ namespace: numlab
+ ressource: solutions
+ postroute: false
+ events: true
+
+cc_course:
+ namespace: cc
+ ressource: course
+ postroute: false
+ events: true
+
+sys_auths:
+ namespace: sys
+ ressource: auths
+ postroute: false
+ events: false
diff --git a/test/fixtures/subparticipants.yml b/test/fixtures/subparticipants.yml
new file mode 100644
index 0000000..2097774
--- /dev/null
+++ b/test/fixtures/subparticipants.yml
@@ -0,0 +1,24 @@
+# Copyright (C) 2014 Heiko Bernloehr (FreeIT.de).
+#
+# This file is part of ECS.
+#
+# ECS is free software: you can redistribute it and/or modify it
+# under the terms of the GNU Affero General Public License as
+# published by the Free Software Foundation, either version 3 of
+# the License, or (at your option) any later version.
+#
+# ECS is distributed in the hope that it will be useful, but
+# WITHOUT ANY WARRANTY; without even the implied warranty of
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+# Affero General Public License for more details.
+#
+# You should have received a copy of the GNU Affero General Public
+# License along with ECS. If not, see <http://www.gnu.org/licenses/>.
+
+# Read about fixtures at http://ar.rubyonrails.org/classes/Fixtures.html
+
+one:
+ realm: MyString
+
+two:
+ realm: MyString
diff --git a/test/integration/community_messages_test.rb b/test/integration/community_messages_test.rb
new file mode 100644
index 0000000..a40d799
--- /dev/null
+++ b/test/integration/community_messages_test.rb
@@ -0,0 +1,64 @@
+# Copyright (C) 2007, 2008, 2009, 2010 Heiko Bernloehr (FreeIT.de).
+#
+# This file is part of ECS.
+#
+# ECS is free software: you can redistribute it and/or modify it
+# under the terms of the GNU Affero General Public License as
+# published by the Free Software Foundation, either version 3 of
+# the License, or (at your option) any later version.
+#
+# ECS is distributed in the hope that it will be useful, but
+# WITHOUT ANY WARRANTY; without even the implied warranty of
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+# Affero General Public License for more details.
+#
+# You should have received a copy of the GNU Affero General Public
+# License along with ECS. If not, see <http://www.gnu.org/licenses/>.
+
+
+require 'test_helper'
+
+class CommunityMessagesTest < ActionController::IntegrationTest
+ fixtures :all
+
+ BODY_DATA = "hallole"
+
+ def sender_headers
+ @headers ||= {}
+ @headers['HTTP_ACCEPT'] = 'text/plain'
+ @headers['CONTENT_TYPE'] = 'text/plain'
+ @participant = identities(:stgt_id1).participant
+ @headers["X-EcsAuthId"] = identities(:stgt_id1).name
+ @headers["X-EcsReceiverCommunities"] = communities(:suv).name + ',' + communities(:wuv).name
+ @headers["X-EcsReceiverMemberships"] = ""
+ end
+
+ def setup
+ end
+
+ def test_new_jointable_entries
+ sender_headers
+ post '/numlab/exercises', BODY_DATA, @headers
+ assert_response 201
+ mid = URI.split(headers["Location"])[5].sub(/.*\/(.*)/, '\1')
+ assert Message.find(mid).communities.map{|c| c.name}.include?(communities(:suv).name)
+ assert Message.find(mid).communities.map{|c| c.name}.include?(communities(:wuv).name)
+ assert_equal 2, Message.find(mid).communities.length
+ end
+
+ def test_if_jointable_entries_will_be_deleted
+ r=Ressource.find_by_namespace_and_ressource("numlab","exercises");r.events=false;r.save!
+ cm_count = CommunityMessage.all.length
+ sender_headers
+ post '/numlab/exercises', BODY_DATA, @headers
+ assert_equal cm_count+2, CommunityMessage.all.length # addressed to two communities
+ location = URI.split(headers["Location"])[5][1..-1].sub(/[^\/]*\/(.*)/, '\1')
+ mid = URI.split(headers["Location"])[5].sub(/.*\/(.*)/, '\1')
+ sender_headers
+ delete '/numlab/'+location, nil, @headers
+ assert_response 200
+ assert_equal cm_count, CommunityMessage.all.length
+ end
+
+end
+
diff --git a/test/integration/ressource_test.rb b/test/integration/ressource_test.rb
new file mode 100644
index 0000000..a24dae5
--- /dev/null
+++ b/test/integration/ressource_test.rb
@@ -0,0 +1,332 @@
+# Copyright (C) 2007, 2008, 2009, 2010 Heiko Bernloehr (FreeIT.de).
+#
+# This file is part of ECS.
+#
+# ECS is free software: you can redistribute it and/or modify it
+# under the terms of the GNU Affero General Public License as
+# published by the Free Software Foundation, either version 3 of
+# the License, or (at your option) any later version.
+#
+# ECS is distributed in the hope that it will be useful, but
+# WITHOUT ANY WARRANTY; without even the implied warranty of
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+# Affero General Public License for more details.
+#
+# You should have received a copy of the GNU Affero General Public
+# License along with ECS. If not, see <http://www.gnu.org/licenses/>.
+
+
+require 'test_helper'
+
+class RessourceTest < ActionController::IntegrationTest
+ fixtures :all
+
+ def setup
+ # delete all messages for sender and receiver_1
+
+ end
+
+ BODY_DATA = "hallole"
+
+ def sender_headers
+ @headers ||= {}
+ @headers['HTTP_ACCEPT'] = 'text/plain'
+ @headers['CONTENT_TYPE'] = 'text/plain'
+ @participant = identities(:stgt_id1).participant
+ @headers["X-EcsAuthId"] = identities(:stgt_id1).name
+ @headers["X-EcsReceiverCommunities"] = communities(:suv).name
+ @headers["X-EcsReceiverMemberships"] = ""
+ end
+
+ def sender2_headers
+ @headers ||= {}
+ @headers['HTTP_ACCEPT'] = 'text/plain'
+ @headers['CONTENT_TYPE'] = 'text/plain'
+ @participant = identities(:stgt_id1).participant
+ @headers["X-EcsAuthId"] = identities(:stgt_id1).name
+ @headers["X-EcsReceiverCommunities"] = communities(:public).name
+ @headers["X-EcsReceiverMemberships"] = ""
+ end
+
+ def receiver_1_headers
+ @headers ||= {}
+ @headers['HTTP_ACCEPT'] = 'text/plain'
+ @headers['CONTENT_TYPE'] = 'text/plain'
+ @participant = identities(:ulm_id1).participant
+ @headers["X-EcsAuthId"] = identities(:ulm_id1).name
+ @headers["X-EcsReceiverCommunities"] = communities(:suv).name
+ end
+
+ def receiver_2_headers
+ @headers ||= {}
+ @headers['HTTP_ACCEPT'] = 'text/plain'
+ @headers['CONTENT_TYPE'] = 'text/plain'
+ @participant = identities(:numlab_teacher_id1).participant
+ @headers["X-EcsAuthId"] = identities(:numlab_teacher_id1).name
+ @headers["X-EcsReceiverCommunities"] = communities(:public).name
+ end
+
+ def receiver_3_headers
+ @headers ||= {}
+ @headers['HTTP_ACCEPT'] = 'text/plain'
+ @headers['CONTENT_TYPE'] = 'text/plain'
+ @participant = identities(:numlab_comp_id1).participant
+ @headers["X-EcsAuthId"] = identities(:numlab_comp_id1).name
+ @headers["X-EcsReceiverCommunities"] = communities(:public).name
+ end
+
+ def test_community_selfrouting
+ sender_headers
+ @participant.community_selfrouting=true;@participant.save!
+ location = ""
+ post '/numlab/exercises', BODY_DATA, @headers
+ assert_response 201
+ location = URI.split(headers["Location"])[5][1..-1].sub(/[^\/]*\/(.*)/, '\1')
+ logger.info('headers["Location"]: '+headers["Location"])
+ logger.info('location: '+location)
+ sender_headers
+ get '/numlab/exercises', nil, @headers
+ assert_response 200
+ assert response.body.index(location)
+ end
+
+ def test_community_no_selfrouting
+ sender_headers
+ location = ""
+ @participant.community_selfrouting=false;@participant.save!
+ post '/numlab/exercises', BODY_DATA, @headers
+ assert_response 201
+ location = URI.split(headers["Location"])[5][1..-1].sub(/[^\/]*\/(.*)/, '\1')
+ logger.info('headers["Location"]: '+headers["Location"])
+ logger.info('location: '+location)
+ sender_headers
+ assert !@participant.community_selfrouting
+ get '/numlab/exercises', nil, @headers
+ assert_response 200
+ assert_nil response.body.index(location)
+ end
+
+
+
+
+ # events true
+ # postrouted true
+ # community_selfrouting false
+ #
+ # 1.0 Create exercise.
+ # 1.1 Test index of sender and other receivers.
+ # The new exercise should be shown on all indexes.
+ # 1.2 Test via GET /numlab/exercises/lifo of sender and other receivers.
+ # The new exercise should only be shown by receivers not by sender.
+ # 1.3 Test via GET /numlab/exercises/<id> of sender and other receivers.
+ # The new exercise should be shown by sender and other receivers.
+ # 1.4 Test if all receiver participants get an "created" event.
+ # The new event should be shown by sender and other receivers.
+ # 1.5 Pop sender and all receiver events.
+ def test_create
+ r=Ressource.find_by_namespace_and_ressource("numlab","exercises");r.postroute=true;r.save!
+ r=Ressource.find_by_namespace_and_ressource("numlab","exercises");r.events=true;r.save!
+ # 1.0
+ sender_headers
+ location = ""
+ post '/numlab/exercises', BODY_DATA, @headers
+ assert_response 201
+ location = URI.split(headers["Location"])[5][1..-1].sub(/[^\/]*\/(.*)/, '\1')
+ logger.info('headers["Location"]: '+headers["Location"])
+ logger.info('location: '+location)
+ # 1.1
+ sender_headers
+ get '/numlab/exercises', nil, @headers
+ assert_response 200
+ assert_nil response.body.index(location)
+ receiver_1_headers
+ get '/numlab/exercises', nil, @headers
+ assert_response 200
+ assert response.body.index(location)
+ # 1.2
+ sender_headers
+ get '/numlab/exercises/lifo', nil, @headers
+ assert_response 200
+ assert_nil response.body.index(BODY_DATA)
+ receiver_1_headers
+ get '/numlab/exercises/lifo', nil, @headers
+ assert_response 200
+ assert response.body.index(BODY_DATA)
+ # 1.3
+ sender_headers
+ get '/numlab/'+location, nil, @headers
+ assert_response 200
+ assert response.body.index(BODY_DATA)
+ receiver_1_headers
+ get '/numlab/'+location, nil, @headers
+ assert_response 200
+ assert response.body.index(BODY_DATA)
+ # 1.4
+ sender_headers
+ get '/events', nil, @headers
+ assert_response 200
+ assert_nil response.body.index(/.*?#{location}.*?created.*/)
+ receiver_1_headers
+ get '/events', nil, @headers
+ assert_response 200
+ assert response.body.index(/.*?#{location}.*?created.*/)
+ # 1.5
+ sender_headers
+ post '/events/fifo', nil, @headers
+ logger.info("response body:\n"+response.body)
+ assert_response 200
+ assert_nil response.body.index(location)
+ sender_headers
+ post '/events/fifo', nil, @headers
+ assert_response 200
+ assert_nil response.body.index(location)
+ receiver_1_headers
+ post '/events/fifo', nil, @headers
+ assert_response 200
+ assert response.body.index(location)
+ receiver_1_headers
+ get '/events/fifo', nil, @headers
+ assert_response 200
+ assert_nil response.body.index(location)
+ end
+
+ # events true/false
+ # postrouted true/false
+ #
+ # 1.0 Delete exercise through the owner.
+ # 1.1 Test index of sender and other receivers.
+ # There shoudn't be any exercise on the index
+ # 1.2 Test if all receiver participants get an "destroyed" event.
+ # 1.3 Test if the deleted ressource is still in message table if events true
+ # otherwise the message shoud have been removed.
+ # 2.0 Pop all receiver destroyed events.
+ # 2.1 Test if the ressource was deleted from message table.
+ def test_delete_as_owner
+ p = lambda do |ev|
+ # 1.0
+ sender_headers
+ location = ""
+ post '/numlab/exercises', BODY_DATA, @headers
+ assert_response 201
+ location = URI.split(headers["Location"])[5][1..-1].sub(/[^\/]*\/(.*)/, '\1')
+ sender_headers
+ delete '/numlab/'+location, nil, @headers
+ assert_response 200
+ # 1.1
+ sender_headers
+ get '/numlab/exercises', nil, @headers
+ assert_response 200
+ assert_nil response.body.index(location)
+ receiver_1_headers
+ get '/numlab/exercises', nil, @headers
+ assert_response 200
+ assert_nil response.body.index(location)
+ # 1.2
+ sender_headers
+ get '/events', nil, @headers
+ assert_response 200
+ assert_nil(response.body.index(/.*?#{location}.*?destroyed.*/))
+ receiver_1_headers
+ get '/events', nil, @headers
+ assert_response 200
+ if ev
+ assert(response.body.index(/.*?#{location}.*?destroyed.*/))
+ else
+ assert_nil(response.body.index(/.*?#{location}.*?destroyed.*/))
+ end
+ # 1.3
+ id = location.sub(/.*\/(.*)$/,'\1').to_i
+ if ev
+ assert_nothing_raised(ActiveRecord::RecordNotFound) { Message.find(id) }
+ assert(Message.find(id).removed)
+ else
+ assert_raise(ActiveRecord::RecordNotFound) { Message.find(id) }
+ end
+ # 2.0
+ sender_headers
+ post '/events/fifo', nil, @headers # created event
+ assert_response 200
+ assert_nil(response.body.index(/.*?#{location}.*?created.*/))
+ sender_headers
+ post '/events/fifo', nil, @headers # destroyed event
+ assert_response 200
+ if ev
+ assert_nil(response.body.index(/.*?#{location}.*?destroyed.*/))
+ assert_nothing_raised(ActiveRecord::RecordNotFound) { Message.find(id) }
+ else
+ assert_nil(response.body.index(/.*?#{location}.*?destroyed.*/))
+ assert_raise(ActiveRecord::RecordNotFound) { Message.find(id) }
+ end
+ receiver_1_headers
+ post '/events/fifo', nil, @headers # created event
+ assert_response 200
+ if ev
+ assert(response.body.index(/.*?#{location}.*?created.*/))
+ assert_nothing_raised(ActiveRecord::RecordNotFound) { Message.find(id) }
+ else
+ assert_nil(response.body.index(/.*?#{location}.*?created.*/))
+ assert_raise(ActiveRecord::RecordNotFound) { Message.find(id) }
+ end
+ receiver_1_headers
+ post '/events/fifo', nil, @headers # destroyed event
+ assert_response 200
+ if ev
+ assert(response.body.index(/.*?#{location}.*?destroyed.*/))
+ else
+ assert_nil(response.body.index(/.*?#{location}.*?destroyed.*/))
+ end
+ assert_raise(ActiveRecord::RecordNotFound) { Message.find(id) }
+ end
+ r=Ressource.find_by_namespace_and_ressource("numlab","exercises");r.events=true;r.save!
+ p.call(true)
+ r=Ressource.find_by_namespace_and_ressource("numlab","exercises");r.postroute=false;r.save!
+ p.call(true)
+ r=Ressource.find_by_namespace_and_ressource("numlab","exercises");r.events=false;r.save!
+ p.call(false)
+ r=Ressource.find_by_namespace_and_ressource("numlab","exercises");r.postroute=true;r.save!
+ p.call(false)
+ end
+
+ # events true
+ # postrouted false
+ # community_selfrouting false
+ #
+ # 1.0 Delete exercise through non owner
+ # 1.1 Test index
+ def test_delete_as_non_owner
+ r=Ressource.find_by_namespace_and_ressource("numlab","exercises");r.events=true;r.save!
+ #p.call(true)
+ r=Ressource.find_by_namespace_and_ressource("numlab","exercises");r.postroute=false;r.save!
+ #p.call(true)
+ sender2_headers
+ @participant.community_selfrouting=false;@participant.save!
+ location = ""
+ post '/numlab/exercises', BODY_DATA, @headers
+ assert_response 201
+ location = URI.split(headers["Location"])[5][1..-1].sub(/[^\/]*\/(.*)/, '\1')
+ id = location.sub(/.*\/(.*)$/,'\1').to_i
+ sender2_headers
+ get '/numlab/'+location, nil, @headers
+ assert_response 200
+ assert response.body.index(BODY_DATA)
+ assert_nothing_raised(ActiveRecord::RecordNotFound) { Message.find(id) }
+ assert !Message.find(id).removed
+ receiver_1_headers
+ delete '/numlab/'+location, nil, @headers
+ assert_response 404
+ assert_nothing_raised(ActiveRecord::RecordNotFound) { Message.find(id) }
+ assert !Message.find(id).removed
+ receiver_2_headers
+ delete '/numlab/'+location, nil, @headers
+ assert_response 200
+ assert response.body.index(BODY_DATA)
+ assert_nothing_raised(ActiveRecord::RecordNotFound) { Message.find(id) }
+ assert !Message.find(id).removed
+ receiver_3_headers
+ delete '/numlab/'+location, nil, @headers
+ assert_response 200
+ assert response.body.index(BODY_DATA)
+ assert_nothing_raised(ActiveRecord::RecordNotFound) { Message.find(id) }
+ assert Message.find(id).removed
+ end
+end
diff --git a/test/models/auth_test.rb b/test/models/auth_test.rb
new file mode 100644
index 0000000..2fe6192
--- /dev/null
+++ b/test/models/auth_test.rb
@@ -0,0 +1,8 @@
+require 'test_helper'
+
+class AuthTest < ActiveSupport::TestCase
+ # Replace this with your real tests.
+ test "the truth" do
+ assert true
+ end
+end
diff --git a/test/models/community_message_test.rb b/test/models/community_message_test.rb
new file mode 100644
index 0000000..4b543b5
--- /dev/null
+++ b/test/models/community_message_test.rb
@@ -0,0 +1,26 @@
+# Copyright (C) 2007, 2008, 2009, 2010 Heiko Bernloehr (FreeIT.de).
+#
+# This file is part of ECS.
+#
+# ECS is free software: you can redistribute it and/or modify it
+# under the terms of the GNU Affero General Public License as
+# published by the Free Software Foundation, either version 3 of
+# the License, or (at your option) any later version.
+#
+# ECS is distributed in the hope that it will be useful, but
+# WITHOUT ANY WARRANTY; without even the implied warranty of
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+# Affero General Public License for more details.
+#
+# You should have received a copy of the GNU Affero General Public
+# License along with ECS. If not, see <http://www.gnu.org/licenses/>.
+
+
+require 'test_helper'
+
+class CommunityMessageTest < ActiveSupport::TestCase
+ # Replace this with your real tests.
+ test "the truth" do
+ assert true
+ end
+end
diff --git a/test/models/community_test.rb b/test/models/community_test.rb
new file mode 100644
index 0000000..ef2caf7
--- /dev/null
+++ b/test/models/community_test.rb
@@ -0,0 +1,26 @@
+# Copyright (C) 2007, 2008, 2009, 2010 Heiko Bernloehr (FreeIT.de).
+#
+# This file is part of ECS.
+#
+# ECS is free software: you can redistribute it and/or modify it
+# under the terms of the GNU Affero General Public License as
+# published by the Free Software Foundation, either version 3 of
+# the License, or (at your option) any later version.
+#
+# ECS is distributed in the hope that it will be useful, but
+# WITHOUT ANY WARRANTY; without even the implied warranty of
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+# Affero General Public License for more details.
+#
+# You should have received a copy of the GNU Affero General Public
+# License along with ECS. If not, see <http://www.gnu.org/licenses/>.
+
+
+require 'test_helper'
+
+class CommunityTest < ActiveSupport::TestCase
+ # Replace this with your real tests.
+ test "the truth" do
+ assert true
+ end
+end
diff --git a/test/models/event_test.rb b/test/models/event_test.rb
new file mode 100644
index 0000000..7027376
--- /dev/null
+++ b/test/models/event_test.rb
@@ -0,0 +1,55 @@
+# Copyright (C) 2007, 2008, 2009, 2010 Heiko Bernloehr (FreeIT.de).
+#
+# This file is part of ECS.
+#
+# ECS is free software: you can redistribute it and/or modify it
+# under the terms of the GNU Affero General Public License as
+# published by the Free Software Foundation, either version 3 of
+# the License, or (at your option) any later version.
+#
+# ECS is distributed in the hope that it will be useful, but
+# WITHOUT ANY WARRANTY; without even the implied warranty of
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+# Affero General Public License for more details.
+#
+# You should have received a copy of the GNU Affero General Public
+# License along with ECS. If not, see <http://www.gnu.org/licenses/>.
+
+
+require 'test_helper'
+
+class EventTest < ActiveSupport::TestCase
+ # Replace this with your real tests.
+ test "the truth" do
+ assert true
+ end
+
+ test "generate new created event" do
+ Event.delete_all
+ ec = Event.all.count
+ ev = nil
+ assert_nothing_raised(Exception) do
+ ev = Event.make(:event_type_name => ev_types(:created).name, :membership_message => MembershipMessage.find(1))
+ end
+
+ assert_nothing_raised(ActiveRecord::RecordNotFound) { ev = Event.find(ev.id) }
+ assert_equal(1,Event.all.count)
+
+ assert_equal(participants(:ilias_stgt).id, ev.participant_id)
+ assert_equal(messages(:numlab_ex1).id, ev.message_id)
+ assert_equal(ev_types(:created).id, ev.ev_type_id)
+ end
+
+ test "participant deletion" do
+ Event.delete_all
+ ev = nil
+ assert_nothing_raised(Exception) do
+ ev = Event.make(:event_type_name => ev_types(:created).name, :membership_message => MembershipMessage.find(1))
+ end
+
+ assert_nothing_raised(Exception) { participants(:ilias_stgt).destroy }
+ assert_raise(ActiveRecord::RecordNotFound) { Event.find(ev.id) } # event has to be gone (removed)
+ assert_equal(0,Event.all.count) # event has to be gone (removed)
+ end
+
+end
diff --git a/test/models/helpers/admin/communities_helper_test.rb b/test/models/helpers/admin/communities_helper_test.rb
new file mode 100644
index 0000000..737e688
--- /dev/null
+++ b/test/models/helpers/admin/communities_helper_test.rb
@@ -0,0 +1,22 @@
+# Copyright (C) 2007, 2008, 2009, 2010 Heiko Bernloehr (FreeIT.de).
+#
+# This file is part of ECS.
+#
+# ECS is free software: you can redistribute it and/or modify it
+# under the terms of the GNU Affero General Public License as
+# published by the Free Software Foundation, either version 3 of
+# the License, or (at your option) any later version.
+#
+# ECS is distributed in the hope that it will be useful, but
+# WITHOUT ANY WARRANTY; without even the implied warranty of
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+# Affero General Public License for more details.
+#
+# You should have received a copy of the GNU Affero General Public
+# License along with ECS. If not, see <http://www.gnu.org/licenses/>.
+
+
+require 'test_helper'
+
+class Admin::CommunitiesHelperTest < ActionView::TestCase
+end
diff --git a/test/models/helpers/admin/identities_helper_test.rb b/test/models/helpers/admin/identities_helper_test.rb
new file mode 100644
index 0000000..08a245c
--- /dev/null
+++ b/test/models/helpers/admin/identities_helper_test.rb
@@ -0,0 +1,22 @@
+# Copyright (C) 2007, 2008, 2009, 2010 Heiko Bernloehr (FreeIT.de).
+#
+# This file is part of ECS.
+#
+# ECS is free software: you can redistribute it and/or modify it
+# under the terms of the GNU Affero General Public License as
+# published by the Free Software Foundation, either version 3 of
+# the License, or (at your option) any later version.
+#
+# ECS is distributed in the hope that it will be useful, but
+# WITHOUT ANY WARRANTY; without even the implied warranty of
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+# Affero General Public License for more details.
+#
+# You should have received a copy of the GNU Affero General Public
+# License along with ECS. If not, see <http://www.gnu.org/licenses/>.
+
+
+require 'test_helper'
+
+class Admin::IdentitiesHelperTest < ActionView::TestCase
+end
diff --git a/test/models/helpers/admin/organizations_helper_test.rb b/test/models/helpers/admin/organizations_helper_test.rb
new file mode 100644
index 0000000..c0896fd
--- /dev/null
+++ b/test/models/helpers/admin/organizations_helper_test.rb
@@ -0,0 +1,22 @@
+# Copyright (C) 2007, 2008, 2009, 2010 Heiko Bernloehr (FreeIT.de).
+#
+# This file is part of ECS.
+#
+# ECS is free software: you can redistribute it and/or modify it
+# under the terms of the GNU Affero General Public License as
+# published by the Free Software Foundation, either version 3 of
+# the License, or (at your option) any later version.
+#
+# ECS is distributed in the hope that it will be useful, but
+# WITHOUT ANY WARRANTY; without even the implied warranty of
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+# Affero General Public License for more details.
+#
+# You should have received a copy of the GNU Affero General Public
+# License along with ECS. If not, see <http://www.gnu.org/licenses/>.
+
+
+require 'test_helper'
+
+class Admin::OrganizationsHelperTest < ActionView::TestCase
+end
diff --git a/test/models/helpers/admin/participants_helper_test.rb b/test/models/helpers/admin/participants_helper_test.rb
new file mode 100644
index 0000000..bd028ca
--- /dev/null
+++ b/test/models/helpers/admin/participants_helper_test.rb
@@ -0,0 +1,22 @@
+# Copyright (C) 2007, 2008, 2009, 2010 Heiko Bernloehr (FreeIT.de).
+#
+# This file is part of ECS.
+#
+# ECS is free software: you can redistribute it and/or modify it
+# under the terms of the GNU Affero General Public License as
+# published by the Free Software Foundation, either version 3 of
+# the License, or (at your option) any later version.
+#
+# ECS is distributed in the hope that it will be useful, but
+# WITHOUT ANY WARRANTY; without even the implied warranty of
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+# Affero General Public License for more details.
+#
+# You should have received a copy of the GNU Affero General Public
+# License along with ECS. If not, see <http://www.gnu.org/licenses/>.
+
+
+require 'test_helper'
+
+class Admin::ParticipantsHelperTest < ActionView::TestCase
+end
diff --git a/test/models/helpers/admin/ressources_helper_test.rb b/test/models/helpers/admin/ressources_helper_test.rb
new file mode 100644
index 0000000..9ed47e2
--- /dev/null
+++ b/test/models/helpers/admin/ressources_helper_test.rb
@@ -0,0 +1,22 @@
+# Copyright (C) 2007, 2008, 2009, 2010 Heiko Bernloehr (FreeIT.de).
+#
+# This file is part of ECS.
+#
+# ECS is free software: you can redistribute it and/or modify it
+# under the terms of the GNU Affero General Public License as
+# published by the Free Software Foundation, either version 3 of
+# the License, or (at your option) any later version.
+#
+# ECS is distributed in the hope that it will be useful, but
+# WITHOUT ANY WARRANTY; without even the implied warranty of
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+# Affero General Public License for more details.
+#
+# You should have received a copy of the GNU Affero General Public
+# License along with ECS. If not, see <http://www.gnu.org/licenses/>.
+
+
+require 'test_helper'
+
+class Admin::RessourcesHelperTest < ActionView::TestCase
+end
diff --git a/test/models/helpers/configs_helper_test.rb b/test/models/helpers/configs_helper_test.rb
new file mode 100644
index 0000000..4a0c42a
--- /dev/null
+++ b/test/models/helpers/configs_helper_test.rb
@@ -0,0 +1,4 @@
+require 'test_helper'
+
+class ConfigsHelperTest < ActionView::TestCase
+end
diff --git a/test/models/helpers/events_helper_test.rb b/test/models/helpers/events_helper_test.rb
new file mode 100644
index 0000000..4f0612f
--- /dev/null
+++ b/test/models/helpers/events_helper_test.rb
@@ -0,0 +1,22 @@
+# Copyright (C) 2007, 2008, 2009, 2010 Heiko Bernloehr (FreeIT.de).
+#
+# This file is part of ECS.
+#
+# ECS is free software: you can redistribute it and/or modify it
+# under the terms of the GNU Affero General Public License as
+# published by the Free Software Foundation, either version 3 of
+# the License, or (at your option) any later version.
+#
+# ECS is distributed in the hope that it will be useful, but
+# WITHOUT ANY WARRANTY; without even the implied warranty of
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+# Affero General Public License for more details.
+#
+# You should have received a copy of the GNU Affero General Public
+# License along with ECS. If not, see <http://www.gnu.org/licenses/>.
+
+
+require 'test_helper'
+
+class EventsHelperTest < ActionView::TestCase
+end
diff --git a/test/models/helpers/memberships_helper_test.rb b/test/models/helpers/memberships_helper_test.rb
new file mode 100644
index 0000000..96d054b
--- /dev/null
+++ b/test/models/helpers/memberships_helper_test.rb
@@ -0,0 +1,22 @@
+# Copyright (C) 2007, 2008, 2009, 2010 Heiko Bernloehr (FreeIT.de).
+#
+# This file is part of ECS.
+#
+# ECS is free software: you can redistribute it and/or modify it
+# under the terms of the GNU Affero General Public License as
+# published by the Free Software Foundation, either version 3 of
+# the License, or (at your option) any later version.
+#
+# ECS is distributed in the hope that it will be useful, but
+# WITHOUT ANY WARRANTY; without even the implied warranty of
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+# Affero General Public License for more details.
+#
+# You should have received a copy of the GNU Affero General Public
+# License along with ECS. If not, see <http://www.gnu.org/licenses/>.
+
+
+require 'test_helper'
+
+class MembershipsHelperTest < ActionView::TestCase
+end
diff --git a/test/models/helpers/messages_helper_test.rb b/test/models/helpers/messages_helper_test.rb
new file mode 100644
index 0000000..b092cf0
--- /dev/null
+++ b/test/models/helpers/messages_helper_test.rb
@@ -0,0 +1,22 @@
+# Copyright (C) 2007, 2008, 2009, 2010 Heiko Bernloehr (FreeIT.de).
+#
+# This file is part of ECS.
+#
+# ECS is free software: you can redistribute it and/or modify it
+# under the terms of the GNU Affero General Public License as
+# published by the Free Software Foundation, either version 3 of
+# the License, or (at your option) any later version.
+#
+# ECS is distributed in the hope that it will be useful, but
+# WITHOUT ANY WARRANTY; without even the implied warranty of
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+# Affero General Public License for more details.
+#
+# You should have received a copy of the GNU Affero General Public
+# License along with ECS. If not, see <http://www.gnu.org/licenses/>.
+
+
+require 'test_helper'
+
+class MessagesHelperTest < ActionView::TestCase
+end
diff --git a/test/models/helpers/queue_helper_test.rb b/test/models/helpers/queue_helper_test.rb
new file mode 100644
index 0000000..7c979fd
--- /dev/null
+++ b/test/models/helpers/queue_helper_test.rb
@@ -0,0 +1,22 @@
+# Copyright (C) 2007, 2008, 2009, 2010 Heiko Bernloehr (FreeIT.de).
+#
+# This file is part of ECS.
+#
+# ECS is free software: you can redistribute it and/or modify it
+# under the terms of the GNU Affero General Public License as
+# published by the Free Software Foundation, either version 3 of
+# the License, or (at your option) any later version.
+#
+# ECS is distributed in the hope that it will be useful, but
+# WITHOUT ANY WARRANTY; without even the implied warranty of
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+# Affero General Public License for more details.
+#
+# You should have received a copy of the GNU Affero General Public
+# License along with ECS. If not, see <http://www.gnu.org/licenses/>.
+
+
+require 'test_helper'
+
+class QueueHelperTest < ActionView::TestCase
+end
diff --git a/test/models/helpers/subparticipants_helper_test.rb b/test/models/helpers/subparticipants_helper_test.rb
new file mode 100644
index 0000000..40e31c9
--- /dev/null
+++ b/test/models/helpers/subparticipants_helper_test.rb
@@ -0,0 +1,21 @@
+# Copyright (C) 2014 Heiko Bernloehr (FreeIT.de).
+#
+# This file is part of ECS.
+#
+# ECS is free software: you can redistribute it and/or modify it
+# under the terms of the GNU Affero General Public License as
+# published by the Free Software Foundation, either version 3 of
+# the License, or (at your option) any later version.
+#
+# ECS is distributed in the hope that it will be useful, but
+# WITHOUT ANY WARRANTY; without even the implied warranty of
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+# Affero General Public License for more details.
+#
+# You should have received a copy of the GNU Affero General Public
+# License along with ECS. If not, see <http://www.gnu.org/licenses/>.
+
+require 'test_helper'
+
+class SubparticipantsHelperTest < ActionView::TestCase
+end
diff --git a/test/models/membership_message_test.rb b/test/models/membership_message_test.rb
new file mode 100644
index 0000000..aed6982
--- /dev/null
+++ b/test/models/membership_message_test.rb
@@ -0,0 +1,36 @@
+# Copyright (C) 2007, 2008, 2009, 2010 Heiko Bernloehr (FreeIT.de).
+#
+# This file is part of ECS.
+#
+# ECS is free software: you can redistribute it and/or modify it
+# under the terms of the GNU Affero General Public License as
+# published by the Free Software Foundation, either version 3 of
+# the License, or (at your option) any later version.
+#
+# ECS is distributed in the hope that it will be useful, but
+# WITHOUT ANY WARRANTY; without even the implied warranty of
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+# Affero General Public License for more details.
+#
+# You should have received a copy of the GNU Affero General Public
+# License along with ECS. If not, see <http://www.gnu.org/licenses/>.
+
+
+require 'test_helper'
+
+class MembershipMessageTest < ActiveSupport::TestCase
+ # Replace this with your real tests.
+ test "the truth" do
+ assert true
+ end
+
+ # Only testing for destroy should be sufficient, because updating is
+ # implemented as first destroying and recreating the membership_messages
+ test "optimistic locking" do
+ mm1 = mm2 = nil
+ assert_nothing_raised(ActiveRecord::RecordNotFound) { mm1 = MembershipMessage.find(1) }
+ assert_nothing_raised(ActiveRecord::RecordNotFound) { mm2 = MembershipMessage.find(1) }
+ assert_nothing_raised(Exception) { mm1.destroy }
+ assert_raise(ActiveRecord::StaleObjectError) { mm2.destroy }
+ end
+end
diff --git a/test/models/message_test.rb b/test/models/message_test.rb
new file mode 100644
index 0000000..9a94c77
--- /dev/null
+++ b/test/models/message_test.rb
@@ -0,0 +1,113 @@
+# Copyright (C) 2007, 2008, 2009, 2010 Heiko Bernloehr (FreeIT.de).
+#
+# This file is part of ECS.
+#
+# ECS is free software: you can redistribute it and/or modify it
+# under the terms of the GNU Affero General Public License as
+# published by the Free Software Foundation, either version 3 of
+# the License, or (at your option) any later version.
+#
+# ECS is distributed in the hope that it will be useful, but
+# WITHOUT ANY WARRANTY; without even the implied warranty of
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+# Affero General Public License for more details.
+#
+# You should have received a copy of the GNU Affero General Public
+# License along with ECS. If not, see <http://www.gnu.org/licenses/>.
+
+
+require 'test_helper'
+
+# request stub
+class TestRequest
+ attr_accessor :headers, :raw_post
+ def initialize(h,rp); @headers, @raw_post = h, rp; end
+end
+
+class MessageTest < ActiveSupport::TestCase
+ test "named_scope__for_participant_receiver" do
+ m= Message.for_participant_receiver participants(:ilias_stgt)
+ assert_equal 2,m.length
+ assert m.include?(messages(:numlab_ex1))
+ assert m.include?(messages(:numlab_ulm_ex1))
+ end
+
+ # Change receivers community SUV (:ilias_stgt, :ilias_ulm) to :numlab_teacher
+ # and :ilias_ulm
+ # Note: In the fixtures :ilias_stgt is configured as a receiver because it is
+ # in the SUV community. This is not correct because :ilias_stgt doesn't set
+ # community_selfrouting, but it's history.
+ test "update_receivers" do
+ headers={
+ "X-EcsReceiverMemberships" => "7,2",
+ "CONTENT_TYPE" => "text/plain"
+ }
+ raw_post= "hallo ich war da"
+ request= TestRequest.new(headers, raw_post)
+ assert_nothing_raised do
+ messages(:numlab_ex1).update__(request, "numlab", "exercises", participants(:ilias_stgt))
+ end
+ # :numlab_teacher is a new receiver and gets an created event
+ assert Participant.for_message(messages(:numlab_ex1)).uniq.include?(participants(:numlab_teacher))
+ assert Event.find_by_participant_id_and_ev_type_id(participants(:numlab_teacher).id,EvType.find_by_name("created"))
+ # :ilias_stgt isn't a receiver anymore and gets an destroyed event (:ilias_stgt was a receiver through fixture)
+ assert !Participant.for_message(messages(:numlab_ex1)).uniq.include?(participants(:ilias_stgt))
+ assert Event.find_by_participant_id_and_ev_type_id(participants(:ilias_stgt).id,EvType.find_by_name("destroyed"))
+ # :ilias_ulm is still a receiver and gets an updated event
+ assert Participant.for_message(messages(:numlab_ex1)).uniq.include?(participants(:ilias_ulm))
+ assert Event.find_by_participant_id_and_ev_type_id(participants(:ilias_ulm).id,EvType.find_by_name("updated"))
+ # number of receivers have to be two
+ assert_equal 2, Participant.for_message(messages(:numlab_ex1)).uniq.length
+ end
+
+# Auths
+#
+ test "create_auths" do
+ headers={
+ "X-EcsReceiverMemberships" => "7,2",
+ "CONTENT_TYPE" => "application/json"
+ }
+ raw_post= Hash.new
+ raw_post[:realm]= <<-"HERE"
+ {
+ "realm":"#{Digest::SHA1.hexdigest 'https://ilias.uni-stuttgart.de/goto.php?target=crs_95034&client_id=USTGT'}"
+ }
+ HERE
+ raw_post[:url]= <<-'HERE'
+ {
+ "url":"https://ilias.uni-stuttgart.de/goto.php?target=crs_95034&client_id=USTGT"
+ }
+ HERE
+ raw_post.each do |k,v|
+ request= TestRequest.new(headers, v)
+ msg= nil
+ assert_nothing_raised do
+ msg= Message.create__(request, "sys", "auths", participants(:ilias_stgt))
+ end
+ assert Mime::Type.lookup(msg.content_type)== :json, "Content-Type is not application/json"
+ assert_equal participants(:ilias_stgt).id, msg.sender, "Unexpected creator of the message"
+ json= nil
+ assert_nothing_raised do
+ json= ActiveSupport::JSON.decode(msg.body)
+ end
+ assert json.keys.include?(k.to_s)
+ if k.to_s == "realm"
+ assert_equal Digest::SHA1.hexdigest("https://ilias.uni-stuttgart.de/goto.php?target=crs_95034&client_id=USTGT"), json[k.to_s]
+ end
+ if k.to_s == "url"
+ assert_equal "https://ilias.uni-stuttgart.de/goto.php?target=crs_95034&client_id=USTGT", json[k.to_s]
+ end
+ assert json.keys.include?("pid")
+ assert_equal participants(:ilias_stgt).id, json["pid"]
+ end
+ end
+
+ test "gc_outtimed_auths" do
+ auths_count= Auth.all.length
+ messages_count= Message.all.length
+ Auth.gc_outtimed
+ assert_equal messages_count-1, Message.all.length
+ assert_equal auths_count-1, Auth.all.length
+ assert_raise(ActiveRecord::RecordNotFound){auths(:outtimed)}
+ end
+end
diff --git a/test/models/participant_test.rb b/test/models/participant_test.rb
new file mode 100644
index 0000000..94297c1
--- /dev/null
+++ b/test/models/participant_test.rb
@@ -0,0 +1,31 @@
+# Copyright (C) 2007, 2008, 2009, 2010 Heiko Bernloehr (FreeIT.de).
+#
+# This file is part of ECS.
+#
+# ECS is free software: you can redistribute it and/or modify it
+# under the terms of the GNU Affero General Public License as
+# published by the Free Software Foundation, either version 3 of
+# the License, or (at your option) any later version.
+#
+# ECS is distributed in the hope that it will be useful, but
+# WITHOUT ANY WARRANTY; without even the implied warranty of
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+# Affero General Public License for more details.
+#
+# You should have received a copy of the GNU Affero General Public
+# License along with ECS. If not, see <http://www.gnu.org/licenses/>.
+
+
+require 'test_helper'
+
+class ParticipantTest < ActiveSupport::TestCase
+
+# test "blank participants" do
+# [:name, :dns, :email, :organization_id].each do |attrib|
+# p= Participant.new(:name=>"freeit",:dns=>"ecs.freeit.de",:email=>"hb7@gmx.net",:description=>nil,:organization_id=>1)
+# p[attrib]= nil
+# assert !p.valid?
+# assert p.errors.invalid?(attrib)
+# end
+# end
+end
diff --git a/test/models/subparticipant_test.rb b/test/models/subparticipant_test.rb
new file mode 100644
index 0000000..a1f1cd1
--- /dev/null
+++ b/test/models/subparticipant_test.rb
@@ -0,0 +1,42 @@
+# Copyright (C) 2014 Heiko Bernloehr (FreeIT.de).
+#
+# This file is part of ECS.
+#
+# ECS is free software: you can redistribute it and/or modify it
+# under the terms of the GNU Affero General Public License as
+# published by the Free Software Foundation, either version 3 of
+# the License, or (at your option) any later version.
+#
+# ECS is distributed in the hope that it will be useful, but
+# WITHOUT ANY WARRANTY; without even the implied warranty of
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+# Affero General Public License for more details.
+#
+# You should have received a copy of the GNU Affero General Public
+# License along with ECS. If not, see <http://www.gnu.org/licenses/>.
+
+# Copyright (C) 2014 Heiko Bernloehr (FreeIT.de).
+#
+# This file is part of ECS.
+#
+# ECS is free software: you can redistribute it and/or modify it
+# under the terms of the GNU Affero General Public License as
+# published by the Free Software Foundation, either version 3 of
+# the License, or (at your option) any later version.
+#
+# ECS is distributed in the hope that it will be useful, but
+# WITHOUT ANY WARRANTY; without even the implied warranty of
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+# Affero General Public License for more details.
+#
+# You should have received a copy of the GNU Affero General Public
+# License along with ECS. If not, see <http://www.gnu.org/licenses/>.
+
+require 'test_helper'
+
+class SubparticipantTest < ActiveSupport::TestCase
+ # Replace this with your real tests.
+ test "the truth" do
+ assert true
+ end
+end
diff --git a/test/test_helper.rb b/test/test_helper.rb
index 92e39b2..392100b 100644
--- a/test/test_helper.rb
+++ b/test/test_helper.rb
@@ -1,10 +1,60 @@
-ENV['RAILS_ENV'] ||= 'test'
-require File.expand_path('../../config/environment', __FILE__)
-require 'rails/test_help'
+# Copyright (C) 2007, 2008, 2009, 2010 Heiko Bernloehr (FreeIT.de).
+#
+# This file is part of ECS.
+#
+# ECS is free software: you can redistribute it and/or modify it
+# under the terms of the GNU Affero General Public License as
+# published by the Free Software Foundation, either version 3 of
+# the License, or (at your option) any later version.
+#
+# ECS is distributed in the hope that it will be useful, but
+# WITHOUT ANY WARRANTY; without even the implied warranty of
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+# Affero General Public License for more details.
+#
+# You should have received a copy of the GNU Affero General Public
+# License along with ECS. If not, see <http://www.gnu.org/licenses/>.
+
+
+ENV["RAILS_ENV"] = "test"
+require File.expand_path(File.dirname(__FILE__) + "/../config/environment")
+require 'test_help'
class ActiveSupport::TestCase
- # Setup all fixtures in test/fixtures/*.yml for all tests in alphabetical order.
+ # Transactional fixtures accelerate your tests by wrapping each test method
+ # in a transaction that's rolled back on completion. This ensures that the
+ # test database remains unchanged so your fixtures don't have to be reloaded
+ # between every test method. Fewer database queries means faster tests.
+ #
+ # Read Mike Clark's excellent walkthrough at
+ # http://clarkware.com/cgi/blosxom/2005/10/24#Rails10FastTesting
+ #
+ # Every Active Record database supports transactions except MyISAM tables
+ # in MySQL. Turn off transactional fixtures in this case; however, if you
+ # don't care one way or the other, switching from MyISAM to InnoDB tables
+ # is recommended.
+ #
+ # The only drawback to using transactional fixtures is when you actually
+ # need to test transactions. Since your test is bracketed by a transaction,
+ # any transactions started in your code will be automatically rolled back.
+ self.use_transactional_fixtures = true
+
+ # Instantiated fixtures are slow, but give you @david where otherwise you
+ # would need people(:david). If you don't want to migrate your existing
+ # test cases which use the @david style and don't mind the speed hit (each
+ # instantiated fixtures translates to a database query per test method),
+ # then set this back to true.
+ self.use_instantiated_fixtures = false
+
+ # Setup all fixtures in test/fixtures/*.(yml|csv) for all tests in alphabetical order.
+ #
+ # Note: You'll currently still have to declare fixtures explicitly in integration tests
+ # -- they do not yet inherit this setting
fixtures :all
# Add more helper methods to be used by all tests here...
+ #
+ def logger
+ RAILS_DEFAULT_LOGGER
+ end
end