This repository was archived by the owner on Aug 23, 2024. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 8
/
Copy pathTEST_manager_account.py
179 lines (149 loc) · 7.06 KB
/
TEST_manager_account.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
##################################################################################################
# File: TEST_manager_account.py
# Description: Redfish service conformance check tool. This module contains assertions for
# EventService
#
# Verified/operational Python revisions (Mac OS) :
# 3.4.3
#
# Initial code released : 09/2018
# Robin Ronson ~ Texas Tech University
##################################################################################################
import sys
from schema import SchemaModel
from collections import OrderedDict
from xml.dom import minidom
import re
import rf_utility
import datetime
import xml.etree.ElementTree as ET
import urllib
# map python 2 vs 3 imports
if (sys.version_info < (3, 0)):
# Python 2
Python3 = False
from urlparse import urlparse
from StringIO import StringIO
from httplib import HTTPSConnection, HTTPConnection, HTTPResponse
import urllib
import urllib2
from urllib import urlopen
else:
# Python 3
Python3 = True
from urllib.parse import urlparse
from io import StringIO
from http.client import HTTPSConnection, HTTPConnection, HTTPResponse
from urllib.request import urlopen
import ssl
import re
import json
import argparse
import base64
import datetime
import types
import socket
import select
import os
import os
from collections import OrderedDict
import time
##################################################################################################
# Description: The value of this property shall be the password for this account.
# The value shall be null for GET requests.
# Name: Assertion_MANA101(self, log)
##################################################################################################
def Assertion_MANA101(self, log):
log.AssertionID = 'MANA101'
assertion_status = log.PASS
log.assertion_log('BEGIN_ASSERTION', None)
relative_uris = self.relative_uris
authorization = 'on'
rq_headers = self.request_headers()
try:
json_payload_get, headers, status = self.http_GET(self.sut_toplevel_uris['AccountService']['url'], rq_headers, authorization)
try:
json_payload_get, headers, status = self.http_GET(json_payload_get['Accounts']['@odata.id'], rq_headers, authorization)
try:
json_payload_get, headers, status = self.http_GET(json_payload_get['Members'][0]['@odata.id'], rq_headers, authorization)
if json_payload_get['Password'] == None:
assertion_status = log.PASS
return (assertion_status)
else:
assertion_status = log.FAIL
log.assertion_log('line', "The value for password is not NULL.")
return (assertion_status)
except:
assertion_status = log.WARN
log.assertion_log('line', "No accounts are present.")
return (assertion_status)
except:
assertion_status = log.WARN
log.assertion_log('line', "Accounts property is absent.")
return (assertion_status)
except:
assertion_status = log.WARN
log.assertion_log('line', "AccountService property is absent.")
return (assertion_status)
##################################################################################################
# Description: The value of this property shall be the password for this account.
# The value of this property shall be the user name for this account.
# The value of this property shall be the ID of the Role resource that configured for this
# account. The service shall reject POST, PATCH, or PUT operations that provide a RoleId that
# does not exist by returning HTTP 400 (Bad Request).
# Name: Assertion_MANA103(self, log)
##################################################################################################
def Assertion_MANA103(self, log):
log.AssertionID = 'MANA103'
assertion_status = log.PASS
log.assertion_log('BEGIN_ASSERTION', None)
relative_uris = self.relative_uris
authorization = 'on'
rq_headers = self.request_headers()
# print(json.dumps(json_payload_get, sort_keys=True, indent=4)
try:
json_payload_get, headers, status = self.http_GET(self.sut_toplevel_uris['AccountService']['url'], rq_headers, authorization)
try:
json_payload_get_P, headers, status = self.http_GET(json_payload_get['Accounts']['@odata.id'], rq_headers, authorization)
try:
json_payload_get, headers, status = self.http_GET(json_payload_get_P['Members'][0]['@odata.id'], rq_headers, authorization)
managerRoleId = json_payload_get['RoleId']
print(json.dumps(json_payload_get, sort_keys=True, indent=4))
# Testing if the service shall reject PATCH operation that provide a RoleId that does not exist by returning HTTP 400 (Bad Request).
rq_body = {'RoleId': False}
json_payload_get_P, headers, status = self.http_PATCH(json_payload_get_P['Members'][0]['@odata.id'], rq_headers, rq_body, authorization)
if status != 400:
assertion_status = log.FAIL
log.assertion_log('line', "The service did not reject the PATCH operation that provided a RoleId that does not exist by returning HTTP 400 (Bad Request)" )
return (assertion_status)
try:
json_payload_get, headers, status = self.http_GET(json_payload_get['Links']['Role']['@odata.id'], rq_headers, authorization)
if managerRoleId == json_payload_get['Id']:
assertion_status = log.PASS
return (assertion_status)
else:
assertion_status = log.FAIL
log.assertion_log('line', "The value of this property does not match the Id property of the role referenced in the Role resource referenced from Links")
return (assertion_status)
except:
assertion_status = log.WARN
log.assertion_log('line', "No accounts are present.")
return (assertion_status)
except:
assertion_status = log.WARN
log.assertion_log('line', "No accounts are present.")
return (assertion_status)
except:
assertion_status = log.WARN
log.assertion_log('line', "Accounts property is absent.")
return (assertion_status)
except:
assertion_status = log.WARN
log.assertion_log('line', "AccountService property is absent.")
return (assertion_status)
# run(self, log):
# Takes sut obj and logger obj
###################################################################################################
def run(self, log):
assertion_status = Assertion_MANA101(self,log)
assertion_status = Assertion_MANA103(self,log)