-
Notifications
You must be signed in to change notification settings - Fork 0
Fspw 832 #5
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: main
Are you sure you want to change the base?
Fspw 832 #5
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,16 @@ | ||
| name: ListTables_release | ||
|
|
||
| on: | ||
| workflow_dispatch: | ||
|
|
||
| jobs: | ||
| main_release: | ||
| uses: FrendsPlatform/FrendsTasks/.github/workflows/official_task_pipeline.yml@main | ||
| with: | ||
| workflow_mode: release | ||
| os: all | ||
| workdir: Frends.AzureTableStorage.ListTables | ||
| secrets: | ||
| badge_service_api_key: ${{ secrets.BADGE_SERVICE_API_KEY }} | ||
| target_feed_api_key: ${{ secrets.TASKS_FEED_API_KEY }} | ||
| source_nuget_feed_url: ${{ secrets.TASKS_FEED_URL }} | ||
|
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. 🎯 Functional Correctness | 🟠 Major | ⚡ Quick win Supply the source-feed credential or remove the source-feed URL. When 🧰 Tools🪛 GitHub Check: CodeQL[warning] 8-16: Workflow does not contain permissions 🪛 zizmor (1.30.0)[warning] 7-17: overly broad permissions (excessive-permissions): default permissions used due to no permissions: block (excessive-permissions) 🤖 Prompt for AI Agents
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. @MichalFrends1 agree, remove source_nuget_feed_url - we don't use it here |
||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,29 @@ | ||
| name: ListTables_test_on_main | ||
|
|
||
| on: | ||
| push: | ||
| branches: | ||
| - main | ||
| paths: | ||
| - 'Frends.AzureTableStorage.ListTables/**' | ||
| - '.github/workflows/ListTables*.yml' | ||
| workflow_dispatch: | ||
|
|
||
| jobs: | ||
|
MatteoDelOmbra marked this conversation as resolved.
|
||
| main_test: | ||
| uses: FrendsPlatform/FrendsTasks/.github/workflows/official_task_pipeline.yml@main | ||
| with: | ||
| workflow_mode: main | ||
| os: all | ||
| workdir: Frends.AzureTableStorage.ListTables | ||
| secrets: | ||
| badge_service_api_key: ${{ secrets.BADGE_SERVICE_API_KEY }} | ||
| env_vars: | | ||
| { | ||
| "Frends_AzureTableStorage_ConnString": ${{ toJSON(secrets.FRENDS_AZURETABLESTORAGE_CONNSTRING) }}, | ||
|
|
||
| "Frends_AzureTableStorage_AccountName": ${{ toJSON(secrets.FRENDS_AZURETABLESTORAGE_ACCOUNTNAME) }}, | ||
|
|
||
| "Frends_AzureTableStorage_TenantID": ${{ toJSON(secrets.FRENDS_AZURETABLESTORAGE_TENANTID) }}, | ||
|
|
||
| "Frends_AzureTableStorage_ClientID": ${{ toJSON(secrets.FRENDS_AZURETABLESTORAGE_CLIENTID) }}, | ||
|
|
||
| "Frends_AzureTableStorage_ClientSecret": ${{ toJSON(secrets.FRENDS_AZURETABLESTORAGE_CLIENTSECRET) }}, | ||
|
|
||
| "Frends_AzureTableStorage_SasToken": ${{ toJSON(secrets.FRENDS_AZURETABLESTORAGE_SASTOKEN) }}, | ||
|
|
||
| } | ||
|
MatteoDelOmbra marked this conversation as resolved.
|
||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,30 @@ | ||
| name: ListTables_test_on_push | ||
|
|
||
| on: | ||
| push: | ||
| branches-ignore: | ||
| - main | ||
| paths: | ||
| - 'Frends.AzureTableStorage.ListTables/**' | ||
| - '.github/workflows/ListTables*.yml' | ||
| workflow_dispatch: | ||
|
|
||
| jobs: | ||
| work_push: | ||
| uses: FrendsPlatform/FrendsTasks/.github/workflows/official_task_pipeline.yml@main | ||
|
MatteoDelOmbra marked this conversation as resolved.
|
||
| with: | ||
| workflow_mode: work | ||
| os: all | ||
| workdir: Frends.AzureTableStorage.ListTables | ||
| secrets: | ||
| badge_service_api_key: ${{ secrets.BADGE_SERVICE_API_KEY }} | ||
| target_feed_api_key: ${{ secrets.TASKS_TEST_FEED_API_KEY }} | ||
| env_vars: | | ||
| { | ||
| "Frends_AzureTableStorage_ConnString": ${{ toJSON(secrets.FRENDS_AZURETABLESTORAGE_CONNSTRING) }}, | ||
|
|
||
| "Frends_AzureTableStorage_AccountName": ${{ toJSON(secrets.FRENDS_AZURETABLESTORAGE_ACCOUNTNAME) }}, | ||
|
|
||
| "Frends_AzureTableStorage_TenantID": ${{ toJSON(secrets.FRENDS_AZURETABLESTORAGE_TENANTID) }}, | ||
|
|
||
| "Frends_AzureTableStorage_ClientID": ${{ toJSON(secrets.FRENDS_AZURETABLESTORAGE_CLIENTID) }}, | ||
|
|
||
| "Frends_AzureTableStorage_ClientSecret": ${{ toJSON(secrets.FRENDS_AZURETABLESTORAGE_CLIENTSECRET) }}, | ||
|
|
||
| "Frends_AzureTableStorage_SasToken": ${{ toJSON(secrets.FRENDS_AZURETABLESTORAGE_SASTOKEN) }}, | ||
|
github-advanced-security[bot] marked this conversation as resolved.
Fixed
|
||
| } | ||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,7 @@ | ||
| # Changelog | ||
|
|
||
| ## [1.0.0] - 2026-09-29 | ||
|
|
||
| ### Added | ||
|
|
||
| - Initial implementation |
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,14 @@ | ||
| # Rename this file to .env to run tests locally | ||
|
|
||
| # Connection String authentication (recommended for local testing) | ||
| Frends_AzureTableStorage_ConnString="DefaultEndpointsProtocol=https;AccountName=youraccount;AccountKey=yourkey;EndpointSuffix=core.windows.net" | ||
|
|
||
| # OAuth2 (Service Principal) authentication | ||
| Frends_AzureTableStorage_AccountName="youraccount" | ||
| Frends_AzureTableStorage_TenantID="12345678-1234-1234-1234-123456789012" | ||
| Frends_AzureTableStorage_ClientID="12345678-1234-1234-1234-123456789012" | ||
| Frends_AzureTableStorage_ClientSecret="your-client-secret" | ||
|
|
||
| # SAS Token authentication | ||
| Frends_AzureTableStorage_AccountName="youraccount" | ||
| Frends_AzureTableStorage_SasToken="?sv=2021-06-08&ss=t&srt=sco&sp=rwdlacu&se=2024-12-31T23:59:59Z&st=2024-01-01T00:00:00Z&spr=https&sig=..." |
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,122 @@ | ||
| using System; | ||
| using System.ComponentModel.DataAnnotations; | ||
| using System.Threading; | ||
| using System.Threading.Tasks; | ||
| using Frends.AzureTableStorage.ListTables.Definitions; | ||
| using NUnit.Framework; | ||
|
|
||
| namespace Frends.AzureTableStorage.ListTables.Tests; | ||
|
|
||
| [TestFixture] | ||
| internal class ErrorHandlerTest : TestBase | ||
| { | ||
| private const string CustomErrorMessage = "Custom error occurred during table listing"; | ||
|
|
||
| [Test] | ||
| public void Should_Throw_Error_When_ThrowErrorOnFailure_Is_True() | ||
| { | ||
| var input = DefaultInput(); | ||
| var connection = new Connection | ||
| { | ||
| ConnectionMethod = ConnectionMethod.ConnectionString, | ||
| ConnectionString = "Invalid", | ||
| }; | ||
| var options = DefaultOptions(); | ||
| options.ThrowErrorOnFailure = true; | ||
|
|
||
| Func<Task> action = async () => { await AzureTableStorage.ListTables(input, connection, options, CancellationToken.None); }; | ||
| var ex = Assert.ThrowsAsync<ArgumentException>(action); | ||
| Assert.That(ex, Is.Not.Null); | ||
| } | ||
|
|
||
| [Test] | ||
| public async Task Should_Return_Failed_Result_When_ThrowErrorOnFailure_Is_False() | ||
| { | ||
| var input = DefaultInput(); | ||
| var connection = new Connection | ||
| { | ||
| ConnectionMethod = ConnectionMethod.ConnectionString, | ||
| ConnectionString = "Invalid", | ||
| }; | ||
| var options = DefaultOptions(); | ||
| options.ThrowErrorOnFailure = false; | ||
|
|
||
| var result = await AzureTableStorage.ListTables(input, connection, options, CancellationToken.None); | ||
|
|
||
| Assert.That(result.Success, Is.False); | ||
| Assert.That(result.Error, Is.Not.Null); | ||
| Assert.That(result.Error.Message, Is.Not.Empty); | ||
| } | ||
|
|
||
| [Test] | ||
| public void Should_Use_Custom_ErrorMessageOnFailure() | ||
| { | ||
| var input = DefaultInput(); | ||
| var connection = new Connection | ||
| { | ||
| ConnectionMethod = ConnectionMethod.ConnectionString, | ||
| ConnectionString = "Invalid", | ||
| }; | ||
| var options = DefaultOptions(); | ||
| options.ErrorMessageOnFailure = CustomErrorMessage; | ||
| options.ThrowErrorOnFailure = true; | ||
|
|
||
| Func<Task> action = async () => { await AzureTableStorage.ListTables(input, connection, options, CancellationToken.None); }; | ||
| var ex = Assert.ThrowsAsync<Exception>(action); | ||
| Assert.That(ex, Is.Not.Null); | ||
| Assert.That(ex.Message, Does.Contain(CustomErrorMessage)); | ||
| } | ||
|
|
||
| [Test] | ||
| public async Task Should_Return_Custom_ErrorMessage_When_ThrowErrorOnFailure_Is_False() | ||
| { | ||
| var input = DefaultInput(); | ||
| var connection = new Connection | ||
| { | ||
| ConnectionMethod = ConnectionMethod.ConnectionString, | ||
| ConnectionString = "Invalid", | ||
| }; | ||
| var options = DefaultOptions(); | ||
| options.ErrorMessageOnFailure = CustomErrorMessage; | ||
| options.ThrowErrorOnFailure = false; | ||
|
|
||
| var result = await AzureTableStorage.ListTables(input, connection, options, CancellationToken.None); | ||
|
|
||
| Assert.That(result.Success, Is.False); | ||
| Assert.That(result.Error, Is.Not.Null); | ||
| Assert.That(result.Error.Message, Does.Contain(CustomErrorMessage)); | ||
| } | ||
|
|
||
| [Test] | ||
| public async Task Should_Always_Throw_OperationCanceledException() | ||
|
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. resolve build-time warning here regarding await |
||
| { | ||
| Assume.That(ConnectionString, Is.Not.Empty, "Connection string is required for cancellation test."); | ||
|
|
||
| var cts = new CancellationTokenSource(); | ||
| cts.Cancel(); | ||
|
|
||
| Func<Task> action = async () => | ||
| { | ||
| await AzureTableStorage.ListTables(DefaultInput(), DefaultConnectionStringConnection(), DefaultOptions(), cts.Token); | ||
| }; | ||
|
|
||
| var ex = Assert.ThrowsAsync<TaskCanceledException>(action); | ||
| Assert.That(ex, Is.Not.Null); | ||
| } | ||
|
Comment on lines
+90
to
+105
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. 🎯 Functional Correctness | 🟡 Minor | ⚡ Quick win The cancellation test can fail when the exception type differs.
🤖 Prompt for AI Agents
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. @MichalFrends1 test name and actual assertion suggest different types of exception - maybe do as rabbit suggest? |
||
|
|
||
| [Test] | ||
| public void Should_Throw_ValidationException_When_Input_Is_Null() | ||
| { | ||
| var options = DefaultOptions(); | ||
|
|
||
| Func<Task> action = async () => | ||
| { | ||
| await AzureTableStorage.ListTables(null, DefaultConnectionStringConnection(), options, CancellationToken.None); | ||
| }; | ||
|
|
||
| var ex = Assert.ThrowsAsync<ValidationException>(action); | ||
|
|
||
| Assert.That(ex, Is.Not.Null); | ||
| Assert.That(ex.Message, Does.Contain("Validated object can't be null")); | ||
| } | ||
| } | ||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,24 @@ | ||
| <Project Sdk="Microsoft.NET.Sdk"> | ||
| <PropertyGroup> | ||
| <TargetFramework>net8.0</TargetFramework> | ||
| <IsPackable>false</IsPackable> | ||
| <Nullable>disable</Nullable> | ||
| </PropertyGroup> | ||
|
|
||
| <ItemGroup> | ||
| <ProjectReference Include="..\Frends.AzureTableStorage.ListTables\Frends.AzureTableStorage.ListTables.csproj"/> | ||
| </ItemGroup> | ||
|
|
||
| <ItemGroup> | ||
| <None Include=".env" CopyToOutputDirectory="PreserveNewest" Condition="Exists('.env')"/> | ||
| </ItemGroup> | ||
|
|
||
| <ItemGroup> | ||
| <PackageReference Include="StyleCop.Analyzers" Version="1.2.0-beta.556"/> | ||
| <PackageReference Include="coverlet.collector" Version="6.*"/> | ||
| <PackageReference Include="Microsoft.NET.Test.Sdk" Version="18.*"/> | ||
| <PackageReference Include="NUnit" Version="4.*"/> | ||
| <PackageReference Include="NUnit3TestAdapter" Version="6.*"/> | ||
| <PackageReference Include="dotenv.net" Version="4.*"/> | ||
| </ItemGroup> | ||
| </Project> |
Uh oh!
There was an error while loading. Please reload this page.