Browse Source

Fix flaky QrCodeSettingsControllerTest deep link host test

WhiteLabelingControllerTest saves the system-level login white-labeling
params with baseUrl "https://domain.com" and never restores them. The
params persist in the shared test database, so when QrCodeSettingsControllerTest
runs later in the same JVM, getBaseUrl() resolves the system base URL to
domain.com and testGetMobileDeepLink fails with
expected "localhost" but was "domain.com".

Reset system white-labeling settings after every WhiteLabelingControllerTest
test, and reset them in QrCodeSettingsControllerTest setup as well.
pull/16348/head
Sergey Matvienko 2 months ago
parent
commit
f823a74123
  1. 3
      application/src/test/java/org/thingsboard/server/controller/QrCodeSettingsControllerTest.java
  2. 6
      application/src/test/java/org/thingsboard/server/controller/WhiteLabelingControllerTest.java

3
application/src/test/java/org/thingsboard/server/controller/QrCodeSettingsControllerTest.java

@ -53,7 +53,8 @@ public class QrCodeSettingsControllerTest extends AbstractControllerTest {
@Before
public void setUp() throws Exception {
loginSysAdmin();
// Deep link host is derived from the login white-labeling base URL; start from system defaults
resetSysAdminWhiteLabelingSettings();
MobileApp androidApp = validMobileApp( "my.android.package", PlatformType.ANDROID);
StoreInfo androidStoreInfo = StoreInfo.builder()

6
application/src/test/java/org/thingsboard/server/controller/WhiteLabelingControllerTest.java

@ -36,7 +36,11 @@ public class WhiteLabelingControllerTest extends AbstractControllerTest {
WhiteLabelingDao whiteLabelingDao;
@After
public void afterTest() {
public void afterTest() throws Exception {
// System-level login/white-labeling params are shared by every test class in the same DB;
// restore defaults so the base URL set here (e.g. "https://domain.com") does not leak.
resetSysAdminWhiteLabelingSettings();
if (tenantId != null) {
WhiteLabelingCompositeKey key = new WhiteLabelingCompositeKey(tenantId, WhiteLabelingType.MAIL_TEMPLATES);
if (whiteLabelingDao.findById(SYS_TENANT_ID, key) != null) {

Loading…
Cancel
Save