Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
80 changes: 80 additions & 0 deletions .github/workflows/unit-test.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,80 @@
name: Analysis (feature/unit-test)

on:
push:
branches:
- feature/unit-test

permissions:
contents: read

env:
RUN_UNIT_TEST: "true"
RUN_SAST: "true"
RUN_SCA: "true"
RUN_DAST: "true"

jobs:
initialization:
runs-on: ubuntu-latest
outputs:
envvalue1: ${{ steps.setvar.outputs.envvar1 }}
envvalue2: ${{ steps.setvar.outputs.envvar2 }}
envvalue3: ${{ steps.setvar.outputs.envvar3 }}
envvalue4: ${{ steps.setvar.outputs.envvar4 }}
service_name: ${{ steps.loadvars.outputs.service_name }}

steps:
- name: Checkout required variables
uses: actions/checkout@v4
with:
sparse-checkout: |
.github/variables/vars.env
sparse-checkout-cone-mode: false

- name: Set env flags
id: setvar
run: |
echo "envvar1=$RUN_UNIT_TEST" >> "$GITHUB_OUTPUT"
echo "envvar2=$RUN_SAST" >> "$GITHUB_OUTPUT"
echo "envvar3=$RUN_SCA" >> "$GITHUB_OUTPUT"
echo "envvar4=$RUN_DAST" >> "$GITHUB_OUTPUT"

- name: Load vars
id: loadvars
run: |
source .github/variables/vars.env
echo "service_name=${SERVICE_NAME}" >> "$GITHUB_OUTPUT"

test-job:
if: ${{ needs.initialization.outputs.envvalue1 == 'true' }}
needs: [initialization]
uses: SELISEdigitalplatforms/blocks-inventory/.github/workflows/1_unit_test.yml@main
permissions:
contents: read
checks: write
issues: write
pull-requests: write
with:
COMMENT_RESULTS: false

sast-job:
if: ${{ success() && needs.initialization.outputs.envvalue2 == 'true' }}
needs: [test-job]
uses: SELISEdigitalplatforms/blocks-inventory/.github/workflows/2_sast.yml@main
permissions:
contents: read
checks: write
pull-requests: read
secrets:
SONAR_TOKEN: ${{ secrets.SONAR_TOKEN_GLOBAL }}
SONAR_GET: ${{ secrets.SONAR_GET }}

sca-job:
if: ${{ success() && needs.initialization.outputs.envvalue3 == 'true' }}
needs: [initialization]
uses: SELISEdigitalplatforms/blocks-inventory/.github/workflows/3_sca.yml@main
permissions:
contents: read
secrets:
DEPENDENCY_TRACK_API_KEY: ${{ secrets.DEPENDENCY_TRACK_API_KEY }}
Original file line number Diff line number Diff line change
Expand Up @@ -20,18 +20,18 @@ public ConfigControllerTests()
{
_webHookServiceMock = new Mock<IWebHookService>();

var changeControllerContextMock = new Mock<ChangeControllerContext>(MockBehavior.Loose, null, null, null);
var changeControllerContext = TestChangeControllerContextFactory.Create();

_controller = new ConfigController(
changeControllerContextMock.Object,
changeControllerContext,
_webHookServiceMock.Object
)
{
ControllerContext = new ControllerContext()
};
}

[Fact(Skip = "Blocked by non-overridable Blocks.Genesis.ChangeControllerContext.ChangeContext and null internal dependencies in test context")]
[Fact]
public async Task SaveWebHook_WithValidWebhook_ReturnsSuccess()
{
// Arrange
Expand Down Expand Up @@ -66,7 +66,7 @@ public async Task SaveWebHook_WithValidWebhook_ReturnsSuccess()
_webHookServiceMock.Verify(x => x.SaveWebhookAsync(webhook), Times.Once);
}

[Fact(Skip = "Blocked by non-overridable Blocks.Genesis.ChangeControllerContext.ChangeContext and null internal dependencies in test context")]
[Fact]
public async Task SaveWebHook_WhenServiceFails_ReturnsFailure()
{
// Arrange
Expand Down Expand Up @@ -100,7 +100,7 @@ public async Task SaveWebHook_WhenServiceFails_ReturnsFailure()
result.Success.Should().BeFalse();
}

[Fact(Skip = "Blocked by non-overridable Blocks.Genesis.ChangeControllerContext.ChangeContext and null internal dependencies in test context")]
[Fact]
public async Task SaveWebHook_WhenServiceThrows_PropagatesException()
{
// Arrange
Expand All @@ -127,7 +127,7 @@ public async Task SaveWebHook_WhenServiceThrows_PropagatesException()
await act.Should().ThrowAsync<Exception>();
}

[Fact(Skip = "Blocked by non-overridable Blocks.Genesis.ChangeControllerContext.ChangeContext and null internal dependencies in test context")]
[Fact]
public async Task SaveWebHook_WithMultipleWebhooks_CallsServiceMultipleTimes()
{
// Arrange
Expand Down
Loading
Loading