Skip to content

Commit

Permalink
add Data_Exchange_Governance credential
Browse files Browse the repository at this point in the history
  • Loading branch information
ntruchsess committed Jul 11, 2024
1 parent aa378a8 commit 491588a
Show file tree
Hide file tree
Showing 16 changed files with 1,805 additions and 32 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -54,5 +54,8 @@ public enum VerifiedCredentialExternalTypeId
BUSINESS_PARTNER_DATA_MANAGEMENT = 10,

[EnumMember(Value = "FrameworkAgreement")]
FRAMEWORK_AGREEMENT = 11
FRAMEWORK_AGREEMENT = 11,

[EnumMember(Value = "DataExchangeGovernanceCredential")]
DATA_EXCHANGE_GOVERNANCE_CREDENTIAL = 12
}
Original file line number Diff line number Diff line change
Expand Up @@ -54,5 +54,8 @@ public enum VerifiedCredentialTypeId
BUSINESS_PARTNER_DATA_MANAGEMENT = 10,

[EnumMember(Value = "Framework Agreement")]
FRAMEWORK_AGREEMENT = 11
FRAMEWORK_AGREEMENT = 11,

[EnumMember(Value = "Date Exchange Governance")]
DATA_EXCHANGE_GOVERNANCE_CREDENTIAL = 12
}

Large diffs are not rendered by default.

Original file line number Diff line number Diff line change
@@ -0,0 +1,66 @@
/********************************************************************************
* Copyright (c) 2024 Contributors to the Eclipse Foundation
*
* See the NOTICE file(s) distributed with this work for additional
* information regarding copyright ownership.
*
* This program and the accompanying materials are made available under the
* terms of the Apache License, Version 2.0 which is available at
* https://www.apache.org/licenses/LICENSE-2.0.
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
* WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
* License for the specific language governing permissions and limitations
* under the License.
*
* SPDX-License-Identifier: Apache-2.0
********************************************************************************/

using Microsoft.EntityFrameworkCore.Migrations;

#nullable disable

namespace Org.Eclipse.TractusX.SsiCredentialIssuer.Migrations.Migrations
{
/// <inheritdoc />
public partial class _190AddDataExchangeGovernanceCredential : Migration
{
/// <inheritdoc />
protected override void Up(MigrationBuilder migrationBuilder)
{
migrationBuilder.InsertData(
schema: "issuer",
table: "verified_credential_external_types",
columns: new[] { "id", "label" },
values: new object[] { 12, "DATA_EXCHANGE_GOVERNANCE_CREDENTIAL" });

migrationBuilder.InsertData(
schema: "issuer",
table: "verified_credential_types",
columns: new[] { "id", "label" },
values: new object[] { 12, "DATA_EXCHANGE_GOVERNANCE_CREDENTIAL" });
}

/// <inheritdoc />
protected override void Down(MigrationBuilder migrationBuilder)
{
migrationBuilder.Sql("DELETE FROM issuer.verified_credential_external_type_detail_versions WHERE verified_credential_external_type_id = 12");
migrationBuilder.Sql("DELETE FROM issuer.verified_credential_type_assigned_external_types WHERE verified_credential_type_id = 12");
migrationBuilder.Sql("DELETE FROM issuer.verified_credential_type_assigned_kinds WHERE verified_credential_type_id = 12");
migrationBuilder.Sql("DELETE FROM issuer.verified_credential_type_assigned_use_cases WHERE verified_credential_type_id = 12");

migrationBuilder.DeleteData(
schema: "issuer",
table: "verified_credential_external_types",
keyColumn: "id",
keyValue: 12);

migrationBuilder.DeleteData(
schema: "issuer",
table: "verified_credential_types",
keyColumn: "id",
keyValue: 12);
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -1112,6 +1112,11 @@ protected override void BuildModel(ModelBuilder modelBuilder)
{
Id = 11,
Label = "FRAMEWORK_AGREEMENT"
},
new
{
Id = 12,
Label = "DATA_EXCHANGE_GOVERNANCE_CREDENTIAL"
});
});

Expand Down Expand Up @@ -1224,6 +1229,11 @@ protected override void BuildModel(ModelBuilder modelBuilder)
{
Id = 11,
Label = "FRAMEWORK_AGREEMENT"
},
new
{
Id = 12,
Label = "DATA_EXCHANGE_GOVERNANCE_CREDENTIAL"
});
});

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -61,6 +61,16 @@ public async Task ExecuteAsync(CancellationToken cancellationToken)

_logger.LogInformation("Start BaseEntityBatch Seeder");

await SeedTable<UseCase>("use_cases",
x => x.Id,
x => x.dataEntity.Name != x.dbEntity.Name || x.dataEntity.Shortname != x.dbEntity.Shortname,
(dbEntry, entry) =>
{
dbEntry.Name = entry.Name;
dbEntry.Shortname = entry.Shortname;
},
cancellationToken).ConfigureAwait(ConfigureAwaitOptions.None);

await SeedTable<VerifiedCredentialExternalTypeDetailVersion>("verified_credential_external_type_detail_versions",
x => x.Id,
x => x.dataEntity.Template != x.dbEntity.Template || x.dataEntity.Expiry != x.dbEntity.Expiry || x.dataEntity.ValidFrom != x.dbEntity.ValidFrom || x.dataEntity.Version != x.dbEntity.Version,
Expand All @@ -70,7 +80,8 @@ await SeedTable<VerifiedCredentialExternalTypeDetailVersion>("verified_credentia
dbEntry.Expiry = entry.Expiry;
dbEntry.ValidFrom = entry.ValidFrom;
dbEntry.Version = entry.Version;
}, cancellationToken).ConfigureAwait(ConfigureAwaitOptions.None);
},
cancellationToken).ConfigureAwait(ConfigureAwaitOptions.None);

await _context.SaveChangesAsync(cancellationToken).ConfigureAwait(ConfigureAwaitOptions.None);
_logger.LogInformation("Finished BaseEntityBatch Seeder");
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
[
{
"id": "1aacde78-35ec-4df3-ba1e-f988cddcbbd9",
"name": "None",
"shortname": "None"
}
]
Original file line number Diff line number Diff line change
Expand Up @@ -45,8 +45,8 @@
"shortname": "Puris"
},
{
"id": "1aacde78-35ec-4df3-ba1e-f988cddcbbd9",
"name": "None",
"shortname": "None"
"id": "80ef2989-7540-4c18-ac04-62712c41af6e",
"name": "DataExchangeGovernance",
"shortname": "DEG"
}
]
Original file line number Diff line number Diff line change
Expand Up @@ -5,78 +5,86 @@
"version": "1.0",
"template": "https://catena-x.net/fileadmin/user_upload/04_Einfuehren_und_umsetzen/Governance_Framework/231016_Catena-X_Use_Case_Framework_Traceability.pdf",
"valid_from": "2023-06-01 00:00:00.000000 +00:00",
"expiry": "2024-10-24 00:00:00.000000 +00:00"
"expiry": "2024-10-16 00:00:00.000000 +00:00"
},
{
"id": "1268a76a-ca19-4dd8-b932-01f24071d561",
"verified_credential_external_type_id": 2,
"version": "1.0",
"template": "https://catena-x.net/fileadmin/user_upload/04_Einfuehren_und_umsetzen/Governance_Framework/231016_Catena-X_Use_Case_Framework_PCF.pdf",
"valid_from": "2023-06-01 00:00:00.000000 +00:00",
"expiry": "2024-10-24 00:00:00.000000 +00:00"
"expiry": "2024-10-16 00:00:00.000000 +00:00"
},
{
"id": "1268a76a-ca19-4dd8-b932-01f24071d562",
"verified_credential_external_type_id": 3,
"version": "1.0",
"template": "https://catena-x.net/fileadmin/user_upload/04_Einfuehren_und_umsetzen/Governance_Framework/231016_Catena-X_Use_Case_Framework_BehaviorTwin.pdf",
"valid_from": "2023-06-01 00:00:00.000000 +00:00",
"expiry": "2024-10-24 00:00:00.000000 +00:00"
"expiry": "2024-10-16 00:00:00.000000 +00:00"
},
{
"id": "1268a76a-ca19-4dd8-b932-01f24071d563",
"verified_credential_external_type_id": 1,
"version": "2.0",
"template": "https://catena-x.net/fileadmin/user_upload/04_Einfuehren_und_umsetzen/Governance_Framework/231016_Catena-X_Use_Case_Framework_Traceability.pdf",
"valid_from": "2023-06-01 00:00:00.000000 +00:00",
"expiry": "2024-10-24 00:00:00.000000 +00:00"
"expiry": "2024-10-16 00:00:00.000000 +00:00"
},
{
"id": "1268a76a-ca19-4dd8-b932-01f24071d564",
"verified_credential_external_type_id": 1,
"version": "3.0",
"template": "https://catena-x.net/fileadmin/user_upload/04_Einfuehren_und_umsetzen/Governance_Framework/231016_Catena-X_Use_Case_Framework_Traceability.pdf",
"valid_from": "2024-01-01 00:00:00.000000 +00:00",
"expiry": "2025-06-30 00:00:00.000000 +00:00"
"expiry": "2024-10-16 00:00:00.000000 +00:00"
},
{
"id": "1268a76a-ca19-4dd8-b932-01f24071d565",
"verified_credential_external_type_id": 5,
"version": "1.0",
"template": "https://catena-x.net/fileadmin/user_upload/04_Einfuehren_und_umsetzen/Governance_Framework/231016_Catena-X_Use_Case_Framework_CircularEconomy.pdf",
"valid_from": "2024-01-01 00:00:00.000000 +00:00",
"expiry": "2024-10-24 00:00:00.000000 +00:00"
"expiry": "2024-10-16 00:00:00.000000 +00:00"
},
{
"id": "37aa6259-b452-4d50-b09e-827929dcfa15",
"verified_credential_external_type_id": 6,
"version": "1.0",
"template": "https://catena-x.net/fileadmin/user_upload/04_Einfuehren_und_umsetzen/Governance_Framework/231016_Catena-X_Use_Case_Framework_PCF.pdf",
"valid_from": "2024-03-27 00:00:00.000000 +00:00",
"expiry": "2024-12-31 00:00:00.000000 +00:00"
"expiry": "2024-10-16 00:00:00.000000 +00:00"
},
{
"id": "27d12475-c970-4979-892b-8f88e819018f",
"verified_credential_external_type_id": 8,
"version": "1.0",
"template": "https://catena-x.net/fileadmin/user_upload/04_Einfuehren_und_umsetzen/Governance_Framework/231016_Catena-X_Use_Case_Framework_DemanAndCapacity.pdf",
"valid_from": "2024-03-27 00:00:00.000000 +00:00",
"expiry": "2024-10-24 00:00:00.000000 +00:00"
"expiry": "2024-10-16 00:00:00.000000 +00:00"
},
{
"id": "a7585e82-4789-47ce-9184-5788086b1943",
"verified_credential_external_type_id": 9,
"version": "1.0",
"template": "https://catena-x.net/fileadmin/user_upload/04_Einfuehren_und_umsetzen/Governance_Framework/231016_Catena-X_Use_Case_Framework_Puris.pdf",
"valid_from": "2024-03-27 00:00:00.000000 +00:00",
"expiry": "2024-10-24 00:00:00.000000 +00:00"
"expiry": "2024-10-16 00:00:00.000000 +00:00"
},
{
"id": "0077addf-f50d-4f5e-bc41-26c45d407104",
"verified_credential_external_type_id": 10,
"version": "1.0",
"template": "https://catena-x.net/fileadmin/user_upload/04_Einfuehren_und_umsetzen/Governance_Framework/231016_Catena-X_Use_Case_Framework_BPDM.pdf",
"valid_from": "2024-03-27 00:00:00.000000 +00:00",
"expiry": "2024-10-24 00:00:00.000000 +00:00"
"expiry": "2024-10-16 00:00:00.000000 +00:00"
},
{
"id": "090efafd-9667-404f-85cc-d7d072b5ad46",
"verified_credential_external_type_id": 12,
"version": "1.0",
"template": "https://catena-x.net/fileadmin/user_upload/04_Einfuehren_und_umsetzen/How_To_Conclude_Data_Exchange_Contracts.pdf",
"valid_from": "2024-10-16 00:00:00.000000 +00:00",
"expiry": "2025-10-16 00:00:00.000000 +00:00"
}
]
Original file line number Diff line number Diff line change
Expand Up @@ -34,5 +34,9 @@
{
"verified_credential_external_type_id": 10,
"verified_credential_type_id": 10
},
{
"verified_credential_external_type_id": 12,
"verified_credential_type_id": 12
}
]
Original file line number Diff line number Diff line change
Expand Up @@ -38,5 +38,9 @@
{
"verified_credential_type_id": 10,
"verified_credential_type_kind_id": 1
},
{
"verified_credential_type_id": 12,
"verified_credential_type_kind_id": 1
}
]
Original file line number Diff line number Diff line change
Expand Up @@ -26,5 +26,9 @@
{
"verified_credential_type_id": 10,
"use_case_id": "6909ccc7-37c8-4088-99ab-790f20702460"
},
{
"verified_credential_type_id": 12,
"use_case_id": "80ef2989-7540-4c18-ac04-62712c41af6e"
}
]
Original file line number Diff line number Diff line change
Expand Up @@ -436,8 +436,6 @@ public async Task<Guid> CreateFrameworkCredential(CreateFrameworkCredentialReque
Guid.NewGuid(),
Context,
new[] { "VerifiableCredential", externalTypeId },
externalTypeId,
$"Framework Credential for UseCase {externalTypeId}",
DateTimeOffset.UtcNow,
GetExpiryDate(result.Expiry),
_settings.IssuerDid,
Expand All @@ -446,7 +444,7 @@ public async Task<Guid> CreateFrameworkCredential(CreateFrameworkCredentialReque
requestData.HolderBpn,
"UseCaseFramework",
externalTypeId,
result.Template!,
result.Template,
result.Version!
),
new CredentialStatus(
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -25,8 +25,6 @@ public record FrameworkCredential(
[property: JsonPropertyName("id")] Guid Id,
[property: JsonPropertyName("@context")] IEnumerable<string> Context,
[property: JsonPropertyName("type")] IEnumerable<string> Type,
[property: JsonPropertyName("name")] string Name,
[property: JsonPropertyName("description")] string Description,
[property: JsonPropertyName("issuanceDate")] DateTimeOffset IssuanceDate,
[property: JsonPropertyName("expirationDate")] DateTimeOffset ExpirationDate,
[property: JsonPropertyName("issuer")] string Issuer,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -59,15 +59,16 @@ public async Task GetDetailsForCompany_WithValidData_ReturnsExpected()
var result = await sut.GetUseCaseParticipationForCompany(ValidBpnl, DateTimeOffset.MinValue).ToListAsync();

// Assert
result.Should().HaveCount(9);
result.Where(x => x.Description != null).Should().HaveCount(7).And.Satisfy(
result.Should().HaveCount(10);
result.Where(x => x.Description != null).Should().HaveCount(8).And.Satisfy(
x => x.Description == "T",
x => x.Description == "BT",
x => x.Description == "CE",
x => x.Description == "QM",
x => x.Description == "DCM",
x => x.Description == "Puris",
x => x.Description == "BPDM");
x => x.Description == "BPDM",
x => x.Description == "DEG");
var traceability = result.Single(x => x.CredentialType == VerifiedCredentialTypeId.TRACEABILITY_FRAMEWORK);
traceability.VerifiedCredentials.Should().HaveCount(3).And.Satisfy(
x => x.ExternalDetailData.Version == "1.0" && x.SsiDetailData.Single().ParticipationStatus == CompanySsiDetailStatusId.PENDING,
Expand All @@ -86,15 +87,16 @@ public async Task GetDetailsForCompany_WithExpiryFilter_ReturnsExpected()
var result = await sut.GetUseCaseParticipationForCompany(ValidBpnl, dt).ToListAsync();

// Assert
result.Should().HaveCount(9);
result.Where(x => x.Description != null).Should().HaveCount(7).And.Satisfy(
result.Should().HaveCount(10);
result.Where(x => x.Description != null).Should().HaveCount(8).And.Satisfy(
x => x.Description == "T",
x => x.Description == "BT",
x => x.Description == "CE",
x => x.Description == "QM",
x => x.Description == "DCM",
x => x.Description == "Puris",
x => x.Description == "BPDM");
x => x.Description == "BPDM",
x => x.Description == "DEG");
var traceability = result.Single(x => x.CredentialType == VerifiedCredentialTypeId.TRACEABILITY_FRAMEWORK);
traceability.VerifiedCredentials.Should().HaveCount(3).And.Satisfy(
x => x.ExternalDetailData.Version == "1.0" && x.SsiDetailData.Count() == 1,
Expand Down Expand Up @@ -308,8 +310,8 @@ public async Task CheckCredentialDetailsExistsForCompany_WithInactive_ReturnsFal
#region CheckUseCaseCredentialAndExternalTypeDetails

[Theory]
[InlineData(VerifiedCredentialTypeId.TRACEABILITY_FRAMEWORK, "1268a76a-ca19-4dd8-b932-01f24071d560", "2024-10-24 +0")]
[InlineData(VerifiedCredentialTypeId.PCF_FRAMEWORK, "1268a76a-ca19-4dd8-b932-01f24071d561", "2024-10-24 +0")]
[InlineData(VerifiedCredentialTypeId.TRACEABILITY_FRAMEWORK, "1268a76a-ca19-4dd8-b932-01f24071d560", "2024-10-16 +0")]
[InlineData(VerifiedCredentialTypeId.PCF_FRAMEWORK, "1268a76a-ca19-4dd8-b932-01f24071d561", "2024-10-16 +0")]
#pragma warning disable xUnit1012
[InlineData(default, "1268a76a-ca19-6666-b932-01f24071d561", default)]
#pragma warning restore xUnit1012
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -472,8 +472,6 @@ private static string CreateSchema()
Guid.NewGuid(),
Context,
new[] { "VerifiableCredential", VerifiedCredentialExternalTypeId.TRACEABILITY_CREDENTIAL.ToString() },
VerifiedCredentialExternalTypeId.TRACEABILITY_CREDENTIAL.ToString(),
$"Framework Credential for UseCase {VerifiedCredentialExternalTypeId.TRACEABILITY_CREDENTIAL}",
DateTimeOffset.UtcNow,
DateTimeOffset.UtcNow,
"issuer",
Expand Down Expand Up @@ -662,7 +660,7 @@ public async Task GetCertificateTypes_ReturnsExpected()
var result = await _sut.GetCertificateTypes().ToListAsync();

// Assert
result.Should().HaveCount(11);
result.Should().HaveCount(12);
}

#endregion
Expand Down

0 comments on commit 491588a

Please sign in to comment.