1
|
|
|
# Licensed to the StackStorm, Inc ('StackStorm') under one or more |
2
|
|
|
# contributor license agreements. See the NOTICE file distributed with |
3
|
|
|
# this work for additional information regarding copyright ownership. |
4
|
|
|
# The ASF licenses this file to You under the Apache License, Version 2.0 |
5
|
|
|
# (the "License"); you may not use this file except in compliance with |
6
|
|
|
# the License. You may obtain a copy of the License at |
7
|
|
|
# |
8
|
|
|
# http://www.apache.org/licenses/LICENSE-2.0 |
9
|
|
|
# |
10
|
|
|
# Unless required by applicable law or agreed to in writing, software |
11
|
|
|
# distributed under the License is distributed on an "AS IS" BASIS, |
12
|
|
|
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. |
13
|
|
|
# See the License for the specific language governing permissions and |
14
|
|
|
# limitations under the License. |
15
|
|
|
|
16
|
|
|
from integration.mistral import base |
17
|
|
|
|
18
|
|
|
from st2client import models |
19
|
|
|
|
20
|
|
|
|
21
|
|
|
class CustomYaqlKeyValuePairTest(base.TestWorkflowExecution): |
22
|
|
|
secret = None |
23
|
|
|
|
24
|
|
|
@classmethod |
25
|
|
|
def setUpClass(cls): |
26
|
|
|
super(CustomYaqlKeyValuePairTest, cls).setUpClass() |
27
|
|
|
cls.set_kvp('foobar', 'foobar', scope='system', secret=cls.secret) |
28
|
|
|
cls.set_kvp('marco', 'polo', scope='user', secret=cls.secret) |
29
|
|
|
|
30
|
|
|
@classmethod |
31
|
|
|
def tearDownClass(cls): |
32
|
|
|
super(CustomYaqlKeyValuePairTest, cls).tearDownClass() |
33
|
|
|
cls.del_kvp('foobar') |
34
|
|
|
cls.del_kvp('marco') |
35
|
|
|
|
36
|
|
|
@classmethod |
37
|
|
|
def set_kvp(cls, name, value, scope='system', secret=False): |
38
|
|
|
kvp = models.KeyValuePair( |
39
|
|
|
id=name, |
40
|
|
|
name=name, |
41
|
|
|
value=value, |
42
|
|
|
scope=scope, |
43
|
|
|
secret=secret |
44
|
|
|
) |
45
|
|
|
|
46
|
|
|
cls.st2client.keys.update(kvp) |
47
|
|
|
|
48
|
|
|
@classmethod |
49
|
|
|
def del_kvp(cls, name, scope='system'): |
50
|
|
|
kvp = models.KeyValuePair( |
51
|
|
|
id=name, |
52
|
|
|
name=name, |
53
|
|
|
scope=scope |
54
|
|
|
) |
55
|
|
|
|
56
|
|
|
cls.st2client.keys.delete(kvp) |
57
|
|
|
|
58
|
|
|
|
59
|
|
|
class UnencryptedKeyValuePairTest(CustomYaqlKeyValuePairTest): |
60
|
|
|
secret = False |
61
|
|
|
|
62
|
|
|
def test_system_kvp(self): |
63
|
|
|
execution = self._execute_workflow('examples.mistral-yaql-st2kv-system-scope') |
64
|
|
|
execution = self._wait_for_completion(execution) |
65
|
|
|
self._assert_success(execution, num_tasks=1) |
66
|
|
|
|
67
|
|
|
def test_user_kvp(self): |
68
|
|
|
execution = self._execute_workflow('examples.mistral-yaql-st2kv-user-scope') |
69
|
|
|
execution = self._wait_for_completion(execution) |
70
|
|
|
self._assert_success(execution, num_tasks=1) |
71
|
|
|
|
72
|
|
|
|
73
|
|
|
class EncryptedKeyValuePairTest(CustomYaqlKeyValuePairTest): |
74
|
|
|
secret = True |
75
|
|
|
|
76
|
|
|
def test_system_kvp(self): |
77
|
|
|
execution = self._execute_workflow('examples.mistral-yaql-st2kv-system-scope') |
78
|
|
|
execution = self._wait_for_completion(execution) |
79
|
|
|
self._assert_success(execution, num_tasks=1) |
80
|
|
|
|
81
|
|
|
def test_user_kvp(self): |
82
|
|
|
execution = self._execute_workflow('examples.mistral-yaql-st2kv-user-scope') |
83
|
|
|
execution = self._wait_for_completion(execution) |
84
|
|
|
self._assert_success(execution, num_tasks=1) |
85
|
|
|
|