Company related changes.
diff --git a/api.go b/api.go
index eb5b6b2..66da238 100644
--- a/api.go
+++ b/api.go
@@ -124,7 +124,8 @@
a.callback_url,
ad.name,
ad.id
- FROM APP_CREDENTIAL AS c
+ FROM
+ APP_CREDENTIAL AS c
INNER JOIN APP AS a ON c.app_id = a.id
INNER JOIN ALL_DEVELOPERS AS ad
ON (ad.id = a.company_id OR ad.id = a.developer_id)
diff --git a/api_test.go b/api_test.go
index bc545e2..2e4e76f 100644
--- a/api_test.go
+++ b/api_test.go
@@ -33,20 +33,6 @@
Expect(res).Should(BeTrue())
}
- // companies
- for i := 0; i < 10; i++ {
- row := generateTestCompany(i)
- res := insertCompanies([]common.Row{row}, txn)
- Expect(res).Should(BeTrue())
- }
-
- // company developers
- for i := 0; i < 10; i++ {
- row := generateTestCompanyDeveloper(i)
- res := insertCompanyDevelopers([]common.Row{row}, txn)
- Expect(res).Should(BeTrue())
- }
-
// application
var j, k int
for i := 0; i < 10; i++ {
@@ -70,6 +56,51 @@
Expect(res).Should(BeTrue())
}
+ // Following are data for company
+ // api products
+ for i := 100; i < 110; i++ {
+ row := generateTestApiProduct(i)
+ res := insertAPIproducts([]common.Row{row}, txn)
+ Expect(res).Should(BeTrue())
+ }
+
+ // companies
+ for i := 100; i < 110; i++ {
+ row := generateTestCompany(i)
+ res := insertCompanies([]common.Row{row}, txn)
+ Expect(res).Should(BeTrue())
+ }
+
+ // company developers
+ for i := 100; i < 110; i++ {
+ row := generateTestCompanyDeveloper(i)
+ res := insertCompanyDevelopers([]common.Row{row}, txn)
+ Expect(res).Should(BeTrue())
+ }
+
+ // application
+ k = 100
+ for i := 100; i < 110; i++ {
+ for j = k; j < 100+k; j++ {
+ row := generateTestAppCompany(j, i)
+ res := insertApplications([]common.Row{row}, txn)
+ Expect(res).Should(BeTrue())
+ }
+ k = j
+ }
+ // app credentials
+ for i := 100; i < 110; i++ {
+ row := generateTestAppCreds(i)
+ res := insertCredentials([]common.Row{row}, txn)
+ Expect(res).Should(BeTrue())
+ }
+ // api product mapper
+ for i := 100; i < 110; i++ {
+ row := generateTestApiProductMapper(i)
+ res := insertAPIProductMappers([]common.Row{row}, txn)
+ Expect(res).Should(BeTrue())
+ }
+
txn.Commit()
var count int64
db.QueryRow("select count(*) from data_scope").Scan(&count)
@@ -94,7 +125,7 @@
})
- It("should successfully verify good keys", func() {
+ It("should successfully verify good Developer keys", func() {
for i := 1; i < 10; i++ {
resulti := strconv.FormatInt(int64(i), 10)
v := url.Values{
@@ -113,6 +144,25 @@
}
})
+ It("should successfully verify good Company keys", func() {
+ for i := 100; i < 110; i++ {
+ resulti := strconv.FormatInt(int64(i), 10)
+ v := url.Values{
+ "key": []string{"app_credential_" + resulti},
+ "uriPath": []string{"/test"},
+ "scopeuuid": []string{"ABCDE"},
+ "action": []string{"verify"},
+ }
+ rsp, err := verifyAPIKey(v)
+ Expect(err).ShouldNot(HaveOccurred())
+
+ var respj kmsResponseSuccess
+ json.Unmarshal(rsp, &respj)
+ Expect(respj.Type).Should(Equal("APIKeyContext"))
+ Expect(respj.RspInfo.Key).Should(Equal("app_credential_" + resulti))
+ }
+ })
+
It("Positive DB test for Delete operations", func() {
db := getDB()
txn, err := db.Begin()
@@ -147,7 +197,7 @@
Expect(res).Should(BeTrue())
}
- for i := 0; i < 10; i++ {
+ for i := 100; i < 110; i++ {
row := generateTestCompanyDeveloper(i)
res := deleteCompanyDeveloper(row, txn)
Expect(res).Should(BeTrue())
diff --git a/listener_test.go b/listener_test.go
index 03641b2..d285f7b 100644
--- a/listener_test.go
+++ b/listener_test.go
@@ -106,6 +106,9 @@
"_change_selector": {
Value: "test_org0",
},
+ "parent_id": {
+ Value: "ch_developer_id_2",
+ },
}
/* CRED */
@@ -452,6 +455,9 @@
"_change_selector": {
Value: "test_org0",
},
+ "parent_id": {
+ Value: "ch_developer_id_1",
+ },
}
/* CRED */
diff --git a/test_helper.go b/test_helper.go
index 61f8f00..44a341b 100644
--- a/test_helper.go
+++ b/test_helper.go
@@ -5,11 +5,11 @@
"strconv"
)
-func convertSuffix(i int) string{
+func convertSuffix(i int) string {
return strconv.FormatInt(int64(i), 10)
}
-func generateTestApiProduct(suffix int) common.Row{
+func generateTestApiProduct(suffix int) common.Row {
return common.Row{
"id": {
Value: "api_product_" + convertSuffix(suffix),
@@ -30,7 +30,7 @@
}
func generateTestDeveloper(suffix int) common.Row {
- return common.Row{
+ return common.Row{
"id": {
Value: "developer_id_" + convertSuffix(suffix),
},
@@ -115,6 +115,35 @@
"_change_selector": {
Value: "Org_0",
},
+ "parent_id": {
+ Value: "developer_id_" + convertSuffix(suffix2),
+ },
+ }
+}
+
+func generateTestAppCompany(suffix1, suffix2 int) common.Row {
+ return common.Row{
+ "id": {
+ Value: "application_id_" + convertSuffix(suffix1),
+ },
+ "company_id": {
+ Value: "company_id_" + convertSuffix(suffix2),
+ },
+ "status": {
+ Value: "Approved",
+ },
+ "tenant_id": {
+ Value: "tenant_id_xxxx",
+ },
+ "callback_url": {
+ Value: "http://apigee.com",
+ },
+ "_change_selector": {
+ Value: "Org_0",
+ },
+ "parent_id": {
+ Value: "company_id_" + convertSuffix(suffix2),
+ },
}
}
@@ -163,5 +192,3 @@
},
}
}
-
-