Skip to content
This repository has been archived by the owner on Sep 15, 2023. It is now read-only.

Commit

Permalink
mock forceupdate for specific builds
Browse files Browse the repository at this point in the history
  • Loading branch information
ubhaller committed May 31, 2021
1 parent e6e4732 commit 5e86dd1
Show file tree
Hide file tree
Showing 2 changed files with 28 additions and 4 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,9 @@
import ch.admin.bag.covidcertificate.backend.config.shared.helper.FaqHelper;
import ch.admin.bag.covidcertificate.backend.config.shared.model.ConfigResponse;
import ch.admin.bag.covidcertificate.backend.config.shared.poeditor.Messages;
import ch.admin.bag.covidcertificate.backend.config.shared.semver.Version;
import ch.admin.bag.covidcertificate.backend.config.verifier.ws.controller.VerifierConfigController;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;
import org.springframework.context.annotation.Primary;
Expand All @@ -14,6 +16,12 @@
@Profile("mock-forceupdate")
public class MockForceUpdateConfig {

@Value("${mock.forceupdate.buildnr.ios}")
private String iosBuildNrForceUpdate;

@Value("${mock.forceupdate.buildnr.android}")
private String androidBuildNrForceUpdate;

@Bean
@Primary
public VerifierConfigController verifierConfigController(
Expand All @@ -29,15 +37,19 @@ public MockConfigController(Messages messages, FaqHelper faqHelper) {

@Override
public String hello() {
return super.hello() + " (mock force update)";
return super.hello() + " (mock-forceupdate)";
}

@Override
public ResponseEntity<ConfigResponse> getConfig(
String appversion, String osversion, String buildnr) {
ResponseEntity<ConfigResponse> response =
super.getConfig(appversion, osversion, buildnr);
response.getBody().setForceUpdate(true);
Version version = new Version(appversion);
if ((version.isIOS() && buildnr.equals(iosBuildNrForceUpdate))
|| (version.isAndroid() && buildnr.equals(androidBuildNrForceUpdate))) {
response.getBody().setForceUpdate(true);
}
return response;
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,9 @@
import ch.admin.bag.covidcertificate.backend.config.shared.helper.FaqHelper;
import ch.admin.bag.covidcertificate.backend.config.shared.model.ConfigResponse;
import ch.admin.bag.covidcertificate.backend.config.shared.poeditor.Messages;
import ch.admin.bag.covidcertificate.backend.config.shared.semver.Version;
import ch.admin.bag.covidcertificate.backend.config.wallet.ws.controller.WalletConfigController;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;
import org.springframework.context.annotation.Primary;
Expand All @@ -14,6 +16,12 @@
@Profile("mock-forceupdate")
public class MockForceUpdateConfig {

@Value("${mock.forceupdate.buildnr.ios}")
private String iosBuildNrForceUpdate;

@Value("${mock.forceupdate.buildnr.android}")
private String androidBuildNrForceUpdate;

@Bean
@Primary
public WalletConfigController walletConfigController(Messages messages, FaqHelper faqHelper) {
Expand All @@ -28,15 +36,19 @@ public MockConfigController(Messages messages, FaqHelper faqHelper) {

@Override
public String hello() {
return super.hello() + " (mock)";
return super.hello() + " (mock-forceupdate)";
}

@Override
public ResponseEntity<ConfigResponse> getConfig(
String appversion, String osversion, String buildnr) {
ResponseEntity<ConfigResponse> response =
super.getConfig(appversion, osversion, buildnr);
response.getBody().setForceUpdate(true);
Version version = new Version(appversion);
if ((version.isIOS() && buildnr.equals(iosBuildNrForceUpdate))
|| (version.isAndroid() && buildnr.equals(androidBuildNrForceUpdate))) {
response.getBody().setForceUpdate(true);
}
return response;
}
}
Expand Down

0 comments on commit 5e86dd1

Please sign in to comment.