-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
* fix linting * update testing * add better unit testing * enable corepack * fix corepack enable * remove unit testing from post-deployment pipeline * update names * get s3 client directly
- Loading branch information
1 parent
838ff70
commit 8320466
Showing
52 changed files
with
261 additions
and
123 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,2 @@ | ||
pytest | ||
moto |
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
File renamed without changes.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
File renamed without changes.
Empty file.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,42 @@ | ||
import pytest | ||
from moto import mock_aws | ||
import boto3 | ||
import os | ||
import json | ||
from ..secretsmanager import get_parameter_from_sm | ||
|
||
|
||
key_data = {"CLIENT_DATA": "12345", "CLIENT_SECRET": "12345"} | ||
invalid_key_data = '{"name": "Joe", "age": null]' | ||
@pytest.fixture | ||
def sm_client(): | ||
"""Fixture to create a mocked KMS client using moto.""" | ||
with mock_aws(): | ||
client = boto3.client('secretsmanager', region_name=os.environ.get("AWS_REGION", "us-east-1")) | ||
yield client | ||
|
||
@pytest.fixture | ||
def sm_valid_key_id(sm_client): | ||
"""Fixture to create a mock KMS key.""" | ||
sm_client.create_secret(Name='test-secret', SecretString=json.dumps(key_data)) | ||
return 'test-secret' | ||
|
||
|
||
@pytest.fixture | ||
def sm_invalid_key_id(sm_client): | ||
"""Fixture to create a mock KMS key.""" | ||
sm_client.create_secret(Name='test-invalid-secret', SecretString=invalid_key_data) | ||
return 'test-invalid-secret' | ||
|
||
def test_valid_secret(sm_client, sm_valid_key_id): | ||
assert key_data == get_parameter_from_sm(sm_client, sm_valid_key_id) | ||
|
||
def test_invalid_secret(sm_client, sm_invalid_key_id, capfd): | ||
assert get_parameter_from_sm(sm_client, sm_invalid_key_id) == None | ||
out, _ = capfd.readouterr() | ||
assert out == "Parameter \"test-invalid-secret\" is not in valid JSON format.\n" | ||
|
||
def test_nonexistent_secret(sm_client, capfd): | ||
assert get_parameter_from_sm(sm_client, 'test-nonexistent-secret') == None | ||
out, _ = capfd.readouterr() | ||
assert out == "Parameter \"test-nonexistent-secret\" not found.\n" |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,28 @@ | ||
import userEvent from '@testing-library/user-event'; | ||
import { describe, it, expect, vi } from 'vitest'; | ||
import { render, screen } from '@/test-utils'; | ||
import FullPageError from './index'; // Adjust the import path as necessary | ||
|
||
describe('FullPageError', () => { | ||
it('renders with default error messages when no props are provided', () => { | ||
render(<FullPageError />); | ||
expect(screen.getByText('An error occurred')).toBeInTheDocument(); | ||
expect(screen.getByText('Something went wrong. Please try again later.')).toBeInTheDocument(); | ||
expect(screen.queryByRole('button', { name: 'Retry' })).toBeNull(); | ||
}); | ||
|
||
it('renders custom error codes and messages when provided', () => { | ||
render(<FullPageError errorCode={404} errorMessage="Page not found" />); | ||
expect(screen.getByText('404')).toBeInTheDocument(); | ||
expect(screen.getByText('Page not found')).toBeInTheDocument(); | ||
}); | ||
|
||
it('displays a retry button when an onRetry handler is provided', async () => { | ||
const onRetry = vi.fn(); | ||
render(<FullPageError onRetry={onRetry} />); | ||
const retryButton = screen.getByTestId('errorRetryButton'); | ||
expect(retryButton).toBeInTheDocument(); | ||
await userEvent.click(retryButton); | ||
expect(onRetry).toHaveBeenCalled(); | ||
}); | ||
}); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.