Ensure we set the company values correctly in the data structure.
diff --git a/api.go b/api.go index 477eebd..8afed5e 100644 --- a/api.go +++ b/api.go
@@ -13,9 +13,10 @@ ExpiresAt int64 `json:"expiresAt"` IssuedAt int64 `json:"issuedAt"` Status string `json:"status"` + Type string `json:"cType"` RedirectionURIs string `json:"redirectionURIs"` - DeveloperAppId string `json:"developerId"` - DeveloperAppNam string `json:"developerAppName"` + AppId string `json:"cmpydevId"` + AppName string `json:"cmpydevAppName"` } type errResultDetail struct { @@ -114,7 +115,8 @@ c.status, a.callback_url, ad.name, - ad.id + ad.id, + "developer" as ctype FROM APP_CREDENTIAL AS c INNER JOIN APP AS a ON c.app_id = a.id @@ -131,7 +133,7 @@ AND UPPER(a.status) = 'APPROVED' AND c.id = $1 AND c.tenant_id = $2) - UNION ALL + UNION SELECT ap.api_resources, ap.environments, @@ -139,7 +141,8 @@ c.status, a.callback_url, ad.name, - ad.id + ad.id, + "company" as ctype FROM APP_CREDENTIAL AS c INNER JOIN APP AS a ON c.app_id = a.id @@ -158,10 +161,10 @@ AND c.tenant_id = $2) ;` - var status, redirectionURIs, developerAppName, developerId, resName, resEnv string + var status, redirectionURIs, cmpydevAppName, cmpydevId, resName, resEnv, cType string var issuedAt int64 err := db.QueryRow(sSql, key, tenantId).Scan(&resName, &resEnv, &issuedAt, &status, - &redirectionURIs, &developerAppName, &developerId) + &redirectionURIs, &cmpydevAppName, &cmpydevId, &cType) switch { case err == sql.ErrNoRows: reason := "API Key verify failed for (" + key + ", " + scopeuuid + ", " + path + ")" @@ -203,8 +206,9 @@ IssuedAt: issuedAt, Status: status, RedirectionURIs: redirectionURIs, - DeveloperAppId: developerId, - DeveloperAppNam: developerAppName}, + Type: cType, + AppId: cmpydevId, + AppName: cmpydevAppName}, } return json.Marshal(resp) }
diff --git a/api_test.go b/api_test.go index 2e4e76f..7222341 100644 --- a/api_test.go +++ b/api_test.go
@@ -140,6 +140,7 @@ var respj kmsResponseSuccess json.Unmarshal(rsp, &respj) Expect(respj.Type).Should(Equal("APIKeyContext")) + Expect(respj.RspInfo.Type).Should(Equal("developer")) Expect(respj.RspInfo.Key).Should(Equal("app_credential_" + resulti)) } }) @@ -159,6 +160,7 @@ var respj kmsResponseSuccess json.Unmarshal(rsp, &respj) Expect(respj.Type).Should(Equal("APIKeyContext")) + Expect(respj.RspInfo.Type).Should(Equal("company")) Expect(respj.RspInfo.Key).Should(Equal("app_credential_" + resulti)) } })
diff --git a/listener_test.go b/listener_test.go index 243d25a..72e76f2 100644 --- a/listener_test.go +++ b/listener_test.go
@@ -163,6 +163,7 @@ json.Unmarshal(rsp, &respj) Expect(respj.Type).Should(Equal("APIKeyContext")) Expect(respj.RspInfo.Key).Should(Equal("ch_app_credential_2")) + Expect(respj.RspInfo.Type).Should(Equal("developer")) closed = 1 close(done) }, @@ -181,7 +182,7 @@ /* API Product */ srvItems := common.Row{ "id": { - Value: "ch_api_product_2", + Value: "ch_api_product_5", }, "api_resources": { Value: "{}", @@ -197,25 +198,10 @@ }, } - /* DEVELOPER */ - devItems := common.Row{ - "id": { - Value: "ch_developer_id_2", - }, - "status": { - Value: "Active", - }, - "tenant_id": { - Value: "tenant_id_0", - }, - "_change_selector": { - Value: "test_org0", - }, - } /* COMPANY */ companyItems := common.Row{ "id": { - Value: "ch_company_id_2", + Value: "ch_company_id_5", }, "status": { Value: "Active", @@ -236,7 +222,7 @@ /* COMPANY_DEVELOPER */ companyDeveloperItems := common.Row{ "id": { - Value: "ch_developer_id_2", + Value: "ch_developer_id_5", }, "tenant_id": { Value: "tenant_id_0", @@ -245,20 +231,20 @@ Value: "test_org0", }, "company_id": { - Value: "ch_company_id_2", + Value: "ch_company_id_5", }, "developer_id": { - Value: "ch_developer_id_2", + Value: "ch_developer_id_5", }, } /* APP */ appItems := common.Row{ "id": { - Value: "ch_application_id_2", + Value: "ch_application_id_5", }, "company_id": { - Value: "ch_company_id_2", + Value: "ch_company_id_5", }, "status": { Value: "Approved", @@ -270,17 +256,17 @@ Value: "test_org0", }, "parent_id": { - Value: "ch_company_id_2", + Value: "ch_company_id_5", }, } /* CRED */ credItems := common.Row{ "id": { - Value: "ch_app_credential_2", + Value: "ch_app_credential_5", }, "app_id": { - Value: "ch_application_id_2", + Value: "ch_application_id_5", }, "tenant_id": { Value: "tenant_id_0", @@ -296,13 +282,13 @@ /* APP_CRED_APIPRD_MAPPER */ mpItems := common.Row{ "apiprdt_id": { - Value: "ch_api_product_2", + Value: "ch_api_product_5", }, "app_id": { - Value: "ch_application_id_2", + Value: "ch_application_id_5", }, "appcred_id": { - Value: "ch_app_credential_2", + Value: "ch_app_credential_5", }, "status": { Value: "Approved", @@ -321,11 +307,7 @@ NewRow: srvItems, Operation: 1, }, - { - Table: "kms.developer", - NewRow: devItems, - Operation: 1, - }, + { Table: "kms.app", NewRow: appItems, @@ -364,7 +346,7 @@ return } v := url.Values{ - "key": []string{"ch_app_credential_2"}, + "key": []string{"ch_app_credential_5"}, "uriPath": []string{"/test"}, "scopeuuid": []string{"XYZ"}, "action": []string{"verify"}, @@ -373,8 +355,9 @@ Expect(err).ShouldNot(HaveOccurred()) var respj kmsResponseSuccess json.Unmarshal(rsp, &respj) + Expect(respj.RspInfo.Type).Should(Equal("company")) Expect(respj.Type).Should(Equal("APIKeyContext")) - Expect(respj.RspInfo.Key).Should(Equal("ch_app_credential_2")) + Expect(respj.RspInfo.Key).Should(Equal("ch_app_credential_5")) closed = 1 close(done) }, @@ -673,6 +656,7 @@ json.Unmarshal(rsp, &respj) Expect(respj.Type).Should(Equal("APIKeyContext")) Expect(respj.RspInfo.Key).Should(Equal("ch_app_credential_1")) + Expect(respj.RspInfo.Type).Should(Equal("developer")) closed = 1 close(done) }, @@ -1074,6 +1058,7 @@ json.Unmarshal(rsp, &respj) Expect(respj.Type).Should(Equal("APIKeyContext")) Expect(respj.RspInfo.Key).Should(Equal("ch_app_credential_1")) + closed = 1 close(done) },