Merge remote-tracking branch 'weiss/pr/3'
[nsca-ng.git] / tests / auth.at
blob0bca2093247e921d298ab4a52c0fd43b309c1098
1 # Copyright (c) 2013 Holger Weiss <holger@weiss.in-berlin.de>
2 # All rights reserved.
4 # Redistribution and use in source and binary forms, with or without
5 # modification, are permitted provided that the following conditions are met:
7 # 1. Redistributions of source code must retain the above copyright notice, this
8 #    list of conditions and the following disclaimer.
10 # 2. Redistributions in binary form must reproduce the above copyright notice,
11 #    this list of conditions and the following disclaimer in the documentation
12 #    and/or other materials provided with the distribution.
14 # THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
15 # AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
16 # IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
17 # DISCLAIMED.  IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE
18 # FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
19 # DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
20 # SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
21 # CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
22 # OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
23 # OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
25 AT_BANNER([Authentication and authorization.])
27 AT_SETUP([Incorrect password])
28 NSCA_CHECK([jupiter     0       jupiter is alive], [], [stderr], [], [],
29   [password = "incorrect"], [], [1])
30 AT_CHECK([[grep '^send_nsca: \[FATAL\] TLS error (127.0.0.1): ' stderr]], [0],
31   [ignore])
32 AT_CLEANUP
34 AT_SETUP([Unauthorized submission])
35 NSCA_CHECK([jupiter     0       jupiter is alive], [],
36   [[send_nsca: [FATAL] Server said: FAIL You're not authorized]], [], [], [],
37   [authorize "*" { password = "forty-two" commands = "none" }], [1])
38 AT_CLEANUP
40 AT_SETUP([Legitimate host check result])
41 NSCA_CHECK([jupiter     0       jupiter is alive],
42   [PROCESS_HOST_CHECK_RESULT;jupiter;0;jupiter is alive], [], [], [], [],
43   [authorize "*" { password = "forty-two" hosts = "jupiter" }])
44 AT_CLEANUP
46 AT_SETUP([Legitimate service check result])
47 NSCA_CHECK([jupiter     disk    0       disk is fine],
48   [PROCESS_SERVICE_CHECK_RESULT;jupiter;disk;0;disk is fine], [], [], [], [],
49   [authorize "*" { password = "forty-two" services = "disk" }])
50 AT_CLEANUP
52 AT_SETUP([Malicious host check result])
53 NSCA_CHECK([saturn      0       jupiter;0;tricked you!], [],
54   [[send_nsca: [FATAL] Server said: FAIL You're not authorized]], [], [], [],
55   [authorize "*" { password = "forty-two" hosts = "jupiter" }], [1])
56 AT_CLEANUP
58 AT_SETUP([Malicious service check result])
59 NSCA_CHECK([jupiter     http    0       disk;0;tricked you!], [],
60   [[send_nsca: [FATAL] Server said: FAIL You're not authorized]], [], [], [],
61   [authorize "*" { password = "forty-two" services = "disk" }], [1])
62 AT_CLEANUP
64 dnl vim:set joinspaces textwidth=80 filetype=m4: