From 4d2bd00a308b1570e7bb480d7651e0e891d40cd6 Mon Sep 17 00:00:00 2001
From: Michael Hanselmann <hansmi@google.com>
Date: Tue, 19 Oct 2010 18:14:00 +0200
Subject: [PATCH] QA RAPI: Test HTTP 404 and 501

This tests the HTTP Not Found and Not Implemented errors.

Signed-off-by: Michael Hanselmann <hansmi@google.com>
Reviewed-by: Iustin Pop <iustin@google.com>
---
 qa/qa_rapi.py | 18 ++++++++++++++++++
 1 file changed, 18 insertions(+)

diff --git a/qa/qa_rapi.py b/qa/qa_rapi.py
index df01788d1..a1b371ef3 100644
--- a/qa/qa_rapi.py
+++ b/qa/qa_rapi.py
@@ -178,6 +178,24 @@ def TestEmptyCluster():
     ("/2/os", None, 'GET', None),
     ])
 
+  # Test HTTP Not Found
+  for method in ["GET", "PUT", "POST", "DELETE"]:
+    try:
+      _DoTests([("/99/resource/not/here/99", None, method, None)])
+    except rapi.client.GanetiApiError, err:
+      AssertEqual(err.code, 404)
+    else:
+      raise qa_error.Error("Non-existent resource didn't return HTTP 404")
+
+  # Test HTTP Not Implemented
+  for method in ["PUT", "POST", "DELETE"]:
+    try:
+      _DoTests([("/version", None, method, None)])
+    except rapi.client.GanetiApiError, err:
+      AssertEqual(err.code, 501)
+    else:
+      raise qa_error.Error("Non-implemented method didn't fail")
+
 
 def TestInstance(instance):
   """Testing getting instance(s) info via remote API.
-- 
GitLab