Skip to content
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

v3.11.0-beta0 #264

Merged
merged 253 commits into from
Oct 5, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
253 commits
Select commit Hold shift + click to select a range
7a08e06
More iteration on reports revamp
sei-bstein Apr 14, 2023
962ba13
Merge branch 'next' into new/reports-revamp
sei-bstein Apr 17, 2023
141f2ae
Merge branch 'next' into new/reports-revamp
sei-bstein Apr 19, 2023
35a2873
Checkpoint for reports revamp
sei-bstein Apr 26, 2023
8a3ca5d
More reports backend
sei-bstein Apr 27, 2023
1e12f56
Use challenge specs instead of challenges for reporting.
sei-bstein Apr 27, 2023
1e2915c
More reports plumbing
sei-bstein Apr 28, 2023
ef77a0b
Merge branch 'main' into new/reports-revamp
sei-bstein May 1, 2023
41705c2
More report plumbing
sei-bstein May 1, 2023
3d560c6
Add support report to db
sei-bstein May 2, 2023
f82bccc
Work on support report
sei-bstein May 4, 2023
e9f1970
Polishing support report
sei-bstein May 8, 2023
17af880
Add reports and initial unit tests
sei-bstein May 11, 2023
a058e09
More work on reports
sei-bstein May 15, 2023
ab889aa
Refactor - move SimpleEntity into Gameboard.Api.Features.Common.
sei-bstein May 16, 2023
4afd4f2
Merge branch 'main' into next
sei-bstein May 17, 2023
df58f41
Don't bootstrap JobsService in integration test env
sei-bstein May 17, 2023
101bb29
Address an issue where Gameboard was incorrectly evaluating whether a…
sei-bstein May 17, 2023
597afb1
Merge branch 'main' into next
sei-bstein May 18, 2023
8f00056
Add registration date range to challenges report
sei-bstein May 23, 2023
9e55b9e
Fix player report bugs
sei-bstein May 30, 2023
4834369
Merge branch 'main' into new/reports-revamp
sei-bstein Jun 1, 2023
8825f10
Server-side hardening for illegal mime type upload. Removed bare repo…
sei-bstein Jun 13, 2023
c2c672f
Add improved file upload validation. Add editor config to suppress pr…
sei-bstein Jun 13, 2023
be15550
Merge pull request #202 from cmu-sei/new/ticket-security-enhancements
sei-bstein Jun 13, 2023
349269b
Update unit tests
sei-bstein Jun 13, 2023
0aaf3b4
Remove server-side html escaping of user input (handled client side).
sei-bstein Jun 14, 2023
d1f1c92
Resolved an issue that prevented assignees from being display in the …
sei-bstein Jun 14, 2023
7925081
Remove unnecessary dependency injection from the app hub.
sei-bstein Jun 14, 2023
ebc9094
Merge branch 'main' into next
sei-bstein Jun 14, 2023
36bcd4d
Fix build error in ticket service
sei-bstein Jun 15, 2023
cfcf0e4
Merge branch 'main' into next
sei-bstein Jun 15, 2023
2f987ce
Merge branch 'main' into new/gamebrain-integration-2023
sei-bstein Jun 15, 2023
3efcb98
Fix merge issue from main
sei-bstein Jun 15, 2023
5191c67
Resolve changes from the merge
sei-bstein Jun 15, 2023
e29fa52
Initial version of enrollment report and refactor
sei-bstein Jun 21, 2023
4c7bfc9
Add minimal unit tests for enrollment report
sei-bstein Jun 21, 2023
6b29bcd
Additional refinements to enrollment report
sei-bstein Jun 22, 2023
9111818
Remove gamebrain schema generator (no longer needed)
sei-bstein Jun 22, 2023
600e0ee
Add WhenCreated to player table.
sei-bstein Jun 22, 2023
0652dff
Added export for enrollment report.
sei-bstein Jun 22, 2023
06eb2f6
Remove unnecessary pragma warning for new C# tools, unbreak player se…
sei-bstein Jun 23, 2023
ea178e4
More work on enrollment report
sei-bstein Jun 26, 2023
7f06419
Clarify comments on Enrollment report query
sei-bstein Jun 26, 2023
07c73b3
Fix line chart for enrollment, update validation strategies, add new …
sei-bstein Jun 27, 2023
fccde12
Page to default values when illegal paging is requested. Add Challeng…
sei-bstein Jun 28, 2023
b2305e1
Refactor of practice backend
sei-bstein Jun 29, 2023
0514b9f
Add new user fields for created on, last login date, and login count.…
sei-bstein Jun 30, 2023
5779642
Rename reports folder
sei-bstein Jul 6, 2023
31d6199
Merge branch 'next' into feature/practice-mode
sei-bstein Jul 6, 2023
58e09e3
Add tests for query extensions
sei-bstein Jul 7, 2023
a5e42e1
Started work on practice report
sei-bstein Jul 7, 2023
d8fd156
Code cleanup
sei-bstein Jul 7, 2023
3f12d61
Fix failing integration tests
sei-bstein Jul 9, 2023
62e5cd5
Fix a bug with date processing for the enrollment report
sei-bstein Jul 9, 2023
f1bbcc7
Merge branch 'feature/practice-mode' into practice-report
sei-bstein Jul 9, 2023
35499e7
Work on practice mode report
sei-bstein Jul 12, 2023
03675ce
Add metadata query
sei-bstein Jul 13, 2023
d887573
Improvements to practice report
sei-bstein Jul 14, 2023
64dd164
Update practice report models
sei-bstein Jul 14, 2023
ac0a87f
Add player performance tab to practice mode report
sei-bstein Jul 17, 2023
3d66e6e
Wrapping up a draft of practice mode
sei-bstein Jul 19, 2023
777bc8c
Fix integration test issues
sei-bstein Jul 20, 2023
eaeeaf5
Direct dotnet restore command in Github Action to src
sei-bstein Jul 20, 2023
5341ce5
Update GH actions config for correct solutions file config.
sei-bstein Jul 20, 2023
06320d8
Merge branch 'next' into feature/practice-mode
sei-bstein Jul 20, 2023
15cd50b
Delete extra sln file
sei-bstein Jul 20, 2023
ea024dc
Fix stackoverflow in captain resolution
sei-bstein Jul 20, 2023
081f75a
Improvements to support report and solution tooling.
sei-bstein Jul 20, 2023
437fcbe
Improvements to support report filters
sei-bstein Jul 20, 2023
a7255c3
Code cleanup in engine service
sei-bstein Jul 20, 2023
3abc958
Automatically sort string filters for reports
sei-bstein Jul 20, 2023
9a1b145
fixed an issue with the sponsor filter on the enrollment report
sei-bstein Jul 21, 2023
8eb400e
Guard against orphaned specIds in the practice mode report
sei-bstein Jul 21, 2023
6f897ec
Add games filter to enrollment service.
sei-bstein Jul 21, 2023
dd1ce02
Guard against unexpected nulls in practice mode report
sei-bstein Jul 21, 2023
abedd01
Guard against unexpected sponsor nulls in practice mode report
sei-bstein Jul 21, 2023
abcd3c9
Fix criteria processing for practice mode report
sei-bstein Jul 24, 2023
925640f
PlayerMode to challenges
sei-bstein Jul 24, 2023
1e170eb
Query practice mode report based on the challenge-level PlayerMode fl…
sei-bstein Jul 24, 2023
d878cea
Code cleanup in game engine service
sei-bstein Jul 24, 2023
f5924b5
Code cleanup
sei-bstein Jul 24, 2023
c1ba853
Fix PlayerService constructor signature to remove unused injections
sei-bstein Jul 24, 2023
8770ed5
Code cleanup
sei-bstein Jul 25, 2023
27b93c7
Align parameter names
sei-bstein Jul 25, 2023
c952d81
Add stat summary for enrollment report
sei-bstein Jul 26, 2023
7406674
Code cleanup
sei-bstein Jul 26, 2023
58e50c3
Fix build
sei-bstein Jul 26, 2023
ce45e60
Guard against null sponsors in enrollment report. Hide practice games…
sei-bstein Jul 27, 2023
b208d4f
Present percentile for Practice Mode report as a 0-100 value (up from…
sei-bstein Jul 27, 2023
ddcbd02
Add challenge result to practice mode report
sei-bstein Jul 27, 2023
c43c03c
Optimize sponsor count stat for the enrollment report
sei-bstein Jul 27, 2023
f7114a5
Code cleanup
sei-bstein Jul 28, 2023
35c384f
Remove unused property of game model
sei-bstein Jul 28, 2023
97a703d
Improvements to practice mode workflow (allow detection of active pra…
sei-bstein Jul 31, 2023
b40660c
Change model shape for user active practice challenge.
sei-bstein Aug 2, 2023
7a7bd5f
Enhance information available for an active practice challenge to sup…
sei-bstein Aug 2, 2023
81c8a64
Improvement to practice mode/playcomponent
sei-bstein Aug 2, 2023
df9fc7b
More support for auto-deploy of practice challenges/ new 'play' compo…
sei-bstein Aug 3, 2023
d1621a9
More work on autolaunch/play component
sei-bstein Aug 4, 2023
bfe9a65
Finish autolaunch. Resolves #227
sei-bstein Aug 4, 2023
f9d1d87
Fix a bug in practice report where player count per sponsor was not c…
sei-bstein Aug 4, 2023
fbbd7b1
Fix test game engine service interface sig
sei-bstein Aug 4, 2023
b444457
Fix failing test
sei-bstein Aug 4, 2023
16849c2
Corrected resolution of json options for integration tests.
sei-bstein Aug 4, 2023
505bf67
Code cleanup
sei-bstein Aug 4, 2023
eb290ae
Allow API key authentication to resolve grader keys as well as standa…
sei-bstein Aug 5, 2023
1541cbb
set default solution path
sei-bstein Aug 5, 2023
b75727d
Additional test for grader/apikey authentication.
sei-bstein Aug 5, 2023
6ce8837
Revert "Additional test for grader/apikey authentication."
sei-bstein Aug 5, 2023
9e43eb3
Additional test for grader api key resolution.
sei-bstein Aug 5, 2023
7a8c736
Added revised grader key authentication and modified _Controller to r…
sei-bstein Aug 5, 2023
3e4ce91
Remove incorrect tests
sei-bstein Aug 5, 2023
0d147a3
Update game engine mapper to reflect existing mapping in ChallengeMap…
sei-bstein Aug 8, 2023
2a237c3
Merge from next
sei-bstein Aug 14, 2023
3674b8a
Merge branch 'feature/practice-mode' into local/admin-practice
sei-bstein Aug 14, 2023
d60b6eb
Add practice admin stuff
sei-bstein Aug 15, 2023
c89ddec
Improvements to practice admin
sei-bstein Aug 15, 2023
83207b7
Set default topo timeout to 300 sec (up from 100).
sei-bstein Aug 15, 2023
d091ad6
Finished up practice certificates
sei-bstein Aug 16, 2023
b758389
Fixed broken constructor sig intests
sei-bstein Aug 16, 2023
9832d8d
Merge branch 'next' into feature/practice-mode
sei-bstein Aug 17, 2023
92f493c
Fixed hours/minutes display for practice certificates and added suppo…
sei-bstein Aug 17, 2023
3598d26
Always archive team challenges on reset
sei-bstein Aug 17, 2023
fd0aa15
Removed test (the rule is no longer true)
sei-bstein Aug 17, 2023
11efb65
Playing with various pdf rendering options?
sei-bstein Aug 18, 2023
e72efc8
Various code cleanup
sei-bstein Aug 21, 2023
0788457
Merge branch 'feature/practice-mode' into local/serverside-certificates
sei-bstein Aug 21, 2023
c179168
Do server-side rendering of certificates in PNG format.
sei-bstein Aug 22, 2023
673dd79
Update tests
sei-bstein Aug 22, 2023
37be94a
Finish server side generation of html for both practice and competitive.
sei-bstein Aug 23, 2023
b702490
Fix test signatures
sei-bstein Aug 23, 2023
2dcd777
Make published certificate collections on User default to empty lists
sei-bstein Aug 23, 2023
571e9bf
Bug fixes for various practice mode session end things.
sei-bstein Aug 24, 2023
64c7433
Test fixes
sei-bstein Aug 24, 2023
4f34ed7
Bug fixes to practice mode.
sei-bstein Aug 25, 2023
c00b087
Addresses #236 along with a sister commit in GBUI.
sei-bstein Aug 25, 2023
cc4b61f
Fix test types
sei-bstein Aug 28, 2023
3e89fb5
Update dockerfile for chromium install.
sei-bstein Aug 28, 2023
c9a91b8
Update Dockerfile - move chromium install to production multistage.
sei-bstein Aug 28, 2023
a8dbeda
Accommodate docker execution of chromium with --no-sandbox
sei-bstein Aug 28, 2023
85115f7
Disable use of dev shared memory for chromium image generation.
sei-bstein Aug 28, 2023
e2c80ca
Request full challenge doc from Topomojo during spec sync.
sei-bstein Aug 30, 2023
349ee79
Fix for challenge doc text in practice mode
sei-bstein Aug 30, 2023
d59c424
Try wkhtmltopdf as alternate image generation tool.
sei-bstein Aug 31, 2023
286f5a4
Use correct version of wkhtmltopdf binary
sei-bstein Aug 31, 2023
038d263
DB changes for require sponsor
sei-bstein Aug 31, 2023
400417d
Remove stray pdf
sei-bstein Aug 31, 2023
50167fc
Decrease quality of images rendered by wkhtmltoimage
sei-bstein Aug 31, 2023
39b6fd4
Set wkhtmltoimage quality to 30
sei-bstein Aug 31, 2023
64b32d3
Rename player-facing 'Practice Mode' to 'Practice Area'
sei-bstein Aug 31, 2023
8ac6720
Fix practice area report routes
sei-bstein Aug 31, 2023
041b089
Fix count issue on the player prac/competitive report
sei-bstein Sep 1, 2023
e496ea6
Fix a count issue on the 'by challenge' grouping of the practice area…
sei-bstein Sep 1, 2023
8bcf145
allow authenticated users to retrieve practice mode settings
sei-bstein Sep 1, 2023
164daa3
Fix grouping issue with per-mode practice area report
sei-bstein Sep 1, 2023
2804638
Code cleanup
sei-bstein Sep 1, 2023
0434ce5
Fix typo in Enrollment report desc
sei-bstein Sep 1, 2023
64698cb
Correct calculation of users per sponsor in Enrollment report.
sei-bstein Sep 1, 2023
33e2814
merge from main
sei-bstein Sep 1, 2023
9b811cf
Change roles who can access reporting.
sei-bstein Sep 1, 2023
d94f8bc
Improve summary info on report cards to better reflect the correspond…
sei-bstein Sep 7, 2023
1ac18c4
- corrected an issue that caused practice challenges to appear as tho…
sei-bstein Sep 7, 2023
b7928d7
Resolved an issue which caused the enrollment report to fail to repor…
sei-bstein Sep 7, 2023
bdb4443
Fix failing unit test and add a new one for prac/comp challenge/game …
sei-bstein Sep 7, 2023
911e5b2
Resolved an issue that prevented non-registrars from extending/resett…
sei-bstein Sep 7, 2023
3465f78
Merge branch 'main' into next
sei-bstein Sep 7, 2023
9e27609
Merge branch 'main' into next
sei-bstein Sep 7, 2023
3711320
Code cleanup and add dev env logging.
sei-bstein Sep 7, 2023
be3d917
FIxed an issue that prevented the support report's CSV export from wo…
sei-bstein Sep 7, 2023
af337f5
Resolved issues that caused errors upon invocation of the support and…
sei-bstein Sep 7, 2023
e0b4839
Merge branch 'next' of https://github.com/cmu-sei/Gameboard into next
sei-bstein Sep 7, 2023
08932b7
Resolved an issue that caused the list of attempts in the practice re…
sei-bstein Sep 8, 2023
10ba68b
Removed an unnecessary db call from the Enrollment report.
sei-bstein Sep 8, 2023
9720158
Merge from next
sei-bstein Sep 8, 2023
3ba58ea
More sponsor fixup
sei-bstein Sep 8, 2023
15c1812
Merge branch 'main' into next
sei-bstein Sep 8, 2023
b2af944
Merge branch 'next' into feature/require-sponsor
sei-bstein Sep 8, 2023
35e4528
Require sponsor
sei-bstein Sep 8, 2023
ebe2dbc
More work on require sponsor
sei-bstein Sep 8, 2023
0845f37
Prohibit sponsorless players from enrolling in games.
sei-bstein Sep 11, 2023
9adb609
Prevent players from registering practice challenges (in addition to …
sei-bstein Sep 12, 2023
fe64513
Merge branch 'feature/require-sponsor-validation' into feature/requir…
sei-bstein Sep 12, 2023
f95fc81
MOre work on require sponsor schema change.
sei-bstein Sep 12, 2023
d3f7151
Merge from issue/236
sei-bstein Sep 12, 2023
85e63ed
Remove designer from role list for admin enroll.
sei-bstein Sep 12, 2023
fea3291
More sponsor fixup
sei-bstein Sep 12, 2023
0331be5
Merge branch 'next' into feature/require-sponsor
sei-bstein Sep 13, 2023
1572212
Merge branch 'main' into next
sei-bstein Sep 13, 2023
4aa89e2
More sponsor schema
sei-bstein Sep 13, 2023
f62e6af
Finalized user/player sponsor schema changes before fixing tests
sei-bstein Sep 13, 2023
0f1d39e
Remove default value for HasDefaultSponsor - handling it in app logic…
sei-bstein Sep 13, 2023
42a3347
Remove use of env in GameboardDbContext (we handle this in app start …
sei-bstein Sep 13, 2023
8580f4f
Add migration for sponsor schema change. Add log for enabling sensiti…
sei-bstein Sep 13, 2023
cd2d372
Correct migration to populate HasDefaultSponsor based on pre-migratio…
sei-bstein Sep 13, 2023
6c998f7
Optimize PG migration and add SQLserver custom migration.
sei-bstein Sep 13, 2023
1664a09
Cleanup
sei-bstein Sep 13, 2023
4ce4d8b
Allow the GEtUserActiveChallenges op to return challenges with no end…
sei-bstein Sep 13, 2023
7cb2f29
Tone down EF query logging in non-prod environments.
sei-bstein Sep 13, 2023
1126bcf
Cleaned up resolution of team gamespace limit, refactored, and added …
sei-bstein Sep 14, 2023
8ef968e
Merge branch 'issue/258' into next
sei-bstein Sep 14, 2023
03d13bd
Update test signatures
sei-bstein Sep 14, 2023
a019e73
Make practice mode gamespace limit eval use common logic with competi…
sei-bstein Sep 14, 2023
6273fa7
Add logging messages for EF logging configuration (loggingception)
sei-bstein Sep 14, 2023
bce80c7
Add logger to datastartupextensions
sei-bstein Sep 14, 2023
4e74cfc
Log GameboardExceptions as 500-level (since they're app failures, not…
sei-bstein Sep 14, 2023
29c9a49
Fix expected exception in player unenroll tests
sei-bstein Sep 14, 2023
f51c49a
Code cleanup
sei-bstein Sep 14, 2023
9dd66f0
Remove logging config meta-logging - EF settings were being overridde…
sei-bstein Sep 14, 2023
66043b4
Improvements to ef logging structure.
sei-bstein Sep 14, 2023
c881eb5
Reverse changes that allow player records with no end date to yield a…
sei-bstein Sep 15, 2023
e7c8de6
Correct use of .First
sei-bstein Sep 15, 2023
623e686
Disable the developer exception page by default, even in devenvs (bec…
sei-bstein Sep 15, 2023
3aef333
Return game challenge specs in alpha order.
sei-bstein Sep 15, 2023
16e22db
Merge from next
sei-bstein Sep 15, 2023
72bd67e
Merge branch 'next' into feature/require-sponsor
sei-bstein Sep 18, 2023
9f31bb8
Code cleanup
sei-bstein Sep 18, 2023
7330d1c
Supporting exception architecture for non-null/foreign key sponsors.
sei-bstein Sep 18, 2023
71dffc5
Update build task to include all projects.
sei-bstein Sep 18, 2023
7132e32
Clarify default sponsor assignment.
sei-bstein Sep 18, 2023
226f38e
Improvements to specimen builders for integration tests (supporting s…
sei-bstein Sep 18, 2023
7ed3784
Enable sensitive data logging only in dev
sei-bstein Sep 18, 2023
92864be
Consolidate data state builder interface. Don't swallow exception on …
sei-bstein Sep 18, 2023
b7bcb02
Namespace cleanup
sei-bstein Sep 18, 2023
5e3f60a
Resolve usercontroll test errors
sei-bstein Sep 18, 2023
188cfb7
Updates to tests to use fixture/specimen creation
sei-bstein Sep 18, 2023
04e2cfe
Revise tests to accommodate non-null sponsors
sei-bstein Sep 19, 2023
d00e684
More work on require sponsor - new schema changes.
sei-bstein Sep 19, 2023
ffd9507
More backend for require sponsor - streamlined sponsor API.
sei-bstein Sep 20, 2023
54c5bde
Clean up sponsor controller/command architecture.
sei-bstein Sep 20, 2023
d4ffcda
Update content type validation for sponsors
sei-bstein Sep 20, 2023
63bc23b
More required sponsor - remove manual tracking of team sponsors, adju…
sei-bstein Sep 21, 2023
9d11dbb
Start on parent sponsor
sei-bstein Sep 22, 2023
2f0be50
Refactor the set avatar operation for sponsors into its own thing sin…
sei-bstein Sep 25, 2023
4fdef70
Reshape sponsors endpoints to make more sense.
sei-bstein Sep 26, 2023
a3c4963
Fix broken sponsor test
sei-bstein Sep 26, 2023
0473a60
Correct resolution of captain during player enlistment by invitation …
sei-bstein Sep 26, 2023
7706435
Resolves #156 and adds unit tests.
sei-bstein Sep 26, 2023
935a8c6
Move unit test of enroll to integration test because of mocking limit…
sei-bstein Sep 27, 2023
7ab8520
Code cleanup
sei-bstein Sep 27, 2023
5e7e48d
Ignore HasDeployedGamespace when cleaning up challenges after team re…
sei-bstein Sep 27, 2023
7d6c47a
Guard against challenges not having players attached by team Id
sei-bstein Sep 27, 2023
373ad93
Ported fix to job service from gamebrain integration branch. Resolves…
sei-bstein Sep 27, 2023
501cdf4
Add solution guide field for challenge specs (for practice mode). Res…
sei-bstein Sep 28, 2023
2ff1df6
Add extra logging for API failures during sync.
sei-bstein Sep 28, 2023
c0c6cd2
Add suggested searches to practice area. Resolves #233.
sei-bstein Sep 29, 2023
3d600b6
Add challenge search by playerId. Resolves #263.
sei-bstein Oct 4, 2023
bb9ad95
Also search challenges by TeamID
sei-bstein Oct 4, 2023
eca59d7
Addresses an issue where asset links in challenge markdown were somet…
sei-bstein Oct 4, 2023
330d62c
Extend fix for #213 to practice.
sei-bstein Oct 4, 2023
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
3 changes: 2 additions & 1 deletion .vscode/tasks.json
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@
"type": "process",
"args": [
"build",
"${workspaceFolder}/src/Gameboard.Api/Gameboard.Api.csproj",
"${workspaceFolder}/src",
"/property:GenerateFullPaths=true",
"/consoleloggerparameters:NoSummary"
],
Expand Down Expand Up @@ -165,6 +165,7 @@
"ef",
"database",
"update",
"--verbose",
"--project",
"${workspaceFolder}/src/Gameboard.Api",
"--context",
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
using System.Security.Claims;
using System.Text.Encodings.Web;
using Gameboard.Api;
using Microsoft.AspNetCore.Authentication;
using Microsoft.Extensions.Logging;
using Microsoft.Extensions.Options;
Expand Down Expand Up @@ -31,11 +30,12 @@ protected override Task<AuthenticateResult> HandleAuthenticateAsync()
{
var claims = new List<Claim>
{
new Claim(ClaimTypes.Name, _actingUser.Name),
new Claim(ClaimTypes.NameIdentifier, _actingUser.Id),
new Claim(AppConstants.SubjectClaimName, _actingUser.Id),
new Claim(AppConstants.ApprovedNameClaimName, _actingUser.Name),
new Claim(AppConstants.RoleListClaimName, _actingUser.Role.ToString())
new(ClaimTypes.Name, _actingUser.Name),
new(ClaimTypes.NameIdentifier, _actingUser.Id),
new(AppConstants.SubjectClaimName, _actingUser.Id),
new(AppConstants.ApprovedNameClaimName, _actingUser.Name),
new(AppConstants.RoleListClaimName, _actingUser.Role.ToString()),
new(AppConstants.SponsorClaimName, _actingUser.SponsorId)
};

var identity = new ClaimsIdentity(claims, AuthScheme.Name);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,4 +9,5 @@ internal class TestAuthenticationUser
public string Id { get; set; } = DEFAULT_USERID;
public string Name { get; set; } = "";
public UserRole Role { get; set; } = UserRole.Member;
public string SponsorId { get; set; } = string.Empty;
}
Original file line number Diff line number Diff line change
@@ -1,29 +1,42 @@
using Gameboard.Api.Data;
using Gameboard.Api.Tests.Shared;

namespace Gameboard.Api.Tests.Integration.Fixtures;

public interface IDataStateBuilder
{
IDataStateBuilder Add<TEntity>(IFixture fixture) where TEntity : class, IEntity;
IDataStateBuilder Add<TEntity>(IFixture fixture, Action<TEntity> entityBuilder) where TEntity : class, IEntity;
IDataStateBuilder Add<TEntity>(TEntity entity, Action<TEntity>? entityBuilder = null) where TEntity : class, IEntity;
IDataStateBuilder AddRange<TEntity>(ICollection<TEntity> entities) where TEntity : class, IEntity;
}

internal class DataStateBuilder : IDataStateBuilder
{
private readonly GameboardDbContext _DbContext;

public DataStateBuilder(GameboardDbContext dbContext) => _DbContext = dbContext;

public IDataStateBuilder Add<TEntity>(TEntity entity, Action<TEntity>? entityBuilder = null) where TEntity : class, IEntity
public IDataStateBuilder Add<TEntity>(IFixture fixture) where TEntity : class, IEntity
=> Add<TEntity>(fixture, null);

public IDataStateBuilder Add<TEntity>(IFixture fixture, Action<TEntity>? entityBuilder) where TEntity : class, IEntity
{
var entity = fixture.Create<TEntity>() ?? throw new GbAutomatedTestSetupException($"The test fixture can't create entity of type {typeof(TEntity)}");
entityBuilder?.Invoke(entity);
_DbContext.Add(entity);

try
{
_DbContext.Add(entity);
}
catch (Exception ex)
{
System.Diagnostics.Debug.WriteLine($"ex:{ex.Message}");
}
return this;
}

public IDataStateBuilder AddRange<TEntity>(IEnumerable<TEntity> entities) where TEntity : class, IEntity
public IDataStateBuilder Add<TEntity>(TEntity entity, Action<TEntity>? entityBuilder = null) where TEntity : class, IEntity
{
entityBuilder?.Invoke(entity);
_DbContext.Add(entity);
return this;
}

public IDataStateBuilder AddRange<TEntity>(ICollection<TEntity> entities) where TEntity : class, IEntity
{
foreach (var entity in entities)
Add(entity);
Expand Down

This file was deleted.

Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
using Gameboard.Api.Tests.Shared;
using Gameboard.Api.Common;

namespace Gameboard.Api.Tests.Integration.Fixtures;

Expand Down
Original file line number Diff line number Diff line change
@@ -1,12 +1,8 @@
using Gameboard.Api;

namespace Gameboard.Api.Tests.Integration.Fixtures;

public class TeamBuilderResult
{
public required string TeamId { get; set; }
public required Api.Data.Challenge? Challenge { get; set; }
public required Api.Data.Game Game { get; set; }
public required Api.Data.Player Manager { get; set; }
public required IEnumerable<Api.Data.Player> Players { get; set; }
public required Data.Game Game { get; set; }
public required Data.Player Manager { get; set; }
}
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
using Gameboard.Api.Tests.Shared;
using Gameboard.Api.Common;
using Gameboard.Api.Data;

namespace Gameboard.Api.Tests.Integration.Fixtures;

Expand All @@ -13,203 +14,23 @@ private static T BuildEntity<T>(T entity, Action<T>? builder = null) where T : c
// eventually will replace these with registrations in the customization (like the integration test project does)
private static string GenerateTestGuid() => Guid.NewGuid().ToString("n");

public static void AddChallengeSpec(this IDataStateBuilder dataStateBuilder, Action<Data.ChallengeSpec>? specBuilder = null)
=> dataStateBuilder.Add(BuildChallengeSpec(dataStateBuilder, specBuilder));
public static TEntity Build<TEntity>(this IDataStateBuilder dataStateBuilder, IFixture fixture) where TEntity : class, IEntity
=> Build<TEntity>(dataStateBuilder, fixture, null);

public static Data.ChallengeSpec BuildChallengeSpec(this IDataStateBuilder dataStateBuilder, Action<Data.ChallengeSpec>? specBuilder = null)
=> BuildEntity
(
new Data.ChallengeSpec
{
Id = GenerateTestGuid(),
Game = BuildGame(dataStateBuilder),
Name = "Integration Test Challenge Spec",
AverageDeploySeconds = 1,
Points = 50,
X = 0,
Y = 0,
R = 1
},
specBuilder
);
public static TEntity Build<TEntity>(this IDataStateBuilder dataStateBuilder, IFixture fixture, Action<TEntity>? entityBuilder) where TEntity : class, IEntity
{
var entity = fixture.Create<TEntity>();
entityBuilder?.Invoke(entity);
return entity;
}

public static void AddChallenge(this IDataStateBuilder dataStateBuilder, Action<Data.Challenge>? challengeBuilder = null)
=> dataStateBuilder.Add(BuildChallenge(dataStateBuilder, challengeBuilder));

public static Data.Challenge BuildChallenge(this IDataStateBuilder dataStateBuilder, Action<Data.Challenge>? challengeBuilder = null)
=> BuildEntity
(
new Data.Challenge
{
Name = "Integration Test Challenge",
},
new Data.Challenge { Name = "Integration Test Challenge" },
challengeBuilder
);

public static void AddGame(this IDataStateBuilder dataStateBuilder, Action<Data.Game>? gameBuilder = null)
=> dataStateBuilder.Add(BuildGame(dataStateBuilder, gameBuilder));

public static Data.Game BuildGame(this IDataStateBuilder dataStateBuilder, Action<Data.Game>? gameBuilder = null)
=> BuildEntity
(
new Data.Game
{
Id = GenerateTestGuid(),
Name = "Test game",
Competition = "Test competition",
Season = "1",
Track = "Individual",
Sponsor = "Test Sponsor",
GameStart = DateTimeOffset.UtcNow,
GameEnd = DateTime.UtcNow + TimeSpan.FromDays(30),
RegistrationOpen = DateTimeOffset.UtcNow,
RegistrationClose = DateTime.UtcNow + TimeSpan.FromDays(30),
RegistrationType = Gameboard.Api.GameRegistrationType.Open,
},
gameBuilder
);

public static void AddPlayer(this IDataStateBuilder dataStateBuilder, Action<Data.Player>? playerBuilder = null)
=> dataStateBuilder.Add(BuildPlayer(dataStateBuilder, playerBuilder));

public static Data.Player BuildPlayer(this IDataStateBuilder dataStateBuilder, Action<Data.Player>? playerBuilder = null)
{
// TODO: this is potentially urky if the testing dev sets userid but not user's id
var userId = GenerateTestGuid();

return BuildEntity
(
new Data.Player
{
Id = GenerateTestGuid(),
TeamId = GenerateTestGuid(),
ApprovedName = "Integration Test Player",
Sponsor = "Integration Test Sponsor",
Role = Gameboard.Api.PlayerRole.Manager,
User = new Data.User { Id = userId },
UserId = userId
},
playerBuilder
);
}

/// <summary>
/// Creates a team with a challenge, and players dictated by the options parameter.
/// </summary>
/// <param name="dataStateBuilder"></param>
/// <param name="fixture"></param>
/// <param name="optsBuilder"></param>
/// <returns></returns>
public static TeamBuilderResult AddTeam(this IDataStateBuilder dataStateBuilder, IFixture fixture, Action<TeamBuilderOptions> optsBuilder)
{
var options = new TeamBuilderOptions
{
Challenge = new SimpleEntity { Id = fixture.Create<string>(), Name = fixture.Create<string>() },
Name = fixture.Create<string>(),
NumPlayers = 5,
GameBuilder = g => { },
TeamId = fixture.Create<string>()
};

optsBuilder.Invoke(options);

// fill out properties
var teamName = string.IsNullOrWhiteSpace(options.Name) ? fixture.Create<string>() : options.Name;

var game = new Api.Data.Game
{
Id = fixture.Create<string>(),
// just to avoid obnoxious overconfig on the other end
RegistrationClose = DateTimeOffset.UtcNow.AddYears(1),
RegistrationOpen = DateTimeOffset.UtcNow.AddYears(-1),
RegistrationType = Api.GameRegistrationType.Open
};

options.GameBuilder?.Invoke(game);

Data.Challenge? challenge = null;
if (options.Challenge != null)
{
var specId = fixture.Create<string>();
challenge = new Api.Data.Challenge
{
Id = options.Challenge.Id,
Name = options.Challenge.Name,
Game = game,
SpecId = specId,
TeamId = options.TeamId
};

dataStateBuilder.AddChallengeSpec(spec =>
{
spec.Id = specId;
spec.Name = fixture.Create<string>();
});
}

// create players
var players = new List<Data.Player>();

for (var i = 0; i < options.NumPlayers; i++)
{
var createManager = i == 0;
var player = new Data.Player
{
Id = fixture.Create<string>(),
ApprovedName = teamName,
Name = teamName,
Role = createManager ? Api.PlayerRole.Manager : Api.PlayerRole.Member,
TeamId = options.TeamId,
User = new Data.User { Id = fixture.Create<string>() },
Challenges = challenge != null ? new List<Api.Data.Challenge> { challenge } : new Api.Data.Challenge[] { },
Game = game
};

players.Add(player);
}
dataStateBuilder.AddRange(players);

return new TeamBuilderResult
{
Challenge = challenge,
Game = game,
TeamId = options.TeamId,
Manager = players.Single(p => p.Role == Api.PlayerRole.Manager),
Players = players,
};
}

public static IDataStateBuilder AddUser(this IDataStateBuilder dataStateBuilder, Action<Data.User>? userBuilder = null)
=> dataStateBuilder.Add(BuildUser(dataStateBuilder, userBuilder));

public static Data.User BuildUser(this IDataStateBuilder dataStateBuilder, Action<Data.User>? userBuilder = null)
=> BuildEntity
(
new Data.User
{
Id = GenerateTestGuid(),
Username = "integrationtester",
Email = "integration@test.com",
Name = "integrationtester",
ApprovedName = "integrationtester",
Sponsor = "SEI",
Role = Api.UserRole.Member
},
userBuilder
);

public static IEnumerable<Data.Player> BuildTeam(this IDataStateBuilder builder, int teamSize = 5, Action<Data.Player>? playerBuilder = null)
{
var team = new List<Data.Player>();
var teamId = GenerateTestGuid();

for (var i = 0; i < teamSize; i++)
{
var player = BuildPlayer(builder, p => p.TeamId = teamId);
playerBuilder?.Invoke(player);
team.Add(player);
}

return team;
}
}
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
using System.Net.Http.Headers;
using Gameboard.Api.Data;
using Microsoft.AspNetCore.Authorization;
using Microsoft.AspNetCore.Mvc.Testing;
using Microsoft.AspNetCore.TestHost;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -121,7 +121,7 @@ public Task<GameEngineGameState> RegradeChallenge(Api.Data.Challenge entity)
return Task.FromResult(new GameEngineGameState());
}

public Task<GameEngineGameState> StartGamespace(Api.Data.Challenge entity)
public Task<GameEngineGameState> StartGamespace(GameEngineGamespaceStartRequest request)
{
return Task.FromResult(new GameEngineGameState());
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -15,21 +15,27 @@ public ChallengeBonusControllerManualTests(GameboardTestContext testContext)
}

[Theory, GbIntegrationAutoData]
public async Task AddManual_WithValidData_Succeeds(string challengeId, string userId, string description, double pointsValue)
public async Task AddManual_WithValidData_Succeeds(string challengeId, string userId, string description, double pointsValue, IFixture fixture)
{
// given
await _testContext.WithDataState(state =>
{
state.AddUser(u =>
state.Add<Data.User>(fixture, u =>
{
u.Id = userId;
u.Role = UserRole.Support;
});

state.AddChallenge(c =>
{
c.Id = challengeId;
});
state.Add<Data.Challenge>(fixture, c => c.Id = challengeId);
// state.AddUser(u =>
// {

// });

// state.AddChallenge(c =>
// {
// c.Id = challengeId;
// });
});

var bonus = new CreateManualChallengeBonus
Expand Down
Loading
Loading