Debian Codegraph @

tests/integration/network/key_setup.py

raw
1 # THIS FILE IS PART OF THE CYLC WORKFLOW ENGINE.
2 # Copyright (C) 2008-2019 NIWA & British Crown (Met Office) & Contributors.
3 #
4 # This program is free software: you can redistribute it and/or modify
5 # it under the terms of the GNU General Public License as published by
6 # the Free Software Foundation, either version 3 of the License, or
7 # (at your option) any later version.
8 #
9 # This program is distributed in the hope that it will be useful,
10 # but WITHOUT ANY WARRANTY; without even the implied warranty of
11 # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12 # GNU General Public License for more details.
13 #
14 # You should have received a copy of the GNU General Public License
15 # along with this program. If not, see <http://www.gnu.org/licenses/>.
16
17 """Creates authentication keys for use in testing"""
18
19 from cylc.flow.workflow_files import (
20 create_server_keys,
21 get_workflow_srv_dir,
22 KeyInfo,
23 KeyOwner,
24 KeyType,
25 remove_keys_on_server)
26 from cylc.flow.task_remote_cmd import (
27 remove_keys_on_client, create_client_keys)
28
29
30 def setup_keys(workflow_name):
31 workflow_srv_dir = get_workflow_srv_dir(workflow_name)
32 server_keys = {
33 "client_public_key": KeyInfo(
34 KeyType.PUBLIC,
35 KeyOwner.CLIENT,
36 workflow_srv_dir=workflow_srv_dir),
37 "client_private_key": KeyInfo(
38 KeyType.PRIVATE,
39 KeyOwner.CLIENT,
40 workflow_srv_dir=workflow_srv_dir),
41 "server_public_key": KeyInfo(
42 KeyType.PUBLIC,
43 KeyOwner.SERVER,
44 workflow_srv_dir=workflow_srv_dir),
45 "server_private_key": KeyInfo(
46 KeyType.PRIVATE,
47 KeyOwner.SERVER,
48 workflow_srv_dir=workflow_srv_dir)
49 }
50 remove_keys_on_server(server_keys)
51 remove_keys_on_client(workflow_srv_dir, None, full_clean=True)
52 create_server_keys(server_keys, workflow_srv_dir)
53 create_client_keys(workflow_srv_dir, None)