16580: remove arvados-node-manager
[arvados.git] / sdk / pam / integration_tests / test_pam.py
1 # Copyright (C) The Arvados Authors. All rights reserved.
2 #
3 # SPDX-License-Identifier: Apache-2.0
4
5 """These tests assume we are running (in a docker container) with
6 arvados_pam configured and a test API server running.
7 """
8 import pam
9 import unittest
10
11 # From services/api/test/fixtures/api_client_authorizations.yml
12 # because that file is not available during integration tests:
13 ACTIVE_TOKEN = '3kg6k6lzmp9kj5cpkcoxie963cmvjahbt2fod9zru30k1jqdmi'
14 SPECTATOR_TOKEN = 'zw2f4gwx8hw8cjre7yp6v1zylhrhn3m5gvjq73rtpwhmknrybu'
15
16 class IntegrationTest(unittest.TestCase):
17     def setUp(self):
18         self.p = pam.pam()
19
20     def test_allow(self):
21         self.assertTrue(self.p.authenticate('active', ACTIVE_TOKEN, service='login'))
22
23     def test_deny_bad_token(self):
24         self.assertFalse(self.p.authenticate('active', 'thisisaverybadtoken', service='login'))
25
26     def test_deny_empty_token(self):
27         self.assertFalse(self.p.authenticate('active', '', service='login'))
28
29     def test_deny_permission(self):
30         self.assertFalse(self.p.authenticate('spectator', SPECTATOR_TOKEN, service='login'))