Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
F
FIT-Connect-SDK - .NET
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Wiki
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Build
Pipelines
Jobs
Pipeline schedules
Artifacts
Deploy
Releases
Package Registry
Container Registry
Model registry
Operate
Environments
Terraform modules
Monitor
Incidents
Service Desk
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Terms and privacy
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
FIT-Connect
FIT-Connect-SDK - .NET
Commits
5fdc910d
Commit
5fdc910d
authored
5 months ago
by
Klaus Fischer
Browse files
Options
Downloads
Patches
Plain Diff
updated tests
parent
86a9b84d
No related branches found
Branches containing commit
No related tags found
No related merge requests found
Changes
3
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
Tests/E2ETest/ReplyChannelTest.cs
+60
-40
60 additions, 40 deletions
Tests/E2ETest/ReplyChannelTest.cs
Tests/E2ETest/biDiKoSettings.json
+17
-5
17 additions, 5 deletions
Tests/E2ETest/biDiKoSettings.json
Tests/MockContainer/MockContainer.cs
+1
-2
1 addition, 2 deletions
Tests/MockContainer/MockContainer.cs
with
78 additions
and
47 deletions
Tests/E2ETest/ReplyChannelTest.cs
+
60
−
40
View file @
5fdc910d
...
...
@@ -15,19 +15,20 @@ using Microsoft.Extensions.Logging;
namespace
E2ETest
;
public
record
SenderConfig
(
string
ClientId
,
string
ClientSecret
,
string
CallbackSecret
);
[
Order
(
20
)]
[
TestFixture
]
public
class
ReplyChannelTest
:
EndToEndTestBase
{
private
Sender
Config
[]
_senderConfigs
;
private
FitConnectEnvironment
_environment
=
FitConnectEnvironment
.
Test
;
private
Client
Config
[]
_senderConfigs
;
private
readonly
FitConnectEnvironment
_environment
=
FitConnectEnvironment
.
Test
;
private
int
_senderId
;
private
record
ClientConfig
(
string
ClientId
,
string
ClientSecret
,
string
CallbackSecret
);
[
OneTimeSetUp
]
public
void
OneTimeSetUp
()
{
Configuration
=
new
ConfigurationBuilder
().
AddJsonFile
(
"biDiKoSettings.json"
).
Build
();
_senderConfigs
=
Configuration
.
GetSection
(
"sender"
).
Get
<
Sender
Config
[
]>
();
_senderConfigs
=
Configuration
.
GetSection
(
"sender"
).
Get
<
Client
Config
[
]>
();
_senderId
=
DateTime
.
UtcNow
.
Millisecond
%
_senderConfigs
.
Length
;
Console
.
WriteLine
(
$"Choosing sender
{
_senderId
}
"
);
}
...
...
@@ -36,7 +37,7 @@ public class ReplyChannelTest : EndToEndTestBase {
public
override
void
Setup
()
{
base
.
Setup
();
Configuration
=
new
ConfigurationBuilder
().
AddJsonFile
(
"biDiKoSettings.json"
).
Build
();
_senderConfigs
=
Configuration
.
GetSection
(
"sender"
).
Get
<
Sender
Config
[
]>
();
_senderConfigs
=
Configuration
.
GetSection
(
"sender"
).
Get
<
Client
Config
[
]>
();
var
senderConfig
=
_senderConfigs
[
_senderId
];
//
...
...
@@ -45,10 +46,11 @@ public class ReplyChannelTest : EndToEndTestBase {
senderConfig
.
ClientId
,
senderConfig
.
ClientSecret
,
Logger
);
var
subscriberClientData
=
Configuration
.
GetSection
(
"subscribers"
).
Get
<
List
<
ClientConfig
>>();
Subscriber
=
ClientFactory
.
CreateSubscriberClient
(
_environment
,
Configuration
[
"subscriber:c
lientId
"
]
,
Configuration
[
"subscriber:c
lientSecret
"
]
,
subscriberClientData
.
First
().
C
lientId
,
subscriberClientData
.
First
().
C
lientSecret
,
new
[]
{
Configuration
[
"destination:privateDecryptionKey"
]!
}.
ToList
(),
...
...
@@ -56,24 +58,36 @@ public class ReplyChannelTest : EndToEndTestBase {
Logger
);
AddSubscriber
(
Subscriber
);
foreach
(
var
subscriber
in
subscriberClientData
)
{
var
subscriberClient
=
ClientFactory
.
CreateSubscriberClient
(
_environment
,
subscriber
.
ClientId
,
subscriber
.
ClientSecret
,
new
[]
{
Configuration
[
"destination:privateDecryptionKey"
]!
}.
ToList
(),
Configuration
[
"destination:privateSigningKey"
],
Logger
);
AddSubscriber
(
subscriberClient
);
}
DestinationId
=
Guid
.
Parse
(
Configuration
[
"destination:id"
]);
}
private
SentSubmission
_submission
=
null
!;
private
const
string
R
EPLY_CHANNEL_EMAIL
=
"dummy@trashmail.com"
;
private
const
string
T
RANSACTION_ID
=
"9xxd-432x-6543-xfd6-gfdx-fd28"
;
private
const
double
G
ROSS_AMOUNT
=
12.5
;
private
const
string
A
UTHENTICATION_VERSION
=
"1.0.34"
;
private
static
IReceivedSubmission
receivedSubmission
=
null
!;
private
const
string
R
eplyChannelEmail
=
"dummy@trashmail.com"
;
private
const
string
T
ransactionId
=
"9xxd-432x-6543-xfd6-gfdx-fd28"
;
private
const
double
G
rossAmount
=
12.5
;
private
const
string
A
uthenticationVersion
=
"1.0.34"
;
private
static
IReceivedSubmission
_
receivedSubmission
=
null
!;
private
static
JsonWebKey
GeneratedPrivateKey
{
get
;
set
;
}
private
static
JsonWebKey
GeneratedPublicKey
{
get
;
set
;
}
private
IConfigurationRoot
Configuration
{
get
;
set
;
}
=
null
!;
public
static
Guid
CaseId
{
get
;
set
;
}
private
const
string
A
UTHENTICATION_CONTENT
=
private
const
string
A
uthenticationContent
=
"QXV0b21hdGljYWxseSBCYXNlNjRVcmwgZW5jb2RlZCBTdHJpbmc"
;
private
Guid
DestinationId
{
get
;
set
;
}
=
Guid
.
Empty
;
...
...
@@ -104,16 +118,16 @@ public class ReplyChannelTest : EndToEndTestBase {
Encoding
.
UTF8
.
GetBytes
(
"{\"message\":\"Hello World\"}"
),
MediaTypeNames
.
Application
.
Json
,
"JsonFileAttachment.json"
,
"Attachment #4"
))
.
SetAuthenticationInformation
(
new
AuthenticationInformation
(
A
UTHENTICATION_CONTENT
,
A
uthenticationContent
,
AuthenticationInformationType
.
IdentificationReport
,
A
UTHENTICATION_VERSION
))
A
uthenticationVersion
))
.
SetPaymentInformation
(
new
PaymentInformation
(
PaymentMethod
.
Invoice
,
PaymentStatus
.
Booked
,
T
RANSACTION_ID
,
T
ransactionId
,
"E2E Testing the payment information"
)
{
GrossAmount
=
G
ROSS_AMOUNT
GrossAmount
=
G
rossAmount
})
.
SetReplyChannel
(
ReplyChannel
.
OfFitConnect
(
GeneratedPublicKey
,
...
...
@@ -186,13 +200,13 @@ public class ReplyChannelTest : EndToEndTestBase {
[
Test
]
[
Order
(
40
)]
public
void
T040_Subscriber_RequestSubmission
()
{
receivedSubmission
=
_
receivedSubmission
=
Subscriber
.
RequestSubmissionAsync
(
_submission
.
SubmissionId
).
Result
;
var
data
=
receivedSubmission
.
GetData
();
var
data
=
_
receivedSubmission
.
GetData
();
Logger
.
LogInformation
(
"Data {Data}"
,
data
);
var
attachments
=
receivedSubmission
.
GetAttachmentsAsync
().
Result
.
ToList
();
var
attachments
=
_
receivedSubmission
.
GetAttachmentsAsync
().
Result
.
ToList
();
attachments
.
Count
(
a
=>
a
.
Filename
==
"Test.pdf"
).
Should
().
Be
(
3
);
attachments
.
TrueForAll
(
a
=>
a
.
Description
?.
StartsWith
(
"Attachment #"
)
??
false
).
Should
()
.
BeTrue
();
...
...
@@ -203,37 +217,37 @@ public class ReplyChannelTest : EndToEndTestBase {
attachments
.
Single
(
attachment
=>
attachment
.
Filename
==
"JsonFileAttachment.json"
).
GetData
()
.
Should
().
BeEquivalentTo
(
"{\"message\":\"Hello World\"}"
);
receivedSubmission
.
SubmissionId
.
Should
().
Be
(
_submission
.
SubmissionId
);
receivedSubmission
.
CaseId
.
Should
().
Be
(
_submission
.
CaseId
);
receivedSubmission
.
GetDataMimeType
().
Should
()
_
receivedSubmission
.
SubmissionId
.
Should
().
Be
(
_submission
.
SubmissionId
);
_
receivedSubmission
.
CaseId
.
Should
().
Be
(
_submission
.
CaseId
);
_
receivedSubmission
.
GetDataMimeType
().
Should
()
.
Be
(
MediaTypeNames
.
Application
.
Json
);
receivedSubmission
.
Metadata
.
Should
().
NotBeNull
();
_
receivedSubmission
.
Metadata
.
Should
().
NotBeNull
();
var
authenticationInformation
=
receivedSubmission
.
Metadata
?.
AuthenticationInformation
?.
First
();
_
receivedSubmission
.
Metadata
?.
AuthenticationInformation
?.
First
();
authenticationInformation
.
Should
().
NotBeNull
();
authenticationInformation
!.
Type
.
Should
().
Be
(
AuthenticationInformationType
.
IdentificationReport
);
authenticationInformation
!.
Version
.
Should
().
Be
(
A
UTHENTICATION_VERSION
);
authenticationInformation
!.
Content
.
Should
().
Be
(
A
UTHENTICATION_CONTENT
);
authenticationInformation
!.
Version
.
Should
().
Be
(
A
uthenticationVersion
);
authenticationInformation
!.
Content
.
Should
().
Be
(
A
uthenticationContent
);
receivedSubmission
.
Metadata
?.
PaymentInformation
.
GrossAmount
.
Should
().
Be
(
G
ROSS_AMOUNT
);
receivedSubmission
.
Metadata
?.
PaymentInformation
.
TransactionId
.
Should
()
.
Be
(
T
RANSACTION_ID
);
receivedSubmission
.
Metadata
?.
PaymentInformation
.
PaymentMethod
.
Should
()
_
receivedSubmission
.
Metadata
?.
PaymentInformation
.
GrossAmount
.
Should
().
Be
(
G
rossAmount
);
_
receivedSubmission
.
Metadata
?.
PaymentInformation
.
TransactionId
.
Should
()
.
Be
(
T
ransactionId
);
_
receivedSubmission
.
Metadata
?.
PaymentInformation
.
PaymentMethod
.
Should
()
.
Be
(
PaymentMethod
.
Invoice
);
receivedSubmission
.
Metadata
?.
ReplyChannel
?.
EMail
?.
Address
.
Should
().
Be
(
R
EPLY_CHANNEL_EMAIL
);
_
receivedSubmission
.
Metadata
?.
ReplyChannel
?.
EMail
?.
Address
.
Should
().
Be
(
R
eplyChannelEmail
);
receivedSubmission
.
AcceptSubmissionAsync
().
Wait
();
_
receivedSubmission
.
AcceptSubmissionAsync
().
Wait
();
}
[
Test
]
[
Order
(
43
)]
public
void
T043_SendReply
()
{
var
replySubmission
=
SendableReply
.
From
(
receivedSubmission
)
var
replySubmission
=
SendableReply
.
From
(
_
receivedSubmission
)
.
SetJsonData
(
"{ \"replyData\" : \"Bitte Anhang xy nachreichen\"}"
,
new
Uri
(
"https://projects.eloware.dev/fit-connect/schemas/reply.schema.json"
))
.
AddAttachment
(
Attachment
.
FromPath
(
"Test.pdf"
,
"application/pdf"
,
description
:
"Attachment #1"
,
...
...
@@ -269,7 +283,6 @@ public class ReplyChannelTest : EndToEndTestBase {
Console
.
WriteLine
(
$"Found
{
replies
?.
Count
??
0
}
replies"
);
if
(
replies
==
null
)
return
;
foreach
(
var
reply
in
replies
)
Sender
.
RejectReplyAsync
(
reply
.
ReplyId
,
new
Problems
(
Problems
.
ProblemTypeEnum
.
ServiceMismatch
,
"Cleaning up reject"
)).
Wait
();
...
...
@@ -344,6 +357,7 @@ public class ReplyChannelTest : EndToEndTestBase {
[
Test
]
[
Order
(
63
)]
[
Ignore
(
"Was just used for debugging"
)]
public
void
T063_List_Cases
()
{
var
sender0Cases
=
ClientFactory
.
CreateSenderClient
(
_environment
,
_senderConfigs
[
0
].
ClientId
,
_senderConfigs
[
0
].
ClientSecret
,
...
...
@@ -405,15 +419,21 @@ public class ReplyChannelTest : EndToEndTestBase {
public
override
void
CleanServer
()
{
base
.
CleanServer
();
for
(
var
i
=
0
;
i
<
_senderConfigs
.
Length
;
i
++
)
{
for
each
(
var
senderConfig
in
_senderConfigs
)
{
var
senderClient
=
ClientFactory
.
CreateSenderClient
(
_environment
,
_
senderConfig
s
[
i
]
.
ClientId
,
_
senderConfig
s
[
i
]
.
ClientSecret
,
senderConfig
.
ClientId
,
senderConfig
.
ClientSecret
,
Logger
);
var
destinations
=
senderClient
.
GetCases
().
Result
.
Select
(
c
=>
c
.
DestinationId
).
Distinct
();
var
replies
=
senderClient
.
ListAvailableRepliesAsync
(
null
).
Result
?.
ToList
();
foreach
(
var
reply
in
replies
)
senderClient
.
RejectReplyAsync
(
reply
.
ReplyId
,
new
Problems
(
Problems
.
ProblemTypeEnum
.
ServiceMismatch
,
"Cleaning up reject"
)).
Wait
();
var
destinations
=
senderClient
.
GetCases
().
Result
.
Select
(
c
=>
c
.
DestinationId
).
Distinct
();
foreach
(
var
destinationId
in
destinations
)
{
Console
.
WriteLine
(
$"Server not cleaned for
{
destinationId
}
"
);
Console
.
WriteLine
(
$"Server not cleaned for Sender
{
senderConfig
.
ClientId
}
on destination
{
destinationId
}
but got
{
replies
.
Count
}
replies"
);
}
}
}
...
...
This diff is collapsed.
Click to expand it.
Tests/E2ETest/biDiKoSettings.json
+
17
−
5
View file @
5fdc910d
...
...
@@ -17,11 +17,23 @@
"callbackSecret"
:
""
}
],
"subscriber"
:
{
"clientId"
:
"db49abed-bb23-429c-976f-fa8382780ea4"
,
"clientSecret"
:
"5CUEwrmkEBsUwwOzFrHGczDI3lOtSCcpSJOK6Q338FI"
,
"callbackSecret"
:
""
},
"subscribers"
:
[
{
"clientId"
:
"db49abed-bb23-429c-976f-fa8382780ea4"
,
"clientSecret"
:
"5CUEwrmkEBsUwwOzFrHGczDI3lOtSCcpSJOK6Q338FI"
,
"callbackSecret"
:
""
},
{
"clientId"
:
"b43fdb1a-fa01-4955-93df-a70e4301fb1d"
,
"clientSecret"
:
"0-Zwrv3ptTwvUBpX-N-FwZSYHxPwrZ1AAfozBukKwEI"
,
"callbackSecret"
:
""
},
{
"clientId"
:
"20175c2b-c4dd-4a01-99b1-3a08436881a1"
,
"clientSecret"
:
"KV2qd7qc5n-xESB6dvfrTlMDx2BWHJd5hXJ6pKKnbEQ"
,
"callbackSecret"
:
""
}
],
"destination"
:
{
"id"
:
"57fe8bbe-67a6-433a-b9c6-7efaa5e8b8b7"
,
"serviceIdentifier"
:
"urn:de:fim:leika:leistung:99400048079000"
,
...
...
This diff is collapsed.
Click to expand it.
Tests/MockContainer/MockContainer.cs
+
1
−
2
View file @
5fdc910d
...
...
@@ -59,8 +59,7 @@ public static class Container {
return
builder
.
Build
();
}
private
static
Mock
<
IDestinationService
>
CreateDestinationService
(
IFitConnectSettings
settings
)
{
private
static
Mock
<
IDestinationService
>
CreateDestinationService
(
IFitConnectSettings
settings
)
{
var
mock
=
new
Mock
<
IDestinationService
>();
mock
.
Setup
(
x
=>
x
.
GetPublicKey
(
It
.
IsAny
<
Guid
>()))
...
...
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment