Skip to content

Commit

Permalink
Add encryption field in header section
Browse files Browse the repository at this point in the history
  • Loading branch information
lukasz-andrzejak committed Aug 9, 2023
1 parent 6e34d3e commit 1158dfe
Show file tree
Hide file tree
Showing 17 changed files with 153 additions and 12 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.8-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.9-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 @@ -101,6 +101,7 @@ curl --location --request POST 'http://localhost:8081/as3/maintainers/lgi/apps'
"description": "Description of Fancy application",
"url": "http://url/fancyappl",
"visible": true,
"encryption": 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 @@ -138,6 +138,7 @@ curl -v -X POST -H "Content-type: application/json" -d '{
"id": "com.libertyglobal.app.awesome",
"version": "1.2.3",
"visible": true,
"encryption": false,
"ociImageUrl": "myregistry.local:5000/testing/test-image"
},
"requirements": {
Expand Down Expand Up @@ -180,6 +181,7 @@ curl -v -X POST -H "Content-type: application/json" -d '{
"id": "com.libertyglobal.app.youi",
"version": "1.2.3",
"visible": true,
"encryption": false,
"ociImageUrl": "myregistry.local:5000/testing/test-image"
},
"requirements": {
Expand Down Expand Up @@ -216,6 +218,7 @@ curl -v -X POST -H "Content-type: application/json" -d '{
"id": "com.libertyglobal.app.flutter",
"version": "0.0.1",
"visible": true,
"encryption": false,
"ociImageUrl": "myregistry.local:5000/testing/test-image"
},
"requirements": {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -45,6 +45,7 @@ import static com.lgi.appstore.metadata.test.framework.model.request.QueryParams
import static com.lgi.appstore.metadata.test.framework.model.request.QueryParams.queryParams
import static com.lgi.appstore.metadata.test.framework.model.response.ApplicationDetailsPath.FIELD_CATEGORY
import static com.lgi.appstore.metadata.test.framework.model.response.ApplicationDetailsPath.FIELD_DESCRIPTION
import static com.lgi.appstore.metadata.test.framework.model.response.ApplicationDetailsPath.FIELD_ENCRYPTION
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
Expand Down Expand Up @@ -208,6 +209,7 @@ class MaintainerApiFTSpec extends AsmsFeatureSpecBase {
and: "application has v1 with some metadata"
def v1Visible = false
def v1Encryption = false
def v1OciImageUrl = "v1OciImageUrl"
def v1Name = "v1Name"
def v1Description = "v1Description"
Expand Down Expand Up @@ -236,6 +238,7 @@ class MaintainerApiFTSpec extends AsmsFeatureSpecBase {
.withId(appId)
.withVersion(v1)
.withVisible(v1Visible)
.withEncryption(v1Encryption)
.withOciImageUrl(v1OciImageUrl)
.withName(v1Name)
.withDescription(v1Description)
Expand All @@ -253,6 +256,7 @@ class MaintainerApiFTSpec extends AsmsFeatureSpecBase {
and: "application has v2 with completely different metadata"
def v2Visible = true
def v2Encryption = true
def v2OciImageUrl = "v2OciImageUrl"
def v2Name = "v2NewName"
def v2Description = "v2NewDescription"
Expand Down Expand Up @@ -280,6 +284,7 @@ class MaintainerApiFTSpec extends AsmsFeatureSpecBase {
Application appV2 = builder().fromDefaults().withId(appId)
.withVersion(v2)
.withVisible(v2Visible)
.withEncryption(v2Encryption)
.withOciImageUrl(v2OciImageUrl)
.withName(v2Name)
.withDescription(v2Description)
Expand Down Expand Up @@ -311,6 +316,7 @@ class MaintainerApiFTSpec extends AsmsFeatureSpecBase {
field().header().id().from(theBody1) == appId
field().header().version().from(theBody1) == v1
field().header().visible().from(theBody1) == v1Visible
field().header().encryption().from(theBody1) == v1Encryption
field().header().ociImageUrl().from(theBody1) == v1OciImageUrl
field().header().name().from(theBody1) == v1Name
field().header().category().from(theBody1) == String.valueOf(v1Category)
Expand All @@ -331,10 +337,11 @@ class MaintainerApiFTSpec extends AsmsFeatureSpecBase {
field().maintainer().homepage().from(theBody1) == DEFAULT_DEV_HOMEPAGE
field().maintainer().email().from(theBody1) == DEFAULT_DEV_EMAIL
and: "the body exposes version section with all versions and visibility information"
and: "the body exposes version section with all versions, visibility and encryption information"
assertThat(field().versions().from(theBody1)).asList().hasSize(2)
assertThat(field().versions().version().from(theBody1)).asList().containsExactly(v2, v1)
assertThat(field().versions().visible().from(theBody1)).asList().containsExactly(v2Visible, v1Visible)
assertThat(field().versions().encryption().from(theBody1)).asList().containsExactly(v2Encryption, v1Encryption)
and: "the body exposes requirements section with dependencies information"
assertThat(field().requirements().dependencies().id().from(theBody1)).asList().containsExactlyInAnyOrder(v1Dependency1Id, v1Dependency2Id)
Expand Down Expand Up @@ -368,6 +375,7 @@ class MaintainerApiFTSpec extends AsmsFeatureSpecBase {
field().header().id().from(theBody2) == appId
field().header().version().from(theBody2) == v2
field().header().visible().from(theBody2) == v2Visible
field().header().encryption().from(theBody2) == v2Encryption
field().header().ociImageUrl().from(theBody2) == v2OciImageUrl
field().header().category().from(theBody2) == String.valueOf(v2Category)
field().header().name().from(theBody2) == v2Name
Expand All @@ -382,10 +390,11 @@ class MaintainerApiFTSpec extends AsmsFeatureSpecBase {
field().maintainer().homepage().from(theBody2) == DEFAULT_DEV_HOMEPAGE
field().maintainer().email().from(theBody2) == DEFAULT_DEV_EMAIL
and: "the body exposes version section with all versions and visibility information"
and: "the body exposes version section with all versions, visibility and encryption information"
assertThat(field().versions().from(theBody2)).asList().hasSize(2)
assertThat(field().versions().version().from(theBody2)).asList().containsExactly(v2, v1)
assertThat(field().versions().visible().from(theBody2)).asList().containsExactly(v2Visible, v1Visible)
assertThat(field().versions().encryption().from(theBody2)).asList().containsExactly(v2Encryption, v1Encryption)
and: "the body exposes requirements section with dependencies information"
assertThat(field().requirements().dependencies().id().from(theBody2)).asList().containsExactlyInAnyOrder(v2Dependency1Id, v2Dependency2Id)
Expand Down Expand Up @@ -437,6 +446,7 @@ class MaintainerApiFTSpec extends AsmsFeatureSpecBase {
where:
field | valueBefore || valueAfter
FIELD_VISIBLE | Boolean.FALSE || Boolean.TRUE
FIELD_ENCRYPTION | 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 @@ -497,6 +507,7 @@ class MaintainerApiFTSpec extends AsmsFeatureSpecBase {
where:
field | valueV1Before || valueV1After // must be different than the defaults
FIELD_VISIBLE | Boolean.TRUE || Boolean.FALSE
FIELD_ENCRYPTION | 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
Original file line number Diff line number Diff line change
Expand Up @@ -363,10 +363,11 @@ class StbApiFTSpec extends AsmsFeatureSpecBase {
field().maintainer().homepage().from(theBody1) == DEFAULT_DEV_HOMEPAGE
field().maintainer().email().from(theBody1) == DEFAULT_DEV_EMAIL

and: "the body exposes version section with all versions and visibility information"
and: "the body exposes version section with all versions, visibility and encryption information"
assertThat(field().versions().from(theBody1)).asList().hasSize(2) // 3rd hidden version should not be exposed
assertThat(field().versions().version().from(theBody1)).asList().containsExactly(v2, v1)
assertThat(field().versions().visible().from(theBody1)).asList().containsExactly(null, null) // 'visible' field should not be exposed
assertThat(field().versions().encryption().from(theBody1)).asList().containsExactly(null, null) // 'encryption' field should not be exposed

and: "the body does not expose ociImageUrl"
field().header().ociImageUrl().from(theBody1) == null
Expand Down Expand Up @@ -414,10 +415,11 @@ class StbApiFTSpec extends AsmsFeatureSpecBase {
field().maintainer().homepage().from(theBody2) == DEFAULT_DEV_HOMEPAGE
field().maintainer().email().from(theBody2) == DEFAULT_DEV_EMAIL

and: "the body exposes version section with all versions and visibility information"
and: "the body exposes version section with all versions, visibility and encryption information"
assertThat(field().versions().from(theBody2)).asList().hasSize(2) // 3rd hidden version should not be exposed
assertThat(field().versions().version().from(theBody2)).asList().containsExactly(v2, v1)
assertThat(field().versions().visible().from(theBody2)).asList().containsExactly(null, null) // 'visible' field should not be exposed
assertThat(field().versions().encryption().from(theBody2)).asList().containsExactly(null, null) // 'encryption' field should not be exposed

and: "the body exposes requirements section with dependencies information"
assertThat(field().requirements().dependencies().id().from(theBody2)).asList().containsExactlyInAnyOrder(v2Dependency1Id, v2Dependency2Id)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -50,6 +50,7 @@ class DevApiFTSpecSanity extends AsmsSanitySpecBase {
def appId = randId()
def v1 = "1.0.1"
def v1Visible = false
def v1Encryption = false
def v1OciImageUrl = "myregistry.local:5000/testing/test-image"
def v1Name = "v1Name"
def v1Description = "v1Description"
Expand Down Expand Up @@ -84,6 +85,7 @@ class DevApiFTSpecSanity extends AsmsSanitySpecBase {
.withId(appId)
.withVersion(v1)
.withVisible(v1Visible)
.withEncryption(v1Encryption)
.withOciImageUrl(v1OciImageUrl)
.withName(v1Name)
.withDescription(v1Description)
Expand All @@ -103,6 +105,7 @@ class DevApiFTSpecSanity extends AsmsSanitySpecBase {
and: "application has v2 with completely different metadata"
def v2Visible = true
def v2Encryption = true
def v2OciImageUrl = "myregistry.local:5000/testing/test-image-updated"
def v2Name = "v2NewName"
def v2Description = "v2NewDescription"
Expand Down Expand Up @@ -136,6 +139,7 @@ class DevApiFTSpecSanity extends AsmsSanitySpecBase {
ApplicationForUpdate appV2 = builder().fromDefaults()
.withId(appId)
.withVisible(v2Visible)
.withEncryption(v2Encryption)
.withOciImageUrl(v2OciImageUrl)
.withName(v2Name)
.withDescription(v2Description)
Expand Down Expand Up @@ -168,6 +172,7 @@ class DevApiFTSpecSanity extends AsmsSanitySpecBase {
field().header().id().from(theBody1) == appId
field().header().version().from(theBody1) == v1
field().header().visible().from(theBody1) == v1Visible
field().header().encryption().from(theBody1) == v1Encryption
field().header().ociImageUrl().from(theBody1) == v1OciImageUrl
field().header().name().from(theBody1) == v1Name
field().header().category().from(theBody1) == String.valueOf(v1Category)
Expand All @@ -193,10 +198,11 @@ class DevApiFTSpecSanity extends AsmsSanitySpecBase {
field().maintainer().homepage().from(theBody1) == DEFAULT_DEV_HOMEPAGE
field().maintainer().email().from(theBody1) == DEFAULT_DEV_EMAIL
and: "the body exposes version section with all versions and visibility information"
and: "the body exposes version section with all versions, visibility and encryption information"
assertThat(field().versions().from(theBody1)).asList().hasSize(1)
field().versions().at(0).version().from(theBody1) == v1
field().versions().at(0).visible().from(theBody1) == v1Visible
field().versions().at(0).encryption().from(theBody1) == v1Encryption
and: "the body exposes requirements section with dependencies information"
assertThat(field().requirements().dependencies().id().from(theBody1)).asList().containsExactlyInAnyOrder(v1Dependency1Id, v1Dependency2Id)
Expand Down Expand Up @@ -229,11 +235,12 @@ class DevApiFTSpecSanity extends AsmsSanitySpecBase {
then: "expected response HTTP status should be success/200"
receivedStatus2 == SC_OK
and: "the body exposes requested version information but without 'visible' field and 'ociImageUrl' field"
and: "the body exposes requested version information but without fields: 'visible', 'encryption', 'ociImageUrl'"
JsonPath theBody2 = response2.jsonPath()
field().header().id().from(theBody2) == appId
field().header().version().from(theBody2) == v1
field().header().visible().from(theBody2) == null // STB should not see this field
field().header().encryption().from(theBody2) == null // STB should not see this field
field().header().ociImageUrl().from(theBody2) == null // STB should not see this field
field().header().category().from(theBody2) == String.valueOf(v2Category)
field().header().name().from(theBody2) == v2Name
Expand All @@ -253,10 +260,11 @@ class DevApiFTSpecSanity extends AsmsSanitySpecBase {
field().maintainer().homepage().from(theBody2) == DEFAULT_DEV_HOMEPAGE
field().maintainer().email().from(theBody2) == DEFAULT_DEV_EMAIL
and: "the body exposes version section with all versions and visibility information"
and: "the body exposes version section with all versions, visibility and encryption information"
assertThat(field().versions().from(theBody2)).asList().hasSize(1)
field().versions().at(0).version().from(theBody2) == v1
field().versions().at(0).visible().from(theBody2) == null // STB should not see this field
field().versions().at(0).encryption().from(theBody2) == null // STB should not see this field
and: "the body exposes requirements section with dependencies information"
assertThat(field().requirements().dependencies().id().from(theBody2)).asList().containsExactlyInAnyOrder(v2Dependency1Id, v2Dependency2Id)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -48,6 +48,7 @@ public class ApplicationMetadataBuilder {
private Integer headerSize;
private String headerIcon;
private Boolean headerVisible;
private Boolean headerEncryption;
private String headerOciImageUrl;
private Category headerCategory;
private List<Localization> headerLocalizations;
Expand Down Expand Up @@ -109,6 +110,11 @@ public ApplicationMetadataBuilder withVisible(Boolean headerVisible) {
return this;
}

public ApplicationMetadataBuilder withEncryption(Boolean headerEncryption) {
this.headerEncryption = headerEncryption;
return this;
}

public ApplicationMetadataBuilder withOciImageUrl(String headerOciImageUrl) {
this.headerOciImageUrl = headerOciImageUrl;
return this;
Expand Down Expand Up @@ -156,6 +162,9 @@ private ApplicationMetadataBuilder setFieldValue(String field, Object value) {
case ApplicationDetailsPath.FIELD_VISIBLE:
headerVisible = Boolean.valueOf(String.valueOf(value));
break;
case ApplicationDetailsPath.FIELD_ENCRYPTION:
headerEncryption = Boolean.valueOf(String.valueOf(value));
break;
case ApplicationDetailsPath.FIELD_OCI_IMAGE_URL:
headerOciImageUrl = String.valueOf(value);
break;
Expand Down Expand Up @@ -192,6 +201,7 @@ public ApplicationMetadataBuilder fromDefaults() {
this.headerSize = 10000000;
this.headerIcon = DataUtils.randomAppHeaderIcon();
this.headerVisible = Boolean.TRUE;
this.headerEncryption = Boolean.FALSE;
this.headerOciImageUrl = DataUtils.randomOciImageUrl();
this.headerCategory = Category.APPLICATION;
this.platform = new Platform().architecture(DataUtils.randomPlatformArch()).os(DataUtils.randomPlatformOs());
Expand All @@ -205,6 +215,7 @@ public ApplicationMetadataBuilder fromExisting(Application existingApplication)
headerId = existingHeader.getId();
headerVersion = existingHeader.getVersion();
headerVisible = existingHeader.isVisible();
headerEncryption = existingHeader.isEncryption();
headerOciImageUrl = existingHeader.getOciImageUrl();
headerType = existingHeader.getType();
headerCategory = existingHeader.getCategory();
Expand Down Expand Up @@ -233,6 +244,7 @@ public Application forCreate() {
.size(headerSize)
.icon(headerIcon)
.visible(headerVisible)
.encryption(headerEncryption)
.ociImageUrl(headerOciImageUrl)
.localization(headerLocalizations);

Expand All @@ -250,6 +262,7 @@ public ApplicationForUpdate forUpdate() {
.size(headerSize)
.icon(headerIcon)
.visible(headerVisible)
.encryption(headerEncryption)
.ociImageUrl(headerOciImageUrl)
.localization(headerLocalizations);

Expand Down
Loading

0 comments on commit 1158dfe

Please sign in to comment.