Skip to content

Commit

Permalink
DCB-130 Extend Application metadata with preferred field
Browse files Browse the repository at this point in the history
  • Loading branch information
lukasz-andrzejak committed Aug 31, 2023
1 parent 1a15b98 commit ba7b077
Show file tree
Hide file tree
Showing 19 changed files with 296 additions and 55 deletions.
2 changes: 1 addition & 1 deletion LICENSE-THIRD-PARTY.txt
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ Lists of 149 third-party dependencies.
(The Apache Software License, Version 2.0) Java Faker (com.github.javafaker:javafaker:1.0.2 - http://github.com/DiUS/java-faker)
(The Apache Software License, Version 2.0) Generex (com.github.mifmif:generex:1.0.2 - https://github.com/mifmif/Generex/tree/master)
(The Apache Software License, Version 2.0) project ':json-path' (com.jayway.jsonpath:json-path:2.6.0 - https://github.com/jayway/JsonPath)
(Apache License, Version 2.0) appstore-metadata-service (com.lgi.appstore.metadata:appstore-metadata-service:0.1.10-SNAPSHOT - https://spring.io/projects/spring-boot/appstore-metadata-service-parent/appstore-metadata-service)
(Apache License, Version 2.0) appstore-metadata-service (com.lgi.appstore.metadata:appstore-metadata-service:0.1.11-SNAPSHOT - https://spring.io/projects/spring-boot/appstore-metadata-service-parent/appstore-metadata-service)
(Eclipse Distribution License - v 1.0) Old JAXB Runtime (com.sun.xml.bind:jaxb-impl:2.3.3 - https://eclipse-ee4j.github.io/jaxb-ri/jaxb-bundles/jaxb-impl)
(Apache License 2.0) JSON library from Android SDK (com.vaadin.external.google:android-json:0.0.20131108.vaadin1 - http://developer.android.com/sdk)
(The Apache Software License, Version 2.0) HikariCP (com.zaxxer:HikariCP:4.0.3 - https://github.com/brettwooldridge/HikariCP)
Expand Down
1 change: 1 addition & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -102,6 +102,7 @@ curl --location --request POST 'http://localhost:8081/as3/maintainers/lgi/apps'
"url": "http://url/fancyappl",
"visible": true,
"encryption": false,
"preferred": false,
"ociImageUrl": "myregistry.local:5000/testing/test-image",
"latest" : true,
"type": "fancy_applications",
Expand Down
3 changes: 3 additions & 0 deletions appstore-metadata-service-tests/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -139,6 +139,7 @@ curl -v -X POST -H "Content-type: application/json" -d '{
"version": "1.2.3",
"visible": true,
"encryption": false,
"preferred": false,
"ociImageUrl": "myregistry.local:5000/testing/test-image"
},
"requirements": {
Expand Down Expand Up @@ -182,6 +183,7 @@ curl -v -X POST -H "Content-type: application/json" -d '{
"version": "1.2.3",
"visible": true,
"encryption": false,
"preferred": false,
"ociImageUrl": "myregistry.local:5000/testing/test-image"
},
"requirements": {
Expand Down Expand Up @@ -219,6 +221,7 @@ curl -v -X POST -H "Content-type: application/json" -d '{
"version": "0.0.1",
"visible": true,
"encryption": false,
"preferred": false,
"ociImageUrl": "myregistry.local:5000/testing/test-image"
},
"requirements": {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -49,6 +49,7 @@ import static com.lgi.appstore.metadata.test.framework.model.response.Applicatio
import static com.lgi.appstore.metadata.test.framework.model.response.ApplicationDetailsPath.FIELD_ICON
import static com.lgi.appstore.metadata.test.framework.model.response.ApplicationDetailsPath.FIELD_NAME
import static com.lgi.appstore.metadata.test.framework.model.response.ApplicationDetailsPath.FIELD_OCI_IMAGE_URL
import static com.lgi.appstore.metadata.test.framework.model.response.ApplicationDetailsPath.FIELD_PREFERRED
import static com.lgi.appstore.metadata.test.framework.model.response.ApplicationDetailsPath.FIELD_TYPE
import static com.lgi.appstore.metadata.test.framework.model.response.ApplicationDetailsPath.FIELD_SIZE
import static com.lgi.appstore.metadata.test.framework.model.response.ApplicationDetailsPath.FIELD_URL
Expand Down Expand Up @@ -127,7 +128,7 @@ class MaintainerApiFTSpec extends AsmsFeatureSpecBase {
def "create non-existing app and view details for #behavior"() {
given: "developer create 2 applications: first with 2 versions (incl. hidden latest) and second with only one version"
Application app1v1 = builder().fromDefaults()
.withId(appId).withVersion(v1).forCreate()
.withId(appId).withVersion(v1).withPreferred(isV1Preferred).forCreate()
Application app1v2 = builder().fromDefaults()
.withId(appId).withVersion(v2).withVisible(isV2Visible).forCreate()
Application app2v1 = builder().fromDefaults()
Expand All @@ -151,13 +152,14 @@ class MaintainerApiFTSpec extends AsmsFeatureSpecBase {
v2 == returnedV ? field().header().visible().from(jsonBody) == isV2Visible : IGNORE_THIS_ASSERTION

where:
behavior | appId | v1 | v2 | isV2Visible | queryAppKey || httpStatus | returnedV
"no version specified - fallback to highest v" | randId() | "0.10.0" | "1.1.0" | true | appId || SC_OK | v2
"accepting 'latest' keyword" | randId() | "1.0.0" | "0.10.0" | true | appId + ":latest" || SC_OK | v1
"query for specific version" | randId() | "0.1.0" | "1.0.0" | true | appId + ":" + v1 || SC_OK | v1
"fallback to latest that is hidden" | randId() | "1.0.0" | "2.0.0" | false | appId || SC_OK | v2
"not existing id" | randId() | "10.0.0" | "0.1.0" | true | "App3" || SC_NOT_FOUND | _
"not existing version" | randId() | "10.0.0" | "0.1.0" | true | appId + ":3.0" || SC_NOT_FOUND | _
behavior | appId | v1 | isV1Preferred | v2 | isV2Visible | queryAppKey || httpStatus | returnedV
"no version specified - fallback to highest v" | randId() | "0.10.0" | false | "1.1.0" | true | appId || SC_OK | v2
"accepting 'latest' keyword" | randId() | "1.0.0" | false | "0.10.0" | true | appId + ":latest" || SC_OK | v1
"query for specific version" | randId() | "0.1.0" | false | "1.0.0" | true | appId + ":" + v1 || SC_OK | v1
"fallback to latest that is hidden" | randId() | "1.0.0" | false | "2.0.0" | false | appId || SC_OK | v2
"not existing id" | randId() | "10.0.0" | false | "0.1.0" | true | "App3" || SC_NOT_FOUND | _
"not existing version" | randId() | "10.0.0" | false | "0.1.0" | true | appId + ":3.0" || SC_NOT_FOUND | _
"fallback preferred version v1" | randId() | "0.10.0" | true | "1.1.0" | true | appId || SC_OK | v1
}

def "developer cannot access other developer application (GET/PUT/DELETE)"() {
Expand Down Expand Up @@ -211,6 +213,7 @@ class MaintainerApiFTSpec extends AsmsFeatureSpecBase {
and: "application has v1 with some metadata"
def v1Visible = false
def v1Encryption = false
def v1Preferred = false
def v1OciImageUrl = "v1OciImageUrl"
def v1Name = "v1Name"
def v1Description = "v1Description"
Expand Down Expand Up @@ -240,6 +243,7 @@ class MaintainerApiFTSpec extends AsmsFeatureSpecBase {
.withVersion(v1)
.withVisible(v1Visible)
.withEncryption(v1Encryption)
.withPreferred(v1Preferred)
.withOciImageUrl(v1OciImageUrl)
.withName(v1Name)
.withDescription(v1Description)
Expand All @@ -258,6 +262,7 @@ class MaintainerApiFTSpec extends AsmsFeatureSpecBase {
and: "application has v2 with completely different metadata"
def v2Visible = true
def v2Encryption = true
def v2Preferred = true
def v2OciImageUrl = "v2OciImageUrl"
def v2Name = "v2NewName"
def v2Description = "v2NewDescription"
Expand Down Expand Up @@ -286,6 +291,7 @@ class MaintainerApiFTSpec extends AsmsFeatureSpecBase {
.withVersion(v2)
.withVisible(v2Visible)
.withEncryption(v2Encryption)
.withPreferred(v2Preferred)
.withOciImageUrl(v2OciImageUrl)
.withName(v2Name)
.withDescription(v2Description)
Expand Down Expand Up @@ -318,6 +324,7 @@ class MaintainerApiFTSpec extends AsmsFeatureSpecBase {
field().header().version().from(theBody1) == v1
field().header().visible().from(theBody1) == v1Visible
field().header().encryption().from(theBody1) == v1Encryption
field().header().preferred().from(theBody1) == v1Preferred
field().header().ociImageUrl().from(theBody1) == v1OciImageUrl
field().header().name().from(theBody1) == v1Name
field().header().category().from(theBody1) == String.valueOf(v1Category)
Expand Down Expand Up @@ -376,6 +383,7 @@ class MaintainerApiFTSpec extends AsmsFeatureSpecBase {
field().header().version().from(theBody2) == v2
field().header().visible().from(theBody2) == v2Visible
field().header().encryption().from(theBody2) == v2Encryption
field().header().preferred().from(theBody2) == v2Preferred
field().header().ociImageUrl().from(theBody2) == v2OciImageUrl
field().header().category().from(theBody2) == String.valueOf(v2Category)
field().header().name().from(theBody2) == v2Name
Expand Down Expand Up @@ -446,6 +454,7 @@ class MaintainerApiFTSpec extends AsmsFeatureSpecBase {
field | valueBefore || valueAfter
FIELD_VISIBLE | Boolean.FALSE || Boolean.TRUE
FIELD_ENCRYPTION | Boolean.FALSE || Boolean.TRUE
FIELD_PREFERRED | Boolean.FALSE || Boolean.TRUE
FIELD_NAME | "appNameBefore" || "appNameAfter"
FIELD_DESCRIPTION | "Description Before ąćęłóśżź" || "Description After €\\\\\\\\"
FIELD_CATEGORY | String.valueOf(Category.DEV) || String.valueOf(pickRandomCategory())
Expand Down Expand Up @@ -507,6 +516,7 @@ class MaintainerApiFTSpec extends AsmsFeatureSpecBase {
field | valueV1Before || valueV1After // must be different than the defaults
FIELD_VISIBLE | Boolean.TRUE || Boolean.FALSE
FIELD_ENCRYPTION | Boolean.FALSE || Boolean.TRUE
FIELD_PREFERRED | Boolean.FALSE || Boolean.TRUE
FIELD_NAME | "appNameBefore" || "appNameAfter"
FIELD_DESCRIPTION | "Description Before ąćęłóśżź" || "Description After €\\\\\\\\"
FIELD_CATEGORY | String.valueOf(Category.DEV) || String.valueOf(Category.RESOURCE)
Expand Down Expand Up @@ -667,7 +677,7 @@ class MaintainerApiFTSpec extends AsmsFeatureSpecBase {
dbSteps.listMaintainers()
Application app1v1 = builder().fromDefaults()
.withId(id1).withVersion(v1).forCreate()
.withId(id1).withVersion(v1).withPreferred(isV1Preferred).forCreate()
Application app1v2 = builder().fromDefaults()
.withId(id1).withVersion(v2).forCreate()
Application app2v1 = builder().fromDefaults()
Expand Down Expand Up @@ -706,12 +716,13 @@ class MaintainerApiFTSpec extends AsmsFeatureSpecBase {
}
where:
dev2Code | id1 | id2 | id3 | limit | offset | v1 | v2 | v3 | queryDevCode || possibleIds | possibleV | count | total | returnedLimit
"lgi2" | randId() | randId() | randId() | 3 | 0 | "0.0.11" | "0.1.0" | "1.1.0" | DEFAULT_DEV_CODE || [id1, id2] | [v1, v2] | 2 | 2 | limit
"lgi2" | randId() | randId() | randId() | null | 0 | "0.1.1" | "0.0.1" | "1.0.1" | dev2Code || [id3] | [v3] | 1 | 1 | DEFAULT_LIMIT
"lgi2" | randId() | randId() | randId() | 1 | 0 | "0.11.1" | "1.0.1" | "2.0.1" | DEFAULT_DEV_CODE || [id1, id2] | [v1, v2] | 1 | 2 | limit
"lgi2" | randId() | randId() | randId() | 1 | 1 | "0.1.1" | "0.0.1" | "1.0.1" | DEFAULT_DEV_CODE || [id1, id2] | [v1, v2] | 1 | 2 | limit
"lgi2" | randId() | randId() | randId() | 1 | 2 | "0.1.1" | "0.0.1" | "1.0.1" | DEFAULT_DEV_CODE || _ | _ | 0 | 2 | limit
dev2Code | id1 | id2 | id3 | limit | offset | v1 | v2 | v3 | isV1Preferred || queryDevCode || possibleIds | possibleV | count | total | returnedLimit
"lgi2" | randId() | randId() | randId() | 3 | 0 | "0.0.11" | "0.1.0" | "1.1.0" | false || DEFAULT_DEV_CODE || [id1, id2] | [v1, v2] | 2 | 2 | limit
"lgi2" | randId() | randId() | randId() | null | 0 | "0.1.1" | "0.0.1" | "1.0.1" | false || dev2Code || [id3] | [v3] | 1 | 1 | DEFAULT_LIMIT
"lgi2" | randId() | randId() | randId() | 1 | 0 | "0.11.1" | "1.0.1" | "2.0.1" | false || DEFAULT_DEV_CODE || [id1, id2] | [v1, v2] | 1 | 2 | limit
"lgi2" | randId() | randId() | randId() | 1 | 1 | "0.1.1" | "0.0.1" | "1.0.1" | false || DEFAULT_DEV_CODE || [id1, id2] | [v1, v2] | 1 | 2 | limit
"lgi2" | randId() | randId() | randId() | 1 | 2 | "0.1.1" | "0.0.1" | "1.0.1" | false || DEFAULT_DEV_CODE || _ | _ | 0 | 2 | limit
"lgi2" | randId() | randId() | randId() | null | 0 | "0.1.1" | "1.0.1" | "0.0.1" | true || DEFAULT_DEV_CODE || [id1, id2] | [v1] | 2 | 3 | DEFAULT_LIMIT
}
@Unroll
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -208,7 +208,7 @@ class StbApiFTSpec extends AsmsFeatureSpecBase {
.withId(appId).withVersion(v1).withType("application/vnd.rdk-app.dac.native").forCreate()
Application app1v2 = builder().fromDefaults()
.withId(appId).withVersion(v2).withType("application/vnd.rdk-app.dac.native")
.withVisible(isV2Visible).forCreate()
.withVisible(isV2Visible).withPreferred(isV2Preferred).forCreate()
Application app2v1 = builder().fromDefaults().withType("application/vnd.rdk-app.dac.native")
.withId("someOther_$appId").withVersion(v1) forCreate()

Expand All @@ -230,14 +230,15 @@ class StbApiFTSpec extends AsmsFeatureSpecBase {
receivedStatus == SC_OK ? !field().header().visible().isPresentIn(jsonBody) : IGNORE_THIS_ASSERTION

where:
behavior | appId | v1 | v2 | isV2Visible | queryAppKey || httpStatus | returnedV
"no version specified - fallback to highest v" | randId() | "1.0.0" | "0.10.0" | true | appId || SC_OK | v1
"accepting 'latest' keyword" | randId() | "0.0.10" | "0.1.0" | true | appId + ":latest" || SC_OK | v2
"query for specific version" | randId() | "0.1.0" | "1.0.0" | true | appId + ":" + v1 || SC_OK | v1
"no fallback to latest that is hidden" | randId() | "1.0.0" | "2.0.0" | false | appId || SC_OK | v1 // hidden version is not taken into the account for STB
"not existing id" | randId() | "10.0.0" | "0.1.0" | true | "App3" || SC_NOT_FOUND | _
"not existing version" | randId() | "10.0.0" | "20.0.0" | true | appId + ":3.0" || SC_NOT_FOUND | _
"query for specific version that is hidden" | randId() | "0.1.0" | "1.0.0" | false | appId + ":" + v2 || SC_NOT_FOUND | _ // STB cannot get details of hidden version
behavior | appId | v1 | v2 | isV2Preferred | isV2Visible | queryAppKey || httpStatus | returnedV
"no version specified - fallback to highest v" | randId() | "1.0.0" | "0.10.0" | false | true | appId || SC_OK | v1
"accepting 'latest' keyword" | randId() | "0.0.10" | "0.1.0" | false | true | appId + ":latest" || SC_OK | v2
"query for specific version" | randId() | "0.1.0" | "1.0.0" | false | true | appId + ":" + v1 || SC_OK | v1
"no fallback to latest that is hidden" | randId() | "1.0.0" | "2.0.0" | false | false | appId || SC_OK | v1 // hidden version is not taken into the account for STB
"not existing id" | randId() | "10.0.0" | "0.1.0" | false | true | "App3" || SC_NOT_FOUND | _
"not existing version" | randId() | "10.0.0" | "20.0.0" | false | true | appId + ":3.0" || SC_NOT_FOUND | _
"query for specific version that is hidden" | randId() | "0.1.0" | "1.0.0" | false | false | appId + ":" + v2 || SC_NOT_FOUND | _ // STB cannot get details of hidden version
"fallback preferred version v2" | randId() | "1.0.0" | "0.10.0" | true | true | appId || SC_OK | v2
}

def "details of each version contain separate information about app requirements, maintainer and all visible versions of the application"() {
Expand Down
Loading

0 comments on commit ba7b077

Please sign in to comment.