Commit 682fa2b9 by Czémán Arnold

minor modifications

parent 01bf8c3a
Pipeline #105 failed with stage
in 0 seconds
from django.contrib import admin
# Register your models here.
from django.db import models
# Create your models here.
import requests import requests
from requests.exceptions import ConnectionError
import json import json
# import urllib3 # import urllib3
...@@ -18,7 +17,6 @@ loginData = {"username": username, "password": password} ...@@ -18,7 +17,6 @@ loginData = {"username": username, "password": password}
# automatikusan benne maradjon az osszes keresunkben # automatikusan benne maradjon az osszes keresunkben
with requests.Session() as session: with requests.Session() as session:
headers = {"Content-Type": "application/json", "Referer": server} headers = {"Content-Type": "application/json", "Referer": server}
try:
# Csrf-Token a bejelentkezeshez # Csrf-Token a bejelentkezeshez
req = session.get(server + "occi/login/", headers=headers, req = session.get(server + "occi/login/", headers=headers,
verify=False) verify=False)
...@@ -149,7 +147,6 @@ with requests.Session() as session: ...@@ -149,7 +147,6 @@ with requests.Session() as session:
print(json.dumps(json.loads(req.text), sort_keys=True, print(json.dumps(json.loads(req.text), sort_keys=True,
indent=4, separators=(",", ": "))) indent=4, separators=(",", ": ")))
print print
# vm krealas # vm krealas
try: try:
headers["X-CSRFToken"] = req.cookies["csrftoken"] headers["X-CSRFToken"] = req.cookies["csrftoken"]
...@@ -198,5 +195,3 @@ with requests.Session() as session: ...@@ -198,5 +195,3 @@ with requests.Session() as session:
print print
print(json.dumps(json.loads(req.text), sort_keys=True, print(json.dumps(json.loads(req.text), sort_keys=True,
indent=4, separators=(",", ": "))) indent=4, separators=(",", ": ")))
except ConnectionError as e:
print(e)
...@@ -215,8 +215,8 @@ CREDENTIALS_MIXIN = Mixin("http://circlecloud.org/occi/infrastructure#", ...@@ -215,8 +215,8 @@ CREDENTIALS_MIXIN = Mixin("http://circlecloud.org/occi/infrastructure#",
"credentials", "credentials",
title="Credentials Mixin", title="Credentials Mixin",
attributes=CREDENTIALS_ATTRIBUTES, attributes=CREDENTIALS_ATTRIBUTES,
applies="http://schemas.ogf.org/occi/infrastructure" + applies="http://schemas.ogf.org/occi/" +
"#compute") "infrastructure#compute")
OS_TPL_MIXIN = Mixin("http://schemas.ogf.org/occi/infrastructure#", OS_TPL_MIXIN = Mixin("http://schemas.ogf.org/occi/infrastructure#",
"os_tpl", "os_tpl",
......
...@@ -87,8 +87,8 @@ def validate_request(request, authentication_required=True, ...@@ -87,8 +87,8 @@ def validate_request(request, authentication_required=True,
if has_data: if has_data:
# checking content type # checking content type
if request.META.get("CONTENT_TYPE") != "application/json": if request.META.get("CONTENT_TYPE") != "application/json":
raise OcciRequestNotValid("Only application/json content type is " + raise OcciRequestNotValid("Only application/json content type" +
"allowed.") " is allowed.")
# checking if the data is a valid json # checking if the data is a valid json
try: try:
data = json.loads(request.body.decode("utf-8")) data = json.loads(request.body.decode("utf-8"))
......
from django.test import TestCase
# Create your tests here.
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or sign in to comment