Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Added qodana #10

Merged
merged 2 commits into from
Jan 30, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
21 changes: 21 additions & 0 deletions .github/workflows/qodana_code_quality.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
name: Qodana
on:
workflow_dispatch:
pull_request:
push:
branches:
- main
- master
- onuratakan

jobs:
qodana:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v3
with:
fetch-depth: 0
- name: 'Qodana Scan'
uses: JetBrains/[email protected]
env:
QODANA_TOKEN: ${{ secrets.QODANA_TOKEN }}
29 changes: 29 additions & 0 deletions qodana.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
#-------------------------------------------------------------------------------#
# Qodana analysis is configured by qodana.yaml file #
# https://www.jetbrains.com/help/qodana/qodana-yaml.html #
#-------------------------------------------------------------------------------#
version: "1.0"

#Specify inspection profile for code analysis
profile:
name: qodana.starter

#Enable inspections
#include:
# - name: <SomeEnabledInspectionId>

#Disable inspections
#exclude:
# - name: <SomeDisabledInspectionId>
# paths:
# - <path/where/not/run/inspection>

#Execute shell command before Qodana execution (Applied in CI/CD pipeline)
#bootstrap: sh ./prepare-qodana.sh

#Install IDE plugins before Qodana execution (Applied in CI/CD pipeline)
#plugins:
# - id: <plugin.id> #(plugin id can be found at https://plugins.jetbrains.com)

#Specify Qodana linter for analysis (Applied in CI/CD pipeline)
linter: jetbrains/qodana-<linter>:latest
33 changes: 25 additions & 8 deletions tests/test_api.py
Original file line number Diff line number Diff line change
@@ -1,14 +1,10 @@
import contextlib
import requests
import time
import unittest
import os
import sys
import shutil
import copy
from unittest.mock import patch
import cloudpickle
import threading
import unittest

import cloudpickle
import requests
from waitress.server import create_server

sys.path.append(os.path.join(os.path.dirname(__file__), ".."))
Expand Down Expand Up @@ -278,6 +274,27 @@ def test_disable_admin(self):

self.assertEqual(the_user.is_admin, False)

def test_delete_user(self):
id = "test_delete_user"
the_user = AccessKey(id)
the_user.enable()

self.assertEqual(the_user.is_enable, True)
self.assertEqual(the_user.is_admin, False)

id_admin = "test_delete_user_admin"
the_admin_access_key = AccessKey(id_admin)
the_admin_access_key.enable()
the_admin_access_key.set_is_admin(True)

# Adding the id as user with add_admin_url endpoint
data = {"key": id}
response = requests.post("http://localhost:7777" + delete_user_url, auth=HTTPBasicAuth("", id_admin),
data=data)

self.assertEqual(the_user.is_enable, False)
self.assertEqual(the_user.is_admin, False)



backup = sys.argv
Expand Down
19 changes: 13 additions & 6 deletions upsonic_on_prem/api/operations/admin.py
Original file line number Diff line number Diff line change
@@ -1,12 +1,10 @@
from upsonic_on_prem.api import app

from upsonic_on_prem.api.urls import *

from upsonic_on_prem.utils import storage, AccessKey

from flask import jsonify
from flask import request

from upsonic_on_prem.api import app
from upsonic_on_prem.api.urls import *
from upsonic_on_prem.utils import AccessKey


@app.route(get_admins_url, methods=["get"])
def get_admins():
Expand Down Expand Up @@ -75,3 +73,12 @@ def disable_admin():

return jsonify(True)


@app.route(delete_user_url, methods=["POST"])
def delete_user():
key = request.form.get("key")

user = AccessKey(key)
user.delete()

return jsonify(True)
4 changes: 3 additions & 1 deletion upsonic_on_prem/api/urls.py
Original file line number Diff line number Diff line change
Expand Up @@ -15,4 +15,6 @@

enable_admin_url = "/enable_admin"

disable_admin_url = "/disable_admin"
disable_admin_url = "/disable_admin"

delete_user_url = "/delete_user"
Loading