From d857dba045010a6d3f69845efbb40eaa6b927685 Mon Sep 17 00:00:00 2001 From: Konrad Bańka Date: Tue, 26 Nov 2019 11:21:39 +0100 Subject: Switch instantiation parameters source from user to sdnc parameters MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Issue-ID: MULTICLOUD-941 Signed-off-by: Konrad Bańka Change-Id: I3a6c67eb442023f64600b65f5af54a49117a8c51 --- src/k8splugin/api/brokerhandler.go | 12 +++++----- src/k8splugin/api/brokerhandler_test.go | 41 +++++++++++++++++++++++++++------ 2 files changed, 40 insertions(+), 13 deletions(-) diff --git a/src/k8splugin/api/brokerhandler.go b/src/k8splugin/api/brokerhandler.go index 669b539f..b377baf1 100644 --- a/src/k8splugin/api/brokerhandler.go +++ b/src/k8splugin/api/brokerhandler.go @@ -134,21 +134,21 @@ func (b brokerInstanceHandler) createHandler(w http.ResponseWriter, r *http.Requ return } - rbName := req.getAttributeValue(req.UserDirectives, "definition-name") + rbName := req.getAttributeValue(req.SDNCDirectives, "k8s-rb-definition-name") if rbName == "" { - http.Error(w, "definition-name is missing from user-directives", http.StatusBadRequest) + http.Error(w, "k8s-rb-definition-name is missing from sdnc-directives", http.StatusBadRequest) return } - rbVersion := req.getAttributeValue(req.UserDirectives, "definition-version") + rbVersion := req.getAttributeValue(req.SDNCDirectives, "k8s-rb-definition-version") if rbVersion == "" { - http.Error(w, "definition-version is missing from user-directives", http.StatusBadRequest) + http.Error(w, "k8s-rb-definition-version is missing from sdnc-directives", http.StatusBadRequest) return } - profileName := req.getAttributeValue(req.UserDirectives, "profile-name") + profileName := req.getAttributeValue(req.SDNCDirectives, "k8s-rb-profile-name") if profileName == "" { - http.Error(w, "profile-name is missing from user-directives", http.StatusBadRequest) + http.Error(w, "k8s-rb-profile-name is missing from sdnc-directives", http.StatusBadRequest) return } diff --git a/src/k8splugin/api/brokerhandler_test.go b/src/k8splugin/api/brokerhandler_test.go index 8ef5e184..00ca3b7b 100644 --- a/src/k8splugin/api/brokerhandler_test.go +++ b/src/k8splugin/api/brokerhandler_test.go @@ -54,11 +54,11 @@ func TestBrokerCreateHandler(t *testing.T) { "user_directives": { "attributes": [ { - "attribute_name": "definition-name", + "attribute_name": "k8s-rb-definition-name", "attribute_value": "test-rbdef" }, { - "attribute_name": "definition-version", + "attribute_name": "k8s-rb-definition-version", "attribute_value": "v1" } ] @@ -67,9 +67,9 @@ func TestBrokerCreateHandler(t *testing.T) { expectedCode: http.StatusBadRequest, }, { - label: "Succesfully create an Instance", + label: "Deprecated parameters passed (user_directives)", input: bytes.NewBuffer([]byte(`{ - "vf-module-model-customization-id": "84sdfkio938", + "vf-module-model-customization-id": "97sdfkio168", "sdnc_directives": { "attributes": [ { @@ -81,15 +81,42 @@ func TestBrokerCreateHandler(t *testing.T) { "user_directives": { "attributes": [ { - "attribute_name": "definition-name", + "attribute_name": "rb-definition-name", + "attribute_value": "test-rbdef" + }, + { + "attribute_name": "rb-definition-version", + "attribute_value": "v1" + }, + { + "attribute_name": "rb-profile-name", + "attribute_value": "profile1" + } + ] + } + }`)), + expectedCode: http.StatusBadRequest, + }, + { + label: "Succesfully create an Instance", + input: bytes.NewBuffer([]byte(`{ + "vf-module-model-customization-id": "84sdfkio938", + "sdnc_directives": { + "attributes": [ + { + "attribute_name": "vf_module_name", + "attribute_value": "test-vf-module-name" + }, + { + "attribute_name": "k8s-rb-definition-name", "attribute_value": "test-rbdef" }, { - "attribute_name": "definition-version", + "attribute_name": "k8s-rb-definition-version", "attribute_value": "v1" }, { - "attribute_name": "profile-name", + "attribute_name": "k8s-rb-profile-name", "attribute_value": "profile1" } ] -- cgit 1.2.3-korg