chore: copy kept Tastefully modules and portals into Co-Lite
Backend modules from tastefully 8bd93d15: core-libs, core-session, api-gateway, mobile-api, services-auth, services-system, services-counter, services-member, services-log, services-email. solvway-admin-portal from babyboo f64d096ea, solvway-customer-portal from tastefully 8bd93d15. Copied as tracked files only. Literal secrets replaced with environment placeholders: - services-email: SMTP_PASSWORD, MAILGUN_API_KEY, SENDGRID_API_KEY, MAILJET_API_KEY, MAILJET_SECRET_KEY (optional, empty default) - services-system: JUMIO_TOKEN, JUMIO_SECRET (optional) - services-auth: USER_AUTH_API_SECRET (required); commented JWT secret removed - core-libs: JWT_TOKEN default removed (required), XXL_JOB_TOKEN default removed, ipgeolocation key read from IPGEOLOCATION_API_KEY - services-system EkycAppConfig: commented Jumio credentials removed Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01EFUzfj5akPxyikzGc2iAHM
This commit is contained in:
1 parent
e396568cc3
commit
5ee51d1913
2918 files changed
+302373
-3
No files matched your search
+68
@@ -0,0 +1,68 @@
|
||||
package com.solvway.mobile.api.config;
|
||||
|
||||
import com.solvway.core.enums.GeneralEnum.CmsPlatform;
|
||||
import org.junit.jupiter.api.Test;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
import static org.assertj.core.api.Assertions.assertThat;
|
||||
|
||||
class AuthAppKeyConfigTest {
|
||||
|
||||
@Test
|
||||
void resolvesConfiguredPlatformPerKey() {
|
||||
AuthAppKeyConfig config = new AuthAppKeyConfig();
|
||||
config.setList(List.of("customerKey:CP", "appKey:APP"));
|
||||
|
||||
assertThat(config.contains("customerKey")).isTrue();
|
||||
assertThat(config.resolvePlatform("customerKey")).isEqualTo(CmsPlatform.CP);
|
||||
assertThat(config.resolvePlatform("appKey")).isEqualTo(CmsPlatform.APP);
|
||||
}
|
||||
|
||||
@Test
|
||||
void bareKeyWithoutPlatformDefaultsToApp() {
|
||||
AuthAppKeyConfig config = new AuthAppKeyConfig();
|
||||
config.setList(List.of("legacyKey"));
|
||||
|
||||
assertThat(config.contains("legacyKey")).isTrue();
|
||||
assertThat(config.resolvePlatform("legacyKey")).isEqualTo(CmsPlatform.APP);
|
||||
}
|
||||
|
||||
@Test
|
||||
void unrecognisedPlatformSuffixTreatsWholeTokenAsKeyAndDefaultsToApp() {
|
||||
AuthAppKeyConfig config = new AuthAppKeyConfig();
|
||||
config.setList(List.of("k:NOPE"));
|
||||
|
||||
// "NOPE" is not a CmsPlatform, so the whole token is the key (not "k").
|
||||
assertThat(config.contains("k:NOPE")).isTrue();
|
||||
assertThat(config.contains("k")).isFalse();
|
||||
assertThat(config.resolvePlatform("k:NOPE")).isEqualTo(CmsPlatform.APP);
|
||||
}
|
||||
|
||||
@Test
|
||||
void keyContainingColonResolvesTrailingPlatformSuffix() {
|
||||
AuthAppKeyConfig config = new AuthAppKeyConfig();
|
||||
config.setList(List.of("ab:cd:CP"));
|
||||
|
||||
assertThat(config.contains("ab:cd")).isTrue();
|
||||
assertThat(config.resolvePlatform("ab:cd")).isEqualTo(CmsPlatform.CP);
|
||||
}
|
||||
|
||||
@Test
|
||||
void suffixedTokenIsNotItselfAKey() {
|
||||
AuthAppKeyConfig config = new AuthAppKeyConfig();
|
||||
config.setList(List.of("cpKey:CP"));
|
||||
|
||||
assertThat(config.contains("cpKey:CP")).isFalse();
|
||||
}
|
||||
|
||||
@Test
|
||||
void unknownKeyIsNotContainedAndResolvesToAppDefault() {
|
||||
AuthAppKeyConfig config = new AuthAppKeyConfig();
|
||||
config.setList(List.of("k:CP"));
|
||||
|
||||
assertThat(config.contains("missing")).isFalse();
|
||||
assertThat(config.contains(null)).isFalse();
|
||||
assertThat(config.resolvePlatform("missing")).isEqualTo(CmsPlatform.APP);
|
||||
}
|
||||
}
|
||||
+89
@@ -0,0 +1,89 @@
|
||||
package com.solvway.mobile.api.config;
|
||||
|
||||
import org.junit.jupiter.api.Test;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
import static org.assertj.core.api.Assertions.assertThat;
|
||||
import static org.assertj.core.api.Assertions.assertThatCode;
|
||||
import static org.assertj.core.api.Assertions.assertThatThrownBy;
|
||||
|
||||
class StartupSecurityConfigValidatorTest {
|
||||
|
||||
private static final String VALID_SECRET = "0123456789abcdef0123456789abcdef";
|
||||
private static final String VALID_OUTBOUND_KEY = "outbound-key";
|
||||
|
||||
private static AuthAppKeyConfig keysOf(List<String> keys) {
|
||||
AuthAppKeyConfig config = new AuthAppKeyConfig();
|
||||
config.setList(keys);
|
||||
return config;
|
||||
}
|
||||
|
||||
private static StartupSecurityConfigValidator validator(String secret, String outboundKey, List<String> inboundKeys) {
|
||||
return new StartupSecurityConfigValidator(secret, outboundKey, keysOf(inboundKeys));
|
||||
}
|
||||
|
||||
@Test
|
||||
void acceptsFullyConfiguredEnvironment() {
|
||||
assertThatCode(validator(VALID_SECRET, VALID_OUTBOUND_KEY, List.of("client-key"))::validate)
|
||||
.doesNotThrowAnyException();
|
||||
}
|
||||
|
||||
@Test
|
||||
void rejectsMissingJwtSecret() {
|
||||
assertThatThrownBy(validator("", VALID_OUTBOUND_KEY, List.of("client-key"))::validate)
|
||||
.isInstanceOf(IllegalStateException.class)
|
||||
.hasMessageContaining("JWT_SECRET");
|
||||
}
|
||||
|
||||
@Test
|
||||
void rejectsSpringQuotedEmptyDefaultForJwtSecret() {
|
||||
assertThatThrownBy(validator("''", VALID_OUTBOUND_KEY, List.of("client-key"))::validate)
|
||||
.isInstanceOf(IllegalStateException.class)
|
||||
.hasMessageContaining("JWT_SECRET");
|
||||
}
|
||||
|
||||
@Test
|
||||
void rejectsShortJwtSecret() {
|
||||
assertThatThrownBy(validator("tooshort", VALID_OUTBOUND_KEY, List.of("client-key"))::validate)
|
||||
.isInstanceOf(IllegalStateException.class)
|
||||
.hasMessageContaining("at least 32");
|
||||
}
|
||||
|
||||
@Test
|
||||
void rejectsEmptyInboundApiKeyList() {
|
||||
assertThatThrownBy(validator(VALID_SECRET, VALID_OUTBOUND_KEY, List.of())::validate)
|
||||
.isInstanceOf(IllegalStateException.class)
|
||||
.hasMessageContaining("AUTH_API_KEYS");
|
||||
}
|
||||
|
||||
@Test
|
||||
void rejectsInboundApiKeyListWhoseTokensHaveNoKey() {
|
||||
// ":CP" is non-blank but parses to an empty key, so it would authorise nothing.
|
||||
assertThatThrownBy(validator(VALID_SECRET, VALID_OUTBOUND_KEY, List.of(":CP"))::validate)
|
||||
.isInstanceOf(IllegalStateException.class)
|
||||
.hasMessageContaining("AUTH_API_KEYS");
|
||||
}
|
||||
|
||||
@Test
|
||||
void rejectsInboundApiKeyListOfBlanks() {
|
||||
assertThatThrownBy(validator(VALID_SECRET, VALID_OUTBOUND_KEY, List.of("", " "))::validate)
|
||||
.isInstanceOf(IllegalStateException.class)
|
||||
.hasMessageContaining("AUTH_API_KEYS");
|
||||
}
|
||||
|
||||
@Test
|
||||
void rejectsMissingOutboundApiKey() {
|
||||
assertThatThrownBy(validator(VALID_SECRET, "", List.of("client-key"))::validate)
|
||||
.isInstanceOf(IllegalStateException.class)
|
||||
.hasMessageContaining("APIKEY");
|
||||
}
|
||||
|
||||
@Test
|
||||
void errorMessageNeverLeaksTheSecretValue() {
|
||||
String secret = "supersecretvalue";
|
||||
assertThatThrownBy(validator(secret, VALID_OUTBOUND_KEY, List.of("client-key"))::validate)
|
||||
.isInstanceOf(IllegalStateException.class)
|
||||
.satisfies(ex -> assertThat(ex.getMessage()).doesNotContain(secret));
|
||||
}
|
||||
}
|
||||
Reference in new issue
Block a user