Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
32 commits
Select commit Hold shift + click to select a range
bf2de8c
Update LdapService.cs
JasonRobertFrancis Sep 8, 2025
db98b3d
Adds models for UserInfo
JasonRobertFrancis Sep 8, 2025
8c27012
Create UserInfoController.cs
JasonRobertFrancis Sep 8, 2025
96e5784
Update UserInfo.cshtml
JasonRobertFrancis Sep 8, 2025
22f6e30
Update .gitignore
JasonRobertFrancis Sep 25, 2025
25e46f4
UserInfo first draft
JasonRobertFrancis Oct 1, 2025
6a5fdfe
Updates Userinfo page
JasonRobertFrancis May 29, 2026
e11c276
Updates UserInfo page
JasonRobertFrancis Jun 16, 2026
4223666
fix: clean up unused usings and resolve nullability warnings in tests
JasonRobertFrancis Jul 28, 2026
e89991c
Addresses code-review issues
JasonRobertFrancis Jul 29, 2026
f30712c
fix: resolve S1144 and S6580 Sonar warnings in IamApi
JasonRobertFrancis Jul 29, 2026
f416e35
fix: address PR reviews and linter suggestions
JasonRobertFrancis Jul 29, 2026
fed2a98
A few directory bug fixes (trailing slashes, race condition, loading …
JasonRobertFrancis Jul 30, 2026
694ecd4
Fixes the results of the code-quality-bot's review
JasonRobertFrancis Jul 30, 2026
99eebf8
fix(directory): resolve ReSharper code quality, XML doc, and unit tes…
JasonRobertFrancis Jul 30, 2026
55a94ae
Refactors to remove clones (from adding the sidebar to the directory …
JasonRobertFrancis Jul 31, 2026
4b023bf
Fixes ReSharper redundant constructor and property initializers
JasonRobertFrancis Jul 31, 2026
a65cc7c
Merges main changes in
JasonRobertFrancis Jul 31, 2026
f32f07f
Addresses linting issues
JasonRobertFrancis Aug 1, 2026
c674c9c
Addresses ReSharper issues
JasonRobertFrancis Aug 1, 2026
fb9579e
More ReSharper issues
JasonRobertFrancis Aug 1, 2026
cfde89d
ReSharper issues
JasonRobertFrancis Aug 3, 2026
cb89d91
parameterizes Instinct GraphQL query and updates system roles/permiss…
JasonRobertFrancis Aug 5, 2026
e8023d1
Fixes loading modal on directory when refreshing the page
JasonRobertFrancis Aug 5, 2026
8cd6bd5
Fixes issue with potential null value
JasonRobertFrancis Aug 5, 2026
e29d9a9
feat(userinfo): translate getBase64Image.cfm to PublicPhotoController
JasonRobertFrancis Aug 6, 2026
6a25271
Replaces .Where.FirstOrDefault to .FirstOrDefault
JasonRobertFrancis Aug 6, 2026
5a8fdb3
Updates .gitignore
JasonRobertFrancis Aug 6, 2026
aa17db0
Updates links to User Photo and linting issues
JasonRobertFrancis Aug 6, 2026
8563ac5
Merge remote-tracking branch 'origin/main' into feature/userinfo
JasonRobertFrancis Aug 6, 2026
ed417fa
Removes redundant user photo code and updates links
JasonRobertFrancis Aug 6, 2026
0dbc8f4
Removing debugging (again)
JasonRobertFrancis Aug 6, 2026
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
4 changes: 4 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -515,3 +515,7 @@ inspect-report/

# Agent folders
.claude

# Exclude Impeccable skill and hooks
.github/skills/impeccable/
.github/hooks/impeccable.json
1 change: 1 addition & 0 deletions CLAUDE.md
Original file line number Diff line number Diff line change
Expand Up @@ -44,6 +44,7 @@ When I ask a question or make an observation, respond with an answer - do NOT ju

## Testing & Git

- **No VMACS production calls**: Unit tests, local environments, and test environments must NEVER send requests to the VMACS production server. All external HTTP requests (e.g., VMACS, Instinct, IAM API) must be mocked using in-memory databases and mock HTTP clients/factories to prevent production spam.
- **UI**: Test UI changes with Playwright MCP (modals, forms, keyboard nav)
- **API**: Use Playwright MCP to visit endpoints, APIs require browser auth, `curl` fails
- **Branch & merge flow**: Branch off `main`, named `feature/`|`fix/`|etc. plus the JIRA ticket if applicable (e.g. `feature/VPR-104-clinical-scheduler`). After code review, merge into `Development` and push, which deploys to TEST. After the PR is approved on TEST, merge into `main`. Every change goes through `Development` first.
Expand Down
2 changes: 2 additions & 0 deletions Viper.sln.DotSettings
Original file line number Diff line number Diff line change
Expand Up @@ -2,4 +2,6 @@
<s:String x:Key="/Default/CodeStyle/CodeCleanup/Profiles/=OptimizeUsings/@EntryIndexedValue">&lt;Profile name="OptimizeUsings"&gt;&lt;CSOptimizeUsings&gt;&lt;OptimizeUsings&gt;True&lt;/OptimizeUsings&gt;&lt;EmbraceInRegion&gt;False&lt;/EmbraceInRegion&gt;&lt;RegionName&gt;&lt;/RegionName&gt;&lt;/CSOptimizeUsings&gt;&lt;/Profile&gt;</s:String>
<s:String x:Key="/Default/CodeStyle/CodeCleanup/Profiles/=ShortenReferences/@EntryIndexedValue">&lt;Profile name="ShortenReferences"&gt;&lt;CSShortenReferences&gt;True&lt;/CSShortenReferences&gt;&lt;/Profile&gt;</s:String>
<s:String x:Key="/Default/CodeStyle/CodeCleanup/Profiles/=RemoveRedundancies/@EntryIndexedValue">&lt;Profile name="RemoveRedundancies"&gt;&lt;CSRemoveCodeRedundancies&gt;True&lt;/CSRemoveCodeRedundancies&gt;&lt;RemoveCodeRedundancies&gt;True&lt;/RemoveCodeRedundancies&gt;&lt;CSRemoveRedundantArgumentDefaultValues&gt;True&lt;/CSRemoveRedundantArgumentDefaultValues&gt;&lt;CSRemoveRedundantInitializers&gt;True&lt;/CSRemoveRedundantInitializers&gt;&lt;/Profile&gt;</s:String>
<s:String x:Key="/Default/CodeInspection/Highlighting/InspectionSeverities/=PartialTypeWithSinglePart/@EntryIndexedValue">DO_NOT_SHOW</s:String>
<s:String x:Key="/Default/CodeInspection/Highlighting/InspectionSeverities/=PartialMethodWithSinglePart/@EntryIndexedValue">DO_NOT_SHOW</s:String>
</wpf:ResourceDictionary>
2 changes: 2 additions & 0 deletions scripts/lint-any.js
Original file line number Diff line number Diff line change
Expand Up @@ -218,6 +218,7 @@ function runOxfmtCheckBatch(files) {
stdio: "pipe",
cwd: projectRoot,
encoding: "utf8",
shell: true,
})

if (result.error) {
Expand Down Expand Up @@ -269,6 +270,7 @@ function runOxfmtCheck(files, fix) {
const result = spawnSync("npx", ["oxfmt", "--write", ...batch], {
stdio: "inherit",
cwd: projectRoot,
shell: true,
})
if (result.error || result.status !== 0) {
allPassed = false
Expand Down
3 changes: 1 addition & 2 deletions test/Areas/Directory/VMACSServiceTest.cs
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,6 @@ public void BuildSearchPath_IncludesAuthToken()

[Theory]
[InlineData("https://vmacs-qa.example.edu")]
[InlineData("http://vmacs.example.edu/")]
public void IsValidBaseUrl_True_ForAbsoluteHttpUrls(string baseUrl)
{
Assert.True(VMACSService.IsValidBaseUrl(baseUrl));
Expand All @@ -44,7 +43,7 @@ public void IsValidBaseUrl_True_ForAbsoluteHttpUrls(string baseUrl)
[InlineData("not-a-url")]
[InlineData("/relative/path")]
[InlineData("vmacs-qa.example.edu")]
[InlineData("ftp://vmacs.example.edu")]
[InlineData("ftp://vmacs-qa.example.edu")]
[InlineData("file:///etc/passwd")]
public void IsValidBaseUrl_False_ForMissingOrNonHttpUrls(string? baseUrl)
{
Expand Down
205 changes: 205 additions & 0 deletions test/Services/UserInfoServiceTests.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,205 @@
using Microsoft.EntityFrameworkCore;
using Microsoft.Extensions.Caching.Memory;
using Microsoft.Extensions.Configuration;
using NSubstitute;
using System.Net;
using System.Text;
using Viper.Areas.Directory.Models;
using Viper.Areas.Directory.Services;
using Viper.Classes.SQLContext;
using Viper.Models.AAUD;
using Viper.Models.Courses;

namespace Viper.test.Services
{
public class UserInfoServiceTests
{
private readonly ITestOutputHelper _output;

public UserInfoServiceTests(ITestOutputHelper output)
{
_output = output;
}

private static DbContextOptions<TContext> CreateInMemoryOptions<TContext>() where TContext : DbContext
{
return new DbContextOptionsBuilder<TContext>()
.UseInMemoryDatabase(databaseName: Guid.NewGuid().ToString())
.Options;
}

[Fact]
public async Task TestGetUserInfo_WithSyntheticData()
{
_output.WriteLine("[DEBUG] Starting TestGetUserInfo with fully synthetic data...");

// 1. Arrange Config & Cache
var configData = new Dictionary<string, string?>
{
{ "Instinct:ApiUrl", "https://synthetic.instinctvet.com/" },
{ "Credentials:InstinctApi", "synthetic-password" }
};
var config = new ConfigurationBuilder()
.AddInMemoryCollection(configData)
.Build();

var memoryCache = new MemoryCache(new MemoryCacheOptions());

// 2. Mock HttpClientFactory
var mockHandler = new MockHttpMessageHandler(request =>
{
var uri = request.RequestUri?.ToString() ?? "";
if (uri.Contains("auth/token"))
{
return new HttpResponseMessage(HttpStatusCode.OK)
{
Content = new StringContent("{\"access_token\": \"synthetic-token\", \"expires_in\": 86400}", Encoding.UTF8, "application/json")
};
}
if (uri.Contains("query="))
{
var searchJson = @"
{
""data"": {
""searchUsers"": [
{
""id"": ""inst-synthetic-id"",
""instinctId"": ""inst-synthetic-id"",
""status"": ""Active"",
""isActive"": true,
""username"": ""jsmith"",
""nameFirst"": ""John"",
""nameLast"": ""Smith"",
""roles"": [
{ ""label"": ""Staff"" }
]
}
]
}
}";
return new HttpResponseMessage(HttpStatusCode.OK)
{
Content = new StringContent(searchJson, Encoding.UTF8, "application/json")
};
}
return new HttpResponseMessage(HttpStatusCode.NotFound);
});

var httpClientFactory = Substitute.For<IHttpClientFactory>();
httpClientFactory.CreateClient(Arg.Any<string>()).Returns(_ => new HttpClient(mockHandler));

// 3. Setup DbContexts and Seed Synthetic Data
var aaudOptions = CreateInMemoryOptions<AAUDContext>();
var coursesOptions = CreateInMemoryOptions<CoursesContext>();

using (var aaudSetup = new AAUDContext(aaudOptions))
{
var syntheticUser = new AaudUser
{
IamId = "99999999",
MothraId = "88888888",
MailId = "jsmith",
LoginId = "jsmith",
FirstName = "John",
LastName = "Smith",
DisplayFirstName = "John",
DisplayLastName = "Smith",
DisplayFullName = "John Smith",
Current = 1,
EmployeeId = "emp-999",
EmployeePKey = "pkey-999",
ClientId = "1"
};
aaudSetup.AaudUsers.Add(syntheticUser);

aaudSetup.Employees.Add(new Employee
{
EmpPKey = "pkey-999",
EmpTermCode = "202610",
EmpPrimaryTitle = "Synthetic Analyst",
EmpSchoolDivision = "Synthetic Division",
EmpStatus = "A",
EmpHomeDept = "Synthetic Dept",
EmpClientid = "1",
EmpAltDeptCode = "",
EmpCbuc = ""
});

await aaudSetup.SaveChangesAsync(TestContext.Current.CancellationToken);
}

using (var coursesSetup = new CoursesContext(coursesOptions))
{
coursesSetup.Terminfos.Add(new Terminfo
{
TermCode = "202610",
TermCurrentTermMulti = true,
TermAcademicYear = "",
TermDesc = "",
TermCollCode = "01",
TermStartDate = DateTime.Today,
TermEndDate = DateTime.Today,
TermCurrentTerm = true,
TermTermType = ""
});
await coursesSetup.SaveChangesAsync(TestContext.Current.CancellationToken);
}

using var aaud = new AAUDContext(aaudOptions);
using var raps = new RAPSContext(CreateInMemoryOptions<RAPSContext>());
using var courses = new CoursesContext(coursesOptions);
using var loans = new EquipmentLoanContext(CreateInMemoryOptions<EquipmentLoanContext>());
using var pps = new PPSContext(CreateInMemoryOptions<PPSContext>());
using var idcards = new IDCardsContext(CreateInMemoryOptions<IDCardsContext>());
using var keys = new KeysContext(CreateInMemoryOptions<KeysContext>());

var userInfoService = new UserInfoService(aaud, raps, courses, loans, pps, idcards, keys, config, httpClientFactory, memoryCache);

// 4. Act
// Temporary HttpHelper configuration inside the test context
var mockEnv = Substitute.For<Microsoft.AspNetCore.Hosting.IWebHostEnvironment>();
HttpHelper.Configure(memoryCache, config, mockEnv, null, null, null);

UserInfoResult? result;
try
{
result = await userInfoService.GetUserInfoAsync("99999999", "88888888");
}
finally
{
HttpHelper.Configure(null, null, null!, null, null, null);
}

// 5. Assert
Assert.NotNull(result);
_output.WriteLine($"[DEBUG] Result IamId: {result.IamId}");
_output.WriteLine($"[DEBUG] Result DisplayName: {result.DisplayFullName}");
_output.WriteLine($"[DEBUG] Result InstinctId: {result.InstinctId}");
_output.WriteLine($"[DEBUG] Result InstinctInfo.ErrorMessage: {result.InstinctInfo?.ErrorMessage}");
_output.WriteLine($"[DEBUG] Result InstinctInfo.Valid: {result.InstinctInfo?.Valid}");

Assert.Equal("99999999", result.IamId);
Assert.Equal("88888888", result.MothraId);
Assert.Equal("John Smith", result.DisplayFullName);
Assert.True(result.IsEmployee);
Assert.Equal("Synthetic Analyst", result.EmployeePrimaryTitle);
Assert.Equal("inst-synthetic-id", result.InstinctId);
Assert.Equal("jsmith", result.InstinctUsername);
}

private class MockHttpMessageHandler : HttpMessageHandler
{
private readonly Func<HttpRequestMessage, HttpResponseMessage> _handler;

public MockHttpMessageHandler(Func<HttpRequestMessage, HttpResponseMessage> handler)
{
_handler = handler;
}

protected override Task<HttpResponseMessage> SendAsync(HttpRequestMessage request, CancellationToken cancellationToken)
{
return Task.FromResult(_handler(request));
}
}
}
}
Loading
Loading