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_computersystem_schema.py
117 lines (84 loc) · 4.37 KB
/
TEST_computersystem_schema.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
# Copyright Notice:
# Copyright 2016-2019 Distributed Management Task Force, Inc. All rights reserved.
# License: BSD 3-Clause License. For full text see link: https://github.com/DMTF/Redfish-Service-Conformance-Check/blob/main/LICENSE.md
#####################################################################################################
# File: TEST_ComputerSystem_schema.py
# Description: Redfish service conformance check tool. This module contains implemented assertions for
# SUT.These assertions are based on operational checks on Redfish Service to verify that it conforms
# to the normative statements from the Redfish specification.
# See assertions in redfish-assertions.xlxs for assertions summary
#
# Verified/operational Python revisions (Ubuntu OS) :
# 3.5.2
# Initial code released : 05/2018
# Robin Thekkadathu Ronson ~ Texas Tech University
#####################################################################################################
import json
import string
from openpyxl import load_workbook
from openpyxl.styles import PatternFill
# Helper Functions
def patch_test(self, uri):
authorization = 'on'
rq_headers = self.request_headers()
rq_body = {'IndicatorLED': 'Unknown'}
json_payload, headers, status = self.http_PATCH(uri, rq_headers, rq_body, authorization)
return status == 400
def put_test(self, uri):
authorization = 'on'
rq_headers = self.request_headers()
rq_body = {'IndicatorLED': 'Unknown'}
json_payload, headers, status = self.http_PUT(uri, rq_headers, rq_body, authorization)
return status == 400
###################################################################################################
# Name: Assertion_COMP139(self, log) : Assembly
# Assertion text:
# This value shall represent the Indicator LED is in an unknown state. The service shall reject
# PATCH or PUT requests containing this value by returning HTTP 400 (Bad Request).
###################################################################################################
def Assertion_COMP139(self, log):
log.AssertionID = 'COMP139'
assertion_status = log.PASS
log.assertion_log('BEGIN_ASSERTION', None)
relative_uris = self.relative_uris
authorization = 'on'
rq_headers = self.request_headers()
relative_uris = self.relative_uris
try:
json_payload, headers, status = self.http_GET(relative_uris['Root Service_Systems'], rq_headers, authorization)
except:
assertion_status = log.WARN
log.assertion_log('line', "Resource %s, is not found." % (relative_uris['Root Service_Systems']))
return assertion_status
try:
json_payload, headers, status = self.http_GET(json_payload['Members'][0]['@odata.id'], rq_headers, authorization)
if not 'PATCH' in headers['allow'] or not 'PUT' in headers['allow']:
assertion_status = log.WARN
log.assertion_log('line', "~ PATCH or PUT methods are not supported")
return assertion_status
except:
assertion_status = log.WARN
log.assertion_log('line', "~ No systems are found at resource %s" % (relative_uris['Root Service_Systems']))
return assertion_status
try:
json_payload, headers, status = self.http_GET(json_payload['IndicatorLED'], rq_headers, authorization)
except:
assertion_status = log.WARN
log.assertion_log('line', "Property IndicatorLED is not found.")
return assertion_status
json_payload, headers, status = self.http_GET(relative_uris['Root Service_Systems'], rq_headers, authorization)
if patch_test(self, json_payload['Members'][0]['@odata.id']) and put_test(self, json_payload['Members'][0]['@odata.id']):
assertion_status = log.PASS
log.assertion_log('line', "~ Assertion Passed")
return assertion_status
else:
assertion_status = log.FAIL
log.assertion_log('line', "~ Assertion Failed")
return assertion_status
###################################################################################################
# Name: Assertion_COMP140(self, log) : Assembly
# Assertion text:
#This value shall represent the Indicator LED is in a solid on state. If this value is not supported
###################################################################################################
def run(self, log):
assertion_status = Assertion_COMP139(self, log)