api_accessible :superuser, :extend => :user do |t|
end
+ protected
+
+ def permission_to_create
+ current_user.andand.is_admin
+ end
+
+ def permission_to_update
+ current_user.andand.is_admin
+ end
end
require 'test_helper'
class KeepServiceTest < ActiveSupport::TestCase
- # test "the truth" do
- # assert true
- # end
+ test "non-admins cannot create services" do
+ set_user_from_auth :active
+ ks = KeepService.new
+ assert_not_allowed do
+ ks.save
+ end
+ end
+
+ test "non-admins cannot update services" do
+ set_user_from_auth :active
+ ks = keep_services(:proxy)
+ ks.service_port = 64434
+ assert_not_allowed do
+ ks.save
+ end
+ end
+
+ test "admins can create services" do
+ set_user_from_auth :admin
+ ks = KeepService.new
+ assert(ks.save, "saving new service failed")
+ end
+
+ test "admins can update services" do
+ set_user_from_auth :admin
+ ks = keep_services(:proxy)
+ ks.service_port = 64434
+ assert(ks.save, "saving updated service failed")
+ end
end
}
func (s *GitoliteSuite) TestPush(c *check.C) {
- err := s.RunGit(c, activeToken, "push", "active/foo.git")
+ err := s.RunGit(c, activeToken, "push", "active/foo.git", "master:gitolite-push")
c.Check(err, check.Equals, nil)
// Check that the commit hash appears in the gitolite log, as
}
func (s *GitoliteSuite) TestPushUnwritable(c *check.C) {
- err := s.RunGit(c, spectatorToken, "push", "active/foo.git")
+ err := s.RunGit(c, spectatorToken, "push", "active/foo.git", "master:gitolite-push-fail")
c.Check(err, check.ErrorMatches, `.*HTTP code = 403.*`)
}