From 918bcb2444627308f3826442053dfe6d3232f43f Mon Sep 17 00:00:00 2001 From: "dependabot[bot]" <49699333+dependabot[bot]@users.noreply.github.com> Date: Wed, 18 Oct 2023 12:58:27 +0200 Subject: [PATCH 1/3] build(deps): bump actions/checkout from 4.1.0 to 4.1.1 (#2192) Bumps [actions/checkout](https://github.com/actions/checkout) from 4.1.0 to 4.1.1. - [Release notes](https://github.com/actions/checkout/releases) - [Changelog](https://github.com/actions/checkout/blob/main/CHANGELOG.md) - [Commits](https://github.com/actions/checkout/compare/8ade135a41bc03ea155e62e844d188df1ea18608...b4ffde65f46336ab88eb53be808477a3936bae11) --- updated-dependencies: - dependency-name: actions/checkout dependency-type: direct:production update-type: version-update:semver-patch ... Signed-off-by: dependabot[bot] Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com> --- .github/workflows/pssanalyzer.yml | 2 +- .github/workflows/test.yml | 2 +- exercises/concept/authentication-system/.meta/Exemplar.cs | 2 +- 3 files changed, 3 insertions(+), 3 deletions(-) diff --git a/.github/workflows/pssanalyzer.yml b/.github/workflows/pssanalyzer.yml index e67df5ca41..548992fc2a 100644 --- a/.github/workflows/pssanalyzer.yml +++ b/.github/workflows/pssanalyzer.yml @@ -13,5 +13,5 @@ jobs: analyze: runs-on: ubuntu-20.04 steps: - - uses: actions/checkout@8ade135a41bc03ea155e62e844d188df1ea18608 + - uses: actions/checkout@b4ffde65f46336ab88eb53be808477a3936bae11 - run: pwsh ./powershell-script-analyzer.ps1 diff --git a/.github/workflows/test.yml b/.github/workflows/test.yml index 5dc60fd615..81877121e8 100644 --- a/.github/workflows/test.yml +++ b/.github/workflows/test.yml @@ -13,7 +13,7 @@ jobs: test: runs-on: ubuntu-20.04 steps: - - uses: actions/checkout@8ade135a41bc03ea155e62e844d188df1ea18608 + - uses: actions/checkout@b4ffde65f46336ab88eb53be808477a3936bae11 - uses: actions/setup-dotnet@3447fd6a9f9e57506b15f895c5b76d3b197dc7c2 with: dotnet-version: "7.0.100" diff --git a/exercises/concept/authentication-system/.meta/Exemplar.cs b/exercises/concept/authentication-system/.meta/Exemplar.cs index 77b62b8aad..c667fdbd68 100644 --- a/exercises/concept/authentication-system/.meta/Exemplar.cs +++ b/exercises/concept/authentication-system/.meta/Exemplar.cs @@ -40,7 +40,7 @@ public Identity Admin get { return new Identity { Email = admin.Email, EyeColor = admin.EyeColor }; } } - public IReadOnlyDictionary GetDevelopers() + public IDictionary GetDevelopers() { return new ReadOnlyDictionary(developers); } From a61a6f81ad50f1a993d8fc7f9878c8b6b0de3f57 Mon Sep 17 00:00:00 2001 From: Salvatore Piccione <952022+salvatore-piccione@users.noreply.github.com> Date: Wed, 18 Oct 2023 15:54:07 +0200 Subject: [PATCH 2/3] feat: improve tampering test on exercise "Authentication System" --- .../AuthenticationSystemTests.cs | 29 +++++++++++++++++++ 1 file changed, 29 insertions(+) diff --git a/exercises/concept/authentication-system/AuthenticationSystemTests.cs b/exercises/concept/authentication-system/AuthenticationSystemTests.cs index 759d96d562..5c1359248b 100644 --- a/exercises/concept/authentication-system/AuthenticationSystemTests.cs +++ b/exercises/concept/authentication-system/AuthenticationSystemTests.cs @@ -14,6 +14,17 @@ public void GetAdmin() Assert.Equal(admin, authenticator.Admin); } + [Fact] + [Task(4)] + public void CheckAdminCannotBeTampered() + { + var admin = new Identity { EyeColor = "green", Email = "admin@ex.ism" }; + var authenticator = new Authenticator(admin); + var tamperedAdmin = authenticator.Admin; + tamperedAdmin.Email = "admin@hack.ed"; + Assert.NotEqual(tamperedAdmin.Email, authenticator.Admin.Email); + } + [Fact] [Task(5)] public void GetDevelopers() @@ -24,4 +35,22 @@ public void GetDevelopers() bool?[] expected = { true, true, true }; Assert.Equal(expected, actual); } + + [Fact] + [Task(5)] + public void CheckDevelopersCannotBeTampered() + { + var authenticator = new Authenticator(new Identity { EyeColor = "green", Email = "admin@ex.ism" }); + IDictionary devs = authenticator.GetDevelopers(); + + Identity tamperedDev = new Identity { EyeColor = "grey", Email = "anders@hack.ed" }; + try + { + devs["Anders"] = tamperedDev; + Assert.True(false, "Unexpected change to developers list."); + } catch (NotSupportedException) + { + Assert.True(true); + } + } } From 04151e3d504ff19febe7be799a0950182d214f0d Mon Sep 17 00:00:00 2001 From: Salvatore Piccione Date: Thu, 19 Oct 2023 11:20:36 +0200 Subject: [PATCH 3/3] feat: improve test readability --- .../AuthenticationSystemTests.cs | 14 ++++---------- 1 file changed, 4 insertions(+), 10 deletions(-) diff --git a/exercises/concept/authentication-system/AuthenticationSystemTests.cs b/exercises/concept/authentication-system/AuthenticationSystemTests.cs index 5c1359248b..c214b65f54 100644 --- a/exercises/concept/authentication-system/AuthenticationSystemTests.cs +++ b/exercises/concept/authentication-system/AuthenticationSystemTests.cs @@ -18,11 +18,12 @@ public void GetAdmin() [Task(4)] public void CheckAdminCannotBeTampered() { - var admin = new Identity { EyeColor = "green", Email = "admin@ex.ism" }; + var adminEmail = "admin@ex.ism"; + var admin = new Identity { EyeColor = "green", Email = adminEmail }; var authenticator = new Authenticator(admin); var tamperedAdmin = authenticator.Admin; tamperedAdmin.Email = "admin@hack.ed"; - Assert.NotEqual(tamperedAdmin.Email, authenticator.Admin.Email); + Assert.Equal(adminEmail, authenticator.Admin.Email); } [Fact] @@ -44,13 +45,6 @@ public void CheckDevelopersCannotBeTampered() IDictionary devs = authenticator.GetDevelopers(); Identity tamperedDev = new Identity { EyeColor = "grey", Email = "anders@hack.ed" }; - try - { - devs["Anders"] = tamperedDev; - Assert.True(false, "Unexpected change to developers list."); - } catch (NotSupportedException) - { - Assert.True(true); - } + Assert.Throws(() => devs["Anders"] = tamperedDev); } }