Example #1
0
 def test_test_www_authenticate_header_not_tested(self):
     resp.test_www_authenticate_header(self.sut)
     result = get_result(self.sut, Assertion.RESP_HEADERS_WWW_AUTHENTICATE,
                         '', '')
     self.assertIsNotNone(result)
     self.assertEqual(Result.NOT_TESTED, result['result'])
     self.assertIn('No 401 Unauthorized responses found', result['msg'])
Example #2
0
 def test_test_odata_service_mime_type_not_tested(self):
     uri = '/redfish/v1/odata'
     resp.test_odata_service_mime_type(self.sut)
     result = get_result(self.sut, Assertion.RESP_ODATA_SERVICE_MIME_TYPE,
                         'GET', uri)
     self.assertIsNotNone(result)
     self.assertEqual(Result.NOT_TESTED, result['result'])
     self.assertIn('No response found for URI %s' % uri, result['msg'])
Example #3
0
 def test_test_http_unsupported_methods_pass2(self):
     add_response(self.sut, '/redfish/v1/', 'TRACE',
                  requests.codes.NOT_IMPLEMENTED)
     proto.test_http_unsupported_methods(self.sut)
     result = get_result(self.sut, Assertion.PROTO_HTTP_UNSUPPORTED_METHODS,
                         'TRACE', '/redfish/v1/')
     self.assertIsNotNone(result)
     self.assertEqual(Result.PASS, result['result'])
Example #4
0
 def test_test_status_bad_request_not_tested(self):
     resp.test_status_bad_request(self.sut)
     result = get_result(self.sut, Assertion.RESP_STATUS_BAD_REQUEST, '',
                         '')
     self.assertIsNotNone(result)
     self.assertEqual(Result.NOT_TESTED, result['result'])
     self.assertIn(
         'No response with a %s status code was found' %
         requests.codes.BAD_REQUEST, result['msg'])
Example #5
0
 def test_test_http_unsupported_methods_fail(self):
     add_response(self.sut, '/redfish/v1/', 'TRACE',
                  requests.codes.BAD_REQUEST)
     proto.test_http_unsupported_methods(self.sut)
     result = get_result(self.sut, Assertion.PROTO_HTTP_UNSUPPORTED_METHODS,
                         'TRACE', '/redfish/v1/')
     self.assertIsNotNone(result)
     self.assertEqual(Result.FAIL, result['result'])
     self.assertIn('TRACE method returned status', result['msg'])
Example #6
0
 def test_test_allow_header_get_or_head_not_tested(self):
     uri = '/redfish/v1/'
     resp.test_allow_header_get_or_head(self.sut)
     result = get_result(self.sut, Assertion.RESP_HEADERS_ALLOW_GET_OR_HEAD,
                         'HEAD', uri)
     self.assertIsNotNone(result)
     self.assertEqual(Result.NOT_TESTED, result['result'])
     self.assertIn('No response found for %s request to %s' % ('HEAD', uri),
                   result['msg'])
Example #7
0
 def test_test_odata_metadata_entity_container_not_tested(self):
     uri = '/redfish/v1/$metadata'
     resp.test_odata_metadata_entity_container(self.sut)
     result = get_result(self.sut,
                         Assertion.RESP_ODATA_METADATA_ENTITY_CONTAINER,
                         'GET', uri)
     self.assertIsNotNone(result)
     self.assertEqual(Result.NOT_TESTED, result['result'])
     self.assertIn('No response found for URI %s' % uri, result['msg'])
Example #8
0
 def test_test_location_header_not_tested(self):
     method = 'POST'
     resp.test_location_header(self.sut)
     result = get_result(self.sut, Assertion.RESP_HEADERS_LOCATION, method,
                         '')
     self.assertIsNotNone(result)
     self.assertEqual(Result.NOT_TESTED, result['result'])
     self.assertIn('No successful POST (create) response found',
                   result['msg'])
Example #9
0
 def test_test_http_supported_methods_fail(self):
     self._add_get_responses(status=requests.codes.NOT_FOUND)
     proto.test_http_supported_methods(self.sut)
     result = get_result(self.sut, Assertion.PROTO_HTTP_SUPPORTED_METHODS,
                         'GET', '')
     self.assertIsNotNone(result)
     self.assertEqual(Result.FAIL, result['result'])
     self.assertIn('No GET requests had a successful response',
                   result['msg'])
Example #10
0
 def test_test_status_internal_server_error_not_tested(self):
     resp.test_status_internal_server_error(self.sut)
     result = get_result(self.sut,
                         Assertion.RESP_STATUS_INTERNAL_SERVER_ERROR, '',
                         '')
     self.assertIsNotNone(result)
     self.assertEqual(Result.NOT_TESTED, result['result'])
     self.assertIn(
         'No response with a %s status code was found' %
         requests.codes.SERVER_ERROR, result['msg'])
Example #11
0
 def test_test_x_auth_token_header_not_tested1(self):
     method = 'POST'
     uri = self.sut.sessions_uri
     resp.test_x_auth_token_header(self.sut)
     result = get_result(self.sut, Assertion.RESP_HEADERS_X_AUTH_TOKEN,
                         method, uri)
     self.assertIsNotNone(result)
     self.assertEqual(Result.NOT_TESTED, result['result'])
     self.assertIn('No successful response found for POST to Sessions URI',
                   result['msg'])
Example #12
0
 def test_test_valid_etag_pass(self):
     uri = '/redfish/v1/foo'
     response = add_response(
         self.sut, uri, 'GET', status_code=requests.codes.OK,
         headers={}, json={'@odata.etag': '"4A30/CF16"'})
     proto.test_valid_etag(self.sut, uri, response)
     result = get_result(self.sut, Assertion.PROTO_ETAG_RFC7232,
                         'GET', uri)
     self.assertIsNotNone(result)
     self.assertEqual(Result.PASS, result['result'])
Example #13
0
 def test_test_allow_header_method_not_allowed_not_tested(self):
     resp.test_allow_header_method_not_allowed(self.sut)
     result = get_result(self.sut,
                         Assertion.RESP_HEADERS_ALLOW_METHOD_NOT_ALLOWED,
                         '', '')
     self.assertIsNotNone(result)
     self.assertEqual(Result.NOT_TESTED, result['result'])
     self.assertIn(
         'No responses found that returned a %s status code' %
         requests.codes.METHOD_NOT_ALLOWED, result['msg'])
Example #14
0
 def test_test_content_type_header_not_tested1(self):
     uri = '/redfish/v1/'
     method = 'GET'
     resp.test_content_type_header(self.sut)
     result = get_result(self.sut, Assertion.RESP_HEADERS_CONTENT_TYPE,
                         method, uri)
     self.assertIsNotNone(result)
     self.assertEqual(Result.NOT_TESTED, result['result'])
     self.assertIn(
         'No successful response found for %s request to %s' %
         (method, uri), result['msg'])
Example #15
0
 def test_test_odata_service_context_pass(self):
     uri = '/redfish/v1/odata'
     add_response(self.sut,
                  uri,
                  'GET',
                  status_code=requests.codes.OK,
                  json={'@odata.context': '/redfish/v1/$metadata'})
     resp.test_odata_service_context(self.sut)
     result = get_result(self.sut, Assertion.RESP_ODATA_SERVICE_CONTEXT,
                         'GET', uri)
     self.assertIsNotNone(result)
     self.assertEqual(Result.PASS, result['result'])
Example #16
0
 def test_test_odata_service_mime_type_pass(self):
     uri = '/redfish/v1/odata'
     add_response(self.sut,
                  uri,
                  'GET',
                  status_code=requests.codes.OK,
                  headers={'Content-Type': 'application/json'})
     resp.test_odata_service_mime_type(self.sut)
     result = get_result(self.sut, Assertion.RESP_ODATA_SERVICE_MIME_TYPE,
                         'GET', uri)
     self.assertIsNotNone(result)
     self.assertEqual(Result.PASS, result['result'])
Example #17
0
 def test_test_valid_etag_fail(self):
     uri = '/redfish/v1/foo'
     response = add_response(
         self.sut, uri, 'GET', status_code=requests.codes.OK,
         headers={'ETag': 'W/" 9573"'})  # space char not allowed
     proto.test_valid_etag(self.sut, uri, response)
     result = get_result(self.sut, Assertion.PROTO_ETAG_RFC7232,
                         'GET', uri)
     self.assertIsNotNone(result)
     self.assertEqual(Result.FAIL, result['result'])
     self.assertIn('Response from GET request to URI %s returned invalid '
                   'ETag header value' % uri, result['msg'])
Example #18
0
 def test_test_odata_service_value_prop_pass(self):
     uri = '/redfish/v1/odata'
     add_response(self.sut,
                  uri,
                  'GET',
                  status_code=requests.codes.OK,
                  json={'value': []})
     resp.test_odata_service_value_prop(self.sut)
     result = get_result(self.sut, Assertion.RESP_ODATA_SERVICE_VALUE_PROP,
                         'GET', uri)
     self.assertIsNotNone(result)
     self.assertEqual(Result.PASS, result['result'])
Example #19
0
 def test_test_odata_metadata_mime_type_pass2(self):
     uri = '/redfish/v1/$metadata'
     add_response(self.sut,
                  uri,
                  'GET',
                  status_code=requests.codes.OK,
                  headers={'Content-Type': 'application/xml;charset=utf-8'})
     resp.test_odata_metadata_mime_type(self.sut)
     result = get_result(self.sut, Assertion.RESP_ODATA_METADATA_MIME_TYPE,
                         'GET', uri)
     self.assertIsNotNone(result)
     self.assertEqual(Result.PASS, result['result'])
Example #20
0
 def test_test_odata_service_mime_type_fail1(self):
     uri = '/redfish/v1/odata'
     add_response(self.sut,
                  uri,
                  'GET',
                  status_code=requests.codes.NOT_FOUND)
     resp.test_odata_service_mime_type(self.sut)
     result = get_result(self.sut, Assertion.RESP_ODATA_SERVICE_MIME_TYPE,
                         'GET', uri)
     self.assertIsNotNone(result)
     self.assertEqual(Result.FAIL, result['result'])
     self.assertIn(
         '%s request to URI %s failed with status %s' %
         ('GET', uri, requests.codes.NOT_FOUND), result['msg'])
Example #21
0
 def test_test_odata_metadata_mime_type_fail1(self):
     uri = '/redfish/v1/$metadata'
     add_response(self.sut,
                  uri,
                  'GET',
                  status_code=requests.codes.OK,
                  headers={'Content-Type': 'text/xml'})
     resp.test_odata_metadata_mime_type(self.sut)
     result = get_result(self.sut, Assertion.RESP_ODATA_METADATA_MIME_TYPE,
                         'GET', uri)
     self.assertIsNotNone(result)
     self.assertEqual(Result.FAIL, result['result'])
     self.assertIn(
         'The MIME type for the OData metadata document is %s' % 'text/xml',
         result['msg'])
Example #22
0
 def test_test_odata_service_value_prop_fail3(self):
     uri = '/redfish/v1/odata'
     add_response(self.sut,
                  uri,
                  'GET',
                  status_code=requests.codes.OK,
                  json={'value': {}})
     resp.test_odata_service_value_prop(self.sut)
     result = get_result(self.sut, Assertion.RESP_ODATA_SERVICE_VALUE_PROP,
                         'GET', uri)
     self.assertIsNotNone(result)
     self.assertEqual(Result.FAIL, result['result'])
     self.assertIn(
         'The value property for the OData service '
         'document is type %s; expected list' % 'dict', result['msg'])
Example #23
0
 def test_test_etag_header_pass(self):
     uri = '/redfish/v1/AccountsService/Accounts/1'
     method = 'GET'
     r = add_response(self.sut,
                      uri,
                      method,
                      status_code=requests.codes.OK,
                      res_type=ResourceType.MANAGER_ACCOUNT)
     r.headers['ETag'] = 'abcd1234'
     resp.test_etag_header(self.sut)
     result = get_result(self.sut, Assertion.RESP_HEADERS_ETAG, method, uri)
     self.assertIsNotNone(result)
     self.assertEqual(Result.PASS, result['result'])
     self.assertIn('Test passed for header %s: %s' % ('ETag', 'abcd1234'),
                   result['msg'])
Example #24
0
 def test_test_link_header_schema_ver_match_fail1(self):
     uri = '/redfish/v1/'
     method = 'GET'
     uri_ref = ''
     r = add_response(self.sut, uri, method, status_code=requests.codes.OK)
     resp.test_link_header_schema_ver_match(self.sut, uri_ref, uri, method,
                                            r)
     result = get_result(self.sut,
                         Assertion.RESP_HEADERS_LINK_SCHEMA_VER_MATCH,
                         method, uri)
     self.assertIsNotNone(result)
     self.assertEqual(Result.FAIL, result['result'])
     self.assertIn(
         'The Link header with a rel=describedby param did not '
         'include a URI reference', result['msg'])
Example #25
0
 def test_test_allow_header_get_or_head_pass(self):
     uri = '/redfish/v1/'
     add_response(self.sut,
                  uri,
                  'GET',
                  status_code=requests.codes.OK,
                  headers={'Allow': 'GET, HEAD, PATCH'})
     resp.test_allow_header_get_or_head(self.sut)
     result = get_result(self.sut, Assertion.RESP_HEADERS_ALLOW_GET_OR_HEAD,
                         'GET', uri)
     self.assertIsNotNone(result)
     self.assertEqual(Result.PASS, result['result'])
     self.assertIn(
         'Test passed for header %s: %s' % ('Allow', 'GET, HEAD, PATCH'),
         result['msg'])
Example #26
0
 def test_test_odata_metadata_entity_container_pass(self):
     uri = '/redfish/v1/$metadata'
     doc = ('<Edmx><DataServices><Schema><EntityContainer/>'
            '</Schema></DataServices></Edmx>')
     add_response(self.sut,
                  uri,
                  'GET',
                  status_code=requests.codes.OK,
                  text=doc)
     resp.test_odata_metadata_entity_container(self.sut)
     result = get_result(self.sut,
                         Assertion.RESP_ODATA_METADATA_ENTITY_CONTAINER,
                         'GET', uri)
     self.assertIsNotNone(result)
     self.assertEqual(Result.PASS, result['result'])
Example #27
0
 def test_test_odata_metadata_entity_container_fail1(self):
     uri = '/redfish/v1/$metadata'
     add_response(self.sut,
                  uri,
                  'GET',
                  status_code=requests.codes.NOT_FOUND)
     resp.test_odata_metadata_entity_container(self.sut)
     result = get_result(self.sut,
                         Assertion.RESP_ODATA_METADATA_ENTITY_CONTAINER,
                         'GET', uri)
     self.assertIsNotNone(result)
     self.assertEqual(Result.FAIL, result['result'])
     self.assertIn(
         '%s request to URI %s failed with status %s' %
         ('GET', uri, requests.codes.NOT_FOUND), result['msg'])
Example #28
0
 def test_test_x_auth_token_header_not_tested2(self):
     method = 'POST'
     uri = self.sut.sessions_uri
     add_response(self.sut,
                  uri,
                  method,
                  status_code=requests.codes.CREATED,
                  headers={'X-Auth-Token': 'YXN1cmUu'})
     resp.test_x_auth_token_header(self.sut)
     result = get_result(self.sut, Assertion.RESP_HEADERS_X_AUTH_TOKEN,
                         method, uri)
     self.assertIsNotNone(result)
     self.assertEqual(Result.NOT_TESTED, result['result'])
     self.assertIn('The security token is not a hexadecimal string',
                   result['msg'])
Example #29
0
 def test_test_etag_header_not_tested(self):
     uri = '/redfish/v1/AccountsService/Accounts/1'
     method = 'GET'
     add_response(self.sut,
                  uri,
                  method,
                  status_code=requests.codes.NOT_FOUND,
                  res_type=ResourceType.MANAGER_ACCOUNT)
     resp.test_etag_header(self.sut)
     result = get_result(self.sut, Assertion.RESP_HEADERS_ETAG, method, '')
     self.assertIsNotNone(result)
     self.assertEqual(Result.NOT_TESTED, result['result'])
     self.assertIn(
         'No successful response found for %s request to %s' %
         (method, 'ManagerAccount'), result['msg'])
Example #30
0
 def test_test_x_auth_token_header_pass(self):
     method = 'POST'
     uri = self.sut.sessions_uri
     add_response(self.sut,
                  uri,
                  method,
                  status_code=requests.codes.CREATED,
                  headers={'X-Auth-Token': 'C90FDAA22168C234C4C6628B8'})
     resp.test_x_auth_token_header(self.sut)
     result = get_result(self.sut, Assertion.RESP_HEADERS_X_AUTH_TOKEN,
                         method, uri)
     self.assertIsNotNone(result)
     self.assertEqual(Result.PASS, result['result'])
     self.assertIn('Test passed for header %s' % 'X-Auth-Token',
                   result['msg'])