Skip to content

Commit 937e02f

Browse files
CeredronCeredron
andauthored
Enable migration of self-identified users (#1756)
* Enable migration of self-identified users * Remove no longer relevant tests --------- Co-authored-by: Ceredron <roar.mjelde@digdir.no>
1 parent 7bdafff commit 937e02f

File tree

3 files changed

+0
-102
lines changed

3 files changed

+0
-102
lines changed

Test/Altinn.Correspondence.Tests/TestingController/Migration/MigrationControllerTests.cs

Lines changed: 0 additions & 64 deletions
Original file line numberDiff line numberDiff line change
@@ -246,43 +246,6 @@ public async Task MakeCorrespondenceAvailable()
246246
Assert.True(respExt.Statuses.First().Ok);
247247
}
248248

249-
[Fact]
250-
public async Task MakeCorrespondenceAvailable_SelfIdentfied_Rejected()
251-
{
252-
MigrateCorrespondenceExt migrateCorrespondenceExt = new MigrateCorrespondenceBuilder()
253-
.CreateMigrateCorrespondence()
254-
.WithRecipient(_selfIdentifedPartyUuidUrn)
255-
.WithStatusEvent(MigrateCorrespondenceStatusExt.Read, new DateTime(2024, 1, 6, 11, 10, 21))
256-
.WithStatusEvent(MigrateCorrespondenceStatusExt.Read, new DateTime(2024, 1, 7, 15, 11, 56))
257-
.WithStatusEvent(MigrateCorrespondenceStatusExt.Read, new DateTime(2024, 1, 8, 14, 19, 22))
258-
.WithStatusEvent(MigrateCorrespondenceStatusExt.Confirmed, new DateTime(2024, 1, 8, 14, 20, 5))
259-
.WithStatusEvent(MigrateCorrespondenceStatusExt.Archived, new DateTime(2024, 1, 9, 10, 50, 17))
260-
.Build();
261-
SetNotificationHistory(migrateCorrespondenceExt);
262-
263-
CorrespondenceMigrationStatusExt resultObj = await MigrateSingleCorrespondence(migrateCorrespondenceExt);
264-
Assert.NotNull(resultObj);
265-
266-
MakeCorrespondenceAvailableRequestExt request = new MakeCorrespondenceAvailableRequestExt()
267-
{
268-
CreateEvents = false,
269-
CorrespondenceIds = [resultObj.CorrespondenceId],
270-
CorrespondenceId = resultObj.CorrespondenceId
271-
};
272-
var makeAvailableResponse = await _migrationClient.PostAsJsonAsync(makeAvailableUrl, request);
273-
Assert.True(makeAvailableResponse.IsSuccessStatusCode);
274-
MakeCorrespondenceAvailableResponseExt respExt = await makeAvailableResponse.Content.ReadFromJsonAsync<MakeCorrespondenceAvailableResponseExt>();
275-
Assert.NotNull(respExt);
276-
Assert.NotNull(respExt.Statuses);
277-
Assert.Equal(1, respExt.Statuses.Count);
278-
Assert.Equal(resultObj.CorrespondenceId, respExt.Statuses.First().CorrespondenceId);
279-
Assert.False(respExt.Statuses.First().Ok);
280-
281-
// Verify that correspondence still has IsMigrating set to true, which means we cannot retrieve it through GetOverview.
282-
var getCorrespondenceOverviewResponse = await _recipientClient.GetAsync($"correspondence/api/v1/correspondence/{resultObj.CorrespondenceId}/content");
283-
Assert.False(getCorrespondenceOverviewResponse.IsSuccessStatusCode);
284-
}
285-
286249
[Fact]
287250
public async Task MakeCorrespondenceAvailable_Defined()
288251
{
@@ -405,33 +368,6 @@ public async Task MakeCorrespondenceAvailable_SoftDeleted_OnCall()
405368
Assert.NotNull(resultObj.DialogId);
406369
}
407370

408-
[Fact]
409-
public async Task MakeCorrespondenceAvailable_OnCall_SelfIdentified_NotMadeAvailable()
410-
{
411-
MigrateCorrespondenceExt migrateCorrespondenceExt = new MigrateCorrespondenceBuilder()
412-
.CreateMigrateCorrespondence()
413-
.WithStatusEvent(MigrateCorrespondenceStatusExt.Read, new DateTime(2024, 1, 12, 14, 20, 11))
414-
.WithStatusEvent(MigrateCorrespondenceStatusExt.Confirmed, new DateTime(2024, 1, 12, 14, 21, 05))
415-
.WithStatusEvent(MigrateCorrespondenceStatusExt.Archived, new DateTime(2024, 1, 22, 09, 55, 20))
416-
.WithCreatedAt(new DateTime(2024, 1, 1, 03, 09, 21))
417-
.WithRecipient(_selfIdentifedPartyUuidUrn)
418-
.WithResourceId("skd-migratedcorrespondence-5229-1")
419-
.Build();
420-
SetNotificationHistory(migrateCorrespondenceExt);
421-
422-
migrateCorrespondenceExt.MakeAvailable = true;
423-
424-
var initializeCorrespondenceResponse = await _migrationClient.PostAsJsonAsync(migrateCorrespondenceUrl, migrateCorrespondenceExt);
425-
string result = await initializeCorrespondenceResponse.Content.ReadAsStringAsync();
426-
Assert.True(initializeCorrespondenceResponse.IsSuccessStatusCode, result);
427-
CorrespondenceMigrationStatusExt resultObj = JsonConvert.DeserializeObject<CorrespondenceMigrationStatusExt>(result);
428-
Assert.True(String.IsNullOrEmpty(resultObj.DialogId));
429-
430-
// Verify that correspondence has IsMigrating set to true, which means we cannot retrieve it through GetOverview.
431-
var getCorrespondenceOverviewResponse = await _recipientClient.GetAsync($"correspondence/api/v1/correspondence/{resultObj.CorrespondenceId}/content");
432-
Assert.False(getCorrespondenceOverviewResponse.IsSuccessStatusCode);
433-
}
434-
435371
[Fact]
436372
public async Task MakeCorrespondenceAvailable_Multiple()
437373
{

Test/Altinn.Correspondence.Tests/TestingHandler/MigrateCorrespondenceHandlerTests.cs

Lines changed: 0 additions & 33 deletions
Original file line numberDiff line numberDiff line change
@@ -233,39 +233,6 @@ public async Task MakeCorrespondenceAvailable_WithCorrespondenceId_Correspondenc
233233
_dialogportenServiceMock.VerifyNoOtherCalls();
234234
}
235235

236-
[Fact]
237-
public async Task MakeCorrespondenceAvailable_WithCorrespondenceId_CorrespondenceBelongsToSelfIdentifiedRecipient_ShouldNotMakeAvailable()
238-
{
239-
// Arrange
240-
var correspondenceId = Guid.NewGuid();
241-
var request = new MakeCorrespondenceAvailableRequest
242-
{
243-
CorrespondenceId = correspondenceId,
244-
CreateEvents = true
245-
};
246-
247-
var mockCorrespondence = CreateMockCorrespondence(correspondenceId);
248-
mockCorrespondence.Recipient = "urn:altinn:party:uuid:96B337F1-05EB-4DF0-A83A-165C14558153";
249-
250-
_correspondenceRepositoryMock.Setup(x => x.GetCorrespondenceById(
251-
correspondenceId, It.IsAny<bool>(), It.IsAny<bool>(), It.IsAny<bool>(), It.IsAny<CancellationToken>(), It.IsAny<bool>()))
252-
.ReturnsAsync(mockCorrespondence);
253-
254-
// Act
255-
var result = await _handler.MakeCorrespondenceAvailable(request, CancellationToken.None);
256-
257-
// Assert
258-
Assert.NotNull(result);
259-
Assert.True(result.IsT0);
260-
var response = result.AsT0;
261-
Assert.NotNull(response.Statuses);
262-
Assert.Single(response.Statuses);
263-
Assert.Equal(correspondenceId, response.Statuses[0].CorrespondenceId);
264-
Assert.False(response.Statuses[0].Ok);
265-
266-
_dialogportenServiceMock.VerifyNoOtherCalls();
267-
}
268-
269236
[Fact]
270237
public async Task MakeCorrespondenceAvailable_WithCorrespondenceIds_ShouldProcessMultipleCorrespondences()
271238
{

src/Altinn.Correspondence.Application/MigrateCorrespondence/MigrateCorrespondenceHandler.cs

Lines changed: 0 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -271,11 +271,6 @@ public async Task<string> MakeCorrespondenceAvailableInDialogportenAndApi(Guid c
271271
{
272272
throw new InvalidOperationException($"Correspondence with id {correspondenceId} is purged and cannot be made available in Dialogporten or API");
273273
}
274-
275-
if(!string.IsNullOrEmpty(correspondence.Recipient) && correspondence.Recipient.IsWithPartyUuidPrefix())
276-
{
277-
throw new InvalidOperationException($"Correspondence with id {correspondenceId} has a Self-Identifed user as recipient and cannot be made available in Dialogporten");
278-
}
279274

280275
// If the correspondence was soft deleted in Altinn 2, we need to pass this forward in order to set the system label correctly on the Dialog
281276
bool isSoftDeleted = await correspondenceMigrationEventHelper.IsCorrespondenceSoftDeleted(correspondence, cancellationToken);

0 commit comments

Comments
 (0)