Commit 70326c47 authored by Manuel Angel Jimenez Quesada's avatar Manuel Angel Jimenez Quesada
Browse files

Solve some Typo error, include test of Rest interface and gRPC interface

parent 515f8113
Loading
Loading
Loading
Loading
+1 −1
Original line number Diff line number Diff line
@@ -30,7 +30,7 @@ class ZtpServerServiceServicerImpl(ZtpServerServiceServicer):
    @safe_and_metered_rpc_method(METRICS_POOL, LOGGER)
    def GetProvisioningScript(self, request : ProvisioningScriptName, context : grpc.ServicerContext) -> ProvisioningScript:
        try:
            provisioningPath = os.path.join(os.path.dirname(os.path.abspath(__file__)), '..', '..', 'data', request.scriptname)
            provisioningPath = os.path.join(os.path.dirname(os.path.abspath(__file__)), '..', 'data', request.scriptname)
            with open(provisioningPath, 'r') as provisioning_file:
                provisioning_content = provisioning_file.read()
            return ProvisioningScript(script=provisioning_content)
+0 −1
Original line number Diff line number Diff line
@@ -33,5 +33,4 @@ class config(_Resource):
    @HTTP_AUTH.login_required
    def get(self, config_db : str):
        content = returnConfigFile(config_db)

        return content
+2 −2
Original line number Diff line number Diff line
@@ -14,7 +14,7 @@

from ztp_server.service.rest_server.RestServer import RestServer
from .Resources import (
    Config
    config
)

URL_PREFIX = '/provisioning'
@@ -22,7 +22,7 @@ URL_PREFIX = '/provisioning'
# Use 'path' type since some identifiers might contain char '/' and Flask is unable to recognize them in 'string' type.
RESOURCES = [
    # (endpoint_name, resource_class, resource_url)
    ('api.config',    Config,    '/config/<path:config_db>'),
    ('api.config',    config,    '/config/<path:config_db>'),
]

def register_ztp_provisioning(rest_server : RestServer):
+16 −3
Original line number Diff line number Diff line
@@ -21,9 +21,16 @@ from common.Settings import (
    ENVVAR_SUFIX_SERVICE_PORT_HTTP, get_env_var_name
)

from ztp_server.service.rest_server import RestServer
#import ztp_server.service.rest_server as rs = rs.RestServer()
#from ztp_server.service.rest_server as rs _rest_server = rs.RestServer()import RestServer

from common.tools.service.GenericRestServer import GenericRestServer
#from common.Settings import get_service_baseurl_http, get_service_port_http

from ztp_server.service.rest_server.ztpServer_plugins.ztp_provisioning_api import register_ztp_provisioning

from ztp_server.client.ZtpClient import ZtpClient

from .Constants import (
    LOCAL_HOST, MOCKSERVICE_PORT, ZTP_SERVICE_BASE_URL, ZTP_SERVICE_PORT,
    USERNAME, PASSWORD
@@ -34,7 +41,7 @@ os.environ[get_env_var_name(ServiceNameEnum.ZTP_SERVER, ENVVAR_SUFIX_SERVICE_POR

@pytest.fixture(scope='session')
def ztp_server_application():
    _rest_server = RestServer()
    _rest_server = GenericRestServer(ZTP_SERVICE_PORT, None, bind_address='127.0.0.1')
    register_ztp_provisioning(_rest_server)
    _rest_server.start()
    time.sleep(1)   # bring time for the server to start
@@ -42,6 +49,12 @@ def ztp_server_application():
    _rest_server.shutdown()
    _rest_server.join()

@pytest.fixture(scope='session')
def ztp_client():    # pylint: disable=redefined-outer-name
    _client = ZtpClient()
    yield _client
    _client.close()

class RestRequestMethod(enum.Enum):
    GET    = 'get'
    POST   = 'post'
+14 −0
Original line number Diff line number Diff line
# Copyright 2022-2025 ETSI SDG TeraFlowSDN (TFS) (https://tfs.etsi.org/)
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
#      http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.
Loading