summaryrefslogtreecommitdiffstats
path: root/test/integration/api_test/token_authentication_test.rb
blob: 2728232e23c828cf03c2630ffd761f15c52f91e5 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
# Redmine - project management software
# Copyright (C) 2006-2014  Jean-Philippe Lang
#
# This program is free software; you can redistribute it and/or
# modify it under the terms of the GNU General Public License
# as published by the Free Software Foundation; either version 2
# of the License, or (at your option) any later version.
#
# This program 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 General Public License for more details.
#
# You should have received a copy of the GNU General Public License
# along with this program; if not, write to the Free Software
# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301, USA.

require File.expand_path('../../../test_helper', __FILE__)

class Redmine::ApiTest::TokenAuthenticationTest < Redmine::ApiTest::Base
  fixtures :projects, :trackers, :issue_statuses, :issues,
           :enumerations, :users, :issue_categories,
           :projects_trackers,
           :roles,
           :member_roles,
           :members,
           :enabled_modules

  def setup
    Setting.rest_api_enabled = '1'
    Setting.login_required = '1'
  end

  def teardown
    Setting.rest_api_enabled = '0'
    Setting.login_required = '0'
  end

  # Using the NewsController because it's a simple API.
  should_allow_key_based_auth(:get, "/news.xml")
  should_allow_key_based_auth(:get, "/news.json")
end
">*dest; gsize destlen; fd = open (fname, O_RDONLY); if (fd == -1) { rspamd_fprintf (stderr, "cannot open %s: %s", fname, strerror (errno)); exit (EXIT_FAILURE); } if (fstat (fd, &st) == -1) { rspamd_fprintf (stderr, "cannot stat %s: %s", fname, strerror (errno)); exit (EXIT_FAILURE); } map = mmap (NULL, st.st_size, PROT_READ, MAP_SHARED, fd, 0); close (fd); if (map == MAP_FAILED) { rspamd_fprintf (stderr, "cannot mmap %s: %s", fname, strerror (errno)); exit (EXIT_FAILURE); } if (decode) { destlen = st.st_size / 4 * 3 + 10; dest = g_malloc (destlen); rspamd_cryptobox_base64_decode (map, st.st_size, dest, &destlen); } else { dest = rspamd_encode_base64 (map, st.st_size, 80, &destlen); } rspamd_printf ("%*s", (gint)destlen, dest); g_free (dest); munmap (map, st.st_size); } int main (int argc, char **argv) { gint i, start = 1, decode = 0; if (argc > 2 && *argv[1] == '-') { start = 2; if (argv[1][1] == 'd') { decode = 1; } } for (i = start; i < argc; i ++) { if (argv[i]) { rspamd_process_file (argv[i], decode); } } return 0; }