Skip to content

Add unit tests for roleArn validation when stsEnabled is true#162

Merged
stevehu merged 2 commits intoissue160from
copilot/sub-pr-161
Mar 20, 2026
Merged

Add unit tests for roleArn validation when stsEnabled is true#162
stevehu merged 2 commits intoissue160from
copilot/sub-pr-161

Conversation

Copy link
Contributor

Copilot AI commented Mar 20, 2026

The validate() method in LambdaInvokerConfig throws ConfigException when stsEnabled=true but roleArn is blank — this fail-fast behavior had no test coverage.

Changes

  • New test YAML configs in src/test/resources/config/:

    • lambda-invoker-sts-no-role.ymlstsEnabled: true, roleArn blank
    • lambda-invoker-sts-with-role.ymlstsEnabled: true, roleArn set to a valid ARN
  • Two new tests in LambdaInvokerConfigTest:

    • testStsEnabledWithoutRoleArnThrowsConfigException — asserts ConfigException is thrown on load
    • testStsEnabledWithRoleArnSucceeds — asserts clean load and correct roleArn value
@Test
public void testStsEnabledWithoutRoleArnThrowsConfigException() {
    assertThrows(ConfigException.class, () -> LambdaInvokerConfig.load("lambda-invoker-sts-no-role"),
            "ConfigException was not thrown despite stsEnabled=true with blank roleArn");
}

@Test
public void testStsEnabledWithRoleArnSucceeds() {
    LambdaInvokerConfig stsConfig = LambdaInvokerConfig.load("lambda-invoker-sts-with-role");
    assertNotNull(stsConfig);
    assertEquals("arn:aws:iam::123456789012:role/TestRole", stsConfig.getRoleArn());
}

💬 Send tasks to Copilot coding agent from Slack and Teams to turn conversations into code. Copilot posts an update in your thread when it's finished.

Copy link
Contributor Author

Copilot AI commented Mar 20, 2026

Just as a heads up, I was blocked by some firewall rules while working on your feedback. Expand below for details.

Warning

Firewall rules blocked me from connecting to one or more addresses (expand for details)

I tried to connect to the following addresses, but was blocked by firewall rules:

  • central.sonatype.com
    • Triggering command: /usr/lib/jvm/temurin-17-jdk-amd64/bin/java /usr/lib/jvm/temurin-17-jdk-amd64/bin/java --enable-native-access=ALL-UNNAMED -classpath /usr/share/apache-maven-3.9.13/boot/plexus-classworlds-2.9.0.jar -Dclassworlds.conf=/usr/share/apache-maven-3.9.13/bin/m2.conf -Dmaven.home=/usr/share/apache-maven-3.9.13 -Dlibrary.jansi.path=/usr/share/apache-maven-3.9.13/lib/jansi-native -Dmaven.multiModuleProjectDirectory=/home/REDACTED/work/light-aws-lambda/light-aws-lambda/lambda-invoker org.codehaus.plexus.classworlds.launcher.Launcher test -pl . -Dtest=LambdaInvokerConfigTest (dns block)
    • Triggering command: /usr/lib/jvm/temurin-17-jdk-amd64/bin/java /usr/lib/jvm/temurin-17-jdk-amd64/bin/java --enable-native-access=ALL-UNNAMED -classpath /usr/share/apache-maven-3.9.13/boot/plexus-classworlds-2.9.0.jar -Dclassworlds.conf=/usr/share/apache-maven-3.9.13/bin/m2.conf -Dmaven.home=/usr/share/apache-maven-3.9.13 -Dlibrary.jansi.path=/usr/share/apache-maven-3.9.13/lib/jansi-native -Dmaven.multiModuleProjectDirectory=/home/REDACTED/work/light-aws-lambda/light-aws-lambda org.codehaus.plexus.classworlds.launcher.Launcher -f pom.xml -B -V -e -Dfindbugs.skip -Dcheckstyle.skip -Dpmd.skip=true -Dspotbugs.skip -Denforcer.skip -Dmaven.javadoc.skip (dns block)

If you need me to access, download, or install something from one of these locations, you can either:

Copilot AI changed the title [WIP] [WIP] Address feedback from PR #161 on roleArn validation implementation Add unit tests for roleArn validation when stsEnabled is true Mar 20, 2026
Copilot AI requested a review from stevehu March 20, 2026 20:18
@stevehu stevehu marked this pull request as ready for review March 20, 2026 23:50
@stevehu stevehu merged commit 8dc937e into issue160 Mar 20, 2026
1 check passed
@stevehu stevehu deleted the copilot/sub-pr-161 branch March 20, 2026 23:50
stevehu added a commit that referenced this pull request Mar 20, 2026
* fixes #160 Add validation for roleArn to avoid NPE

* Add unit tests for roleArn validation when stsEnabled is true (#162)

* Initial plan

* Add unit tests for roleArn validation when stsEnabled is true

Co-authored-by: stevehu <2042337+stevehu@users.noreply.github.com>
Agent-Logs-Url: https://github.com/networknt/light-aws-lambda/sessions/9112dc37-502e-4d9a-9701-cb1fa8121d5b

---------

Co-authored-by: copilot-swe-agent[bot] <198982749+Copilot@users.noreply.github.com>
Co-authored-by: stevehu <2042337+stevehu@users.noreply.github.com>

---------

Co-authored-by: Copilot <198982749+Copilot@users.noreply.github.com>
Co-authored-by: stevehu <2042337+stevehu@users.noreply.github.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants