@@ -39,26 +39,15 @@ def test_client(self):
39
39
def test_functions (self ):
40
40
41
41
self .assertEqual ("Yes I'm here :)" , self .myclient .check_connection ())
42
- try :
43
- self .assertEqual (list (), self .myclient .get_policies_list ())
44
- except Exception as e :
45
- print (e )
46
- try :
47
- self .assertEqual (["test" ], self .myclient .get_policies_list ())
48
- except Exception as test :
49
- print (test )
50
- try :
51
- self .assertEqual (dict (), self .myclient .get_policies_info ())
52
- except Exception as rr :
53
- print (rr )
54
- try :
55
- my_dict = {'test' : {'path' : [
56
- 'http://localhost:8181/v1/data/play' ], 'rules' : ['http://localhost:8181/v1/data/play/hello' ]}}
57
-
58
- self .assertEqual (my_dict , self .myclient .get_policies_info ())
59
- except Exception as testing :
60
- print (testing )
61
-
42
+ self .assertEqual (list (), self .myclient .get_policies_list ())
43
+
44
+ self .assertEqual (dict (), self .myclient .get_policies_info ())
45
+
46
+ # _dict = {'test': {'path': [
47
+ # 'http://localhost:8181/v1/data/play'], 'rules': ['http://localhost:8181/v1/data/play/hello']}}
48
+
49
+ # self.assertEqual(_dict, self.myclient.get_policies_info())
50
+
62
51
new_policy = '''
63
52
package play
64
53
@@ -72,15 +61,11 @@ def test_functions(self):
72
61
self .assertEqual (
73
62
True , self .myclient .update_opa_policy_fromstring (new_policy , "test" ))
74
63
75
- # self.assertEqual(False, self.myclient.update_opa_policy_fromfile(
76
- # "/home/root/Documents/OPA-python-client/opa_client/test/test.txt", "test"))
77
-
78
- # self.assertEqual(self.myclient.update_opa_policy_fromurl())
79
64
self .assertEqual (["test" ], self .myclient .get_policies_list ())
80
- my_dict = {'test' : {'path' : ['http://localhost:8181/v1/data/play' ],
65
+ _dict = {'test' : {'path' : ['http://localhost:8181/v1/data/play' ],
81
66
'rules' : ['http://localhost:8181/v1/data/play/hello' ]}}
82
67
83
- self .assertEqual (my_dict , self .myclient .get_policies_info ())
68
+ self .assertEqual (_dict , self .myclient .get_policies_info ())
84
69
85
70
my_policy_list = [
86
71
{"resource" : "/api/someapi" , "identity" : "your_identity" , "method" : "PUT" },
@@ -90,36 +75,14 @@ def test_functions(self):
90
75
self .assertTrue (True , self .myclient .update_or_create_opa_data (
91
76
my_policy_list , 'exampledata/accesses' ))
92
77
value = {'result' : {'hello' : False }}
93
- try :
94
- self .assertEqual (dict (), self .myclient .get_opa_raw_data ("play" ))
95
- except Exception as err :
96
- print ("not right one" , err )
97
- try :
98
- self .assertEqual (
99
- value , self .myclient .get_opa_raw_data ("hello" ))
100
- except Exception as errr :
101
- print (errr )
102
-
78
+
103
79
self .assertEqual (True , self .myclient .opa_policy_to_file ("test" ))
104
-
105
- try :
106
- self .assertEqual (dict (), self .myclient .get_opa_raw_data ("play" ))
107
- except Exception as er :
108
- print ("not right" , er )
109
- try :
110
- self .assertEqual (value , self .myclient .get_opa_raw_data ("play" ))
111
- except Exception as identifier :
112
- print (identifier )
113
-
114
- # TODO
115
- # self.assertEqual("sad", self.myclient.get_opa_policy("test"))
116
-
80
+
81
+ self .assertEqual (value , self .myclient .get_opa_raw_data ("play" ))
82
+
117
83
self .assertTrue (True , self .myclient .delete_opa_policy ("test" ))
118
84
with self .assertRaises (DeletePolicyError ):
119
85
self .myclient .delete_opa_policy ("test" )
120
86
121
87
with self .assertRaises (DeleteDataError ):
122
88
self .myclient .delete_opa_data ("play" )
123
-
124
- # TODO #check with owner of client
125
- # self.assertEqual(dict(), self.myclient.check_permission())
0 commit comments