mirror of
https://github.com/floci-io/floci.git
synced 2026-12-01 01:12:48 -05:00
fix(floci-core): remove aws sdk from floci project (#846)
This commit is contained in:
1 parent
cf0db6edc9
commit
b6619f8646
3 files changed
+231
-38
No files matched your search
+12
-25
@@ -4,11 +4,6 @@ import io.github.hectorvent.floci.services.iam.IamService;
|
||||
import io.github.hectorvent.floci.testutil.IamServiceTestHelper;
|
||||
import io.github.hectorvent.floci.testutil.SigV4TokenTestHelper;
|
||||
import org.junit.jupiter.api.Test;
|
||||
import software.amazon.awssdk.auth.credentials.AwsBasicCredentials;
|
||||
import software.amazon.awssdk.auth.credentials.StaticCredentialsProvider;
|
||||
import software.amazon.awssdk.regions.Region;
|
||||
import software.amazon.awssdk.services.rds.RdsUtilities;
|
||||
import software.amazon.awssdk.services.rds.model.GenerateAuthenticationTokenRequest;
|
||||
|
||||
import java.time.Instant;
|
||||
|
||||
@@ -17,34 +12,26 @@ import static org.junit.jupiter.api.Assertions.assertTrue;
|
||||
|
||||
class RdsSigV4ValidatorTest {
|
||||
|
||||
/**
|
||||
* Uses the real AWS SDK RDS presigner as an independent SigV4 oracle.
|
||||
* If this test passes, the validator is compatible with tokens generated
|
||||
* by actual AWS SDK clients, not just our hand-rolled test helper.
|
||||
*/
|
||||
@Test
|
||||
void validateAcceptsTokenFromAwsSdkPresigner() throws Exception {
|
||||
void validateAcceptsTokenSignedByStandardSigV4() throws Exception {
|
||||
String accessKeyId = "AKIAORACLETEST";
|
||||
String secretAccessKey = "oracle-secret-key-value";
|
||||
IamService iamService = IamServiceTestHelper.iamServiceWithAccessKey(accessKeyId, secretAccessKey);
|
||||
|
||||
RdsSigV4Validator validator = new RdsSigV4Validator(iamService);
|
||||
|
||||
RdsUtilities utilities = RdsUtilities.builder()
|
||||
.credentialsProvider(StaticCredentialsProvider.create(
|
||||
AwsBasicCredentials.create(accessKeyId, secretAccessKey)))
|
||||
.region(Region.US_EAST_1)
|
||||
.build();
|
||||
String token = SigV4TokenTestHelper.createRdsToken(
|
||||
"db.oracle-test.local",
|
||||
5432,
|
||||
"testuser",
|
||||
accessKeyId,
|
||||
secretAccessKey,
|
||||
Instant.now().minusSeconds(60),
|
||||
900
|
||||
);
|
||||
|
||||
String sdkToken = utilities.generateAuthenticationToken(
|
||||
GenerateAuthenticationTokenRequest.builder()
|
||||
.hostname("db.oracle-test.local")
|
||||
.port(5432)
|
||||
.username("testuser")
|
||||
.build());
|
||||
|
||||
assertTrue(validator.validate(sdkToken, "testuser"),
|
||||
"Validator must accept tokens generated by the official AWS SDK RDS presigner");
|
||||
assertTrue(validator.validate(token, "testuser"),
|
||||
"Validator must accept a well-formed SigV4 RDS authentication token");
|
||||
}
|
||||
|
||||
@Test
|
||||
|
||||
Reference in new issue
Block a user