Skip to content

Commit

Permalink
Merge branch 'main' into AB2D-6340/Upgrade_spring
Browse files Browse the repository at this point in the history
  • Loading branch information
smirnovaae authored Oct 30, 2024
2 parents 25313bb + 1719071 commit c2f948e
Show file tree
Hide file tree
Showing 3 changed files with 52 additions and 4 deletions.
15 changes: 12 additions & 3 deletions .github/workflows/promote.yml
Original file line number Diff line number Diff line change
Expand Up @@ -38,9 +38,18 @@ jobs:
with:
aws-region: ${{ vars.AWS_REGION }}
role-to-assume: arn:aws:iam::${{ secrets.MGMT_ACCOUNT_ID }}:role/delegatedadmin/developer/ab2d-mgmt-github-actions
- name: Retag images in ECR

- name: Set environment variables
env:
DEPLOYMENT_ENV: ${{ vars[format('{0}_DEPLOYMENT_ENV', inputs.environment)] }}
run: |
if [ "${{ inputs.environment }}" == "prod_test" ]; then
echo "TAG_PREFIX=ab2d-prod-test" >> $GITHUB_ENV
else
echo "TAG_PREFIX=ab2d-$DEPLOYMENT_ENV" >> $GITHUB_ENV
- name: Retag images in ECR
env:
ECR_REPO_DOMAIN: ${{ secrets.MGMT_ACCOUNT_ID }}.dkr.ecr.${{ vars.AWS_REGION }}.amazonaws.com
ECR_REPO: ab2d_${{ inputs.module }}
run: |
Expand All @@ -51,10 +60,10 @@ jobs:
echo "Getting the manifest of the image tagged main-$SHA_SHORT"
MANIFEST="$(curl -sS -H "Authorization: Basic $TOKEN" -H "Accept: $CONTENT_TYPE" "https://$ECR_REPO_DOMAIN/v2/$ECR_REPO/manifests/main-$SHA_SHORT")"
SHA_TAG="ab2d-$DEPLOYMENT_ENV-$SHA_SHORT"
SHA_TAG="$TAG_PREFIX-$SHA_SHORT"
echo "Adding the $SHA_TAG tag to main-$SHA_SHORT image"
curl -sS -X PUT -H "Authorization: Basic $TOKEN" -H "Content-Type: $CONTENT_TYPE" -d "$MANIFEST" "https://$ECR_REPO_DOMAIN/v2/$ECR_REPO/manifests/$SHA_TAG"
LATEST_TAG="ab2d-$DEPLOYMENT_ENV-latest"
LATEST_TAG="$TAG_PREFIX-latest"
echo "Adding the $LATEST_TAG tag to main-$SHA_SHORT image"
curl -sS -X PUT -H "Authorization: Basic $TOKEN" -H "Content-Type: $CONTENT_TYPE" -d "$MANIFEST" "https://$ECR_REPO_DOMAIN/v2/$ECR_REPO/manifests/$LATEST_TAG"
Original file line number Diff line number Diff line change
@@ -0,0 +1,39 @@
package gov.cms.ab2d.api.security;

import static org.junit.Assert.assertEquals;
import static org.junit.Assert.assertThrows;
import static org.mockito.Mockito.mock;
import static org.mockito.Mockito.when;

import org.junit.jupiter.api.Test;
import org.springframework.security.core.userdetails.UsernameNotFoundException;

import gov.cms.ab2d.common.model.PdpClient;
import gov.cms.ab2d.common.repository.PdpClientRepository;

class CustomUserDetailsServiceTest {

@Test
void testLoadUserByUsername1() {
PdpClientRepository pdpClientRepository = mock(PdpClientRepository.class);
CustomUserDetailsService customUserDetailsService = new CustomUserDetailsService(pdpClientRepository);
PdpClient pdpClient = new PdpClient();
when(pdpClientRepository.findByClientId("clientId")).thenReturn(pdpClient);
assertEquals(
customUserDetailsService.loadUserByUsername("clientId"),
pdpClient
);
}

@Test
void testLoadUserByUsername2() {
PdpClientRepository pdpClientRepository = mock(PdpClientRepository.class);
CustomUserDetailsService customUserDetailsService = new CustomUserDetailsService(pdpClientRepository);
when(pdpClientRepository.findByClientId(null)).thenReturn(null);
assertThrows(
UsernameNotFoundException.class,
() -> {customUserDetailsService.loadUserByUsername(null);}
);
}

}
2 changes: 1 addition & 1 deletion pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@
<checkstyle.config>${project.root}/src/main/resources/checkstyle.xml</checkstyle.config>
<logback-encoder.version>7.3</logback-encoder.version>
<testcontainers.version>1.20.1</testcontainers.version>
<newrelic.version>8.13.0</newrelic.version>
<newrelic.version>8.15.0</newrelic.version>
<postgres.version>42.7.3</postgres.version>
<spring-cloud-aws.version>3.1.1</spring-cloud-aws.version>

Expand Down

0 comments on commit c2f948e

Please sign in to comment.