Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
FIT-Connect-SDK - Java
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 - Java
Commits
03a7c320
Commit
03a7c320
authored
4 months ago
by
Martin Vogel
Browse files
Options
Downloads
Patches
Plain Diff
test: add e2e tests for key update (
planning#2209
)
parent
a1c7fba3
No related branches found
No related tags found
1 merge request
!436
planning#2267: Destination API Client
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
integration-tests/src/test/java/dev/fitko/fitconnect/integrationtests/DestinationClientIT.java
+74
-1
74 additions, 1 deletion
...itko/fitconnect/integrationtests/DestinationClientIT.java
with
74 additions
and
1 deletion
integration-tests/src/test/java/dev/fitko/fitconnect/integrationtests/DestinationClientIT.java
+
74
−
1
View file @
03a7c320
...
...
@@ -5,8 +5,11 @@ import dev.fitko.fitconnect.api.domain.model.destination.ContactInformation;
import
dev.fitko.fitconnect.api.domain.model.destination.CreateDestination
;
import
dev.fitko.fitconnect.api.domain.model.destination.Destination
;
import
dev.fitko.fitconnect.api.domain.model.destination.DestinationService
;
import
dev.fitko.fitconnect.api.domain.model.destination.Destinations
;
import
dev.fitko.fitconnect.api.domain.model.destination.StatusEnum
;
import
dev.fitko.fitconnect.api.domain.model.jwk.ApiJwk
;
import
dev.fitko.fitconnect.api.domain.model.jwk.ApiJwks
;
import
dev.fitko.fitconnect.api.domain.model.jwk.KeyOpsEnum
;
import
dev.fitko.fitconnect.api.domain.model.metadata.data.MimeType
;
import
dev.fitko.fitconnect.api.domain.model.metadata.data.SubmissionSchema
;
import
dev.fitko.fitconnect.client.DestinationClient
;
...
...
@@ -17,13 +20,18 @@ import org.junit.jupiter.api.BeforeEach;
import
org.junit.jupiter.api.Test
;
import
java.net.URI
;
import
java.util.List
;
import
java.util.Set
;
import
java.util.UUID
;
import
java.util.stream.Collectors
;
import
static
org
.
hamcrest
.
MatcherAssert
.
assertThat
;
import
static
org
.
hamcrest
.
Matchers
.
empty
;
import
static
org
.
hamcrest
.
Matchers
.
hasSize
;
import
static
org
.
hamcrest
.
Matchers
.
is
;
import
static
org
.
hamcrest
.
Matchers
.
isEmptyOrNullString
;
import
static
org
.
junit
.
jupiter
.
api
.
Assertions
.
assertNotNull
;
import
static
org
.
junit
.
jupiter
.
api
.
Assertions
.
assertTrue
;
@EnableIfEnvironmentVariablesAreSet
public
class
DestinationClientIT
extends
IntegrationTestBase
{
...
...
@@ -65,7 +73,6 @@ public class DestinationClientIT extends IntegrationTestBase {
.
name
(
"Incomplete Draft Destination"
)
.
status
(
StatusEnum
.
DRAFT
)
.
build
();
;
// When
final
Destination
incompleteDestination
=
destinationClient
.
createDestination
(
createDestination
);
...
...
@@ -121,6 +128,72 @@ public class DestinationClientIT extends IntegrationTestBase {
assertThat
(
draftDestination
.
getEncryptionKid
(),
is
(
updatedDestination
.
getEncryptionKid
()));
}
@Test
public
void
testListDestinations
()
{
// Given
final
Destinations
availableDestinations
=
destinationClient
.
listDestinations
(
0
,
10
);
// When
final
List
<
Destination
>
destinations
=
availableDestinations
.
getDestinations
().
stream
()
.
map
(
Destination:
:
getDestinationId
)
.
map
(
destinationClient:
:
getDestination
)
.
collect
(
Collectors
.
toList
());
// Then
assertNotNull
(
destinations
);
assertThat
(
destinations
,
hasSize
(
availableDestinations
.
getCount
()));
}
@Test
public
void
testListKeysForDestination
()
{
// Given
var
destinationId
=
UUID
.
fromString
(
System
.
getenv
(
"TEST_DESTINATION_ID"
));
// When
final
ApiJwks
publicKeys
=
destinationClient
.
getKeysForDestination
(
destinationId
,
0
,
10
);
// Then
assertNotNull
(
publicKeys
);
assertTrue
(
publicKeys
.
getKeys
().
stream
().
flatMap
(
apiJwk
->
apiJwk
.
getKeyOps
().
stream
()).
anyMatch
(
k
->
k
.
equals
(
KeyOpsEnum
.
WRAPKEY
)));
assertTrue
(
publicKeys
.
getKeys
().
stream
().
flatMap
(
apiJwk
->
apiJwk
.
getKeyOps
().
stream
()).
anyMatch
(
k
->
k
.
equals
(
KeyOpsEnum
.
VERIFY
)));
}
@Test
public
void
testGetSingleKeyForDestination
()
{
// Given
var
destinationId
=
UUID
.
fromString
(
System
.
getenv
(
"TEST_DESTINATION_ID"
));
final
ApiJwk
expectedKey
=
destinationClient
.
getKeysForDestination
(
destinationId
,
0
,
1
).
getKeys
().
iterator
().
next
();
// When
final
ApiJwk
publicKey
=
destinationClient
.
getKeyForDestination
(
destinationId
,
expectedKey
.
getKid
());
// Then
assertNotNull
(
publicKey
);
assertThat
(
publicKey
,
is
(
expectedKey
));
}
@Test
public
void
testAddKeyForDestination
()
{
// Given
var
destinationId
=
UUID
.
fromString
(
System
.
getenv
(
"TEST_DESTINATION_ID"
));
var
publicEncryptionKey
=
TestKeyBuilder
.
generateEncryptionKeyPair
().
getPublicApiJwk
();
var
keyCountBeforeUpdate
=
destinationClient
.
getKeysForDestination
(
destinationId
,
0
,
500
).
getKeys
().
size
();
// When
destinationClient
.
addKeyToDestination
(
destinationId
,
publicEncryptionKey
);
Set
<
ApiJwk
>
updatedKeys
=
destinationClient
.
getKeysForDestination
(
destinationId
,
0
,
500
).
getKeys
();
// Then
assertNotNull
(
updatedKeys
);
assertThat
(
updatedKeys
.
size
(),
is
(
keyCountBeforeUpdate
+
1
));
assertTrue
(
updatedKeys
.
stream
().
anyMatch
(
k
->
k
.
getKid
().
equals
(
publicEncryptionKey
.
getKid
())));
}
private
static
CreateDestination
createNewTestDestination
()
{
final
ApiJwk
publicEncryptionKey
=
TestKeyBuilder
.
generateEncryptionKeyPair
().
getPublicApiJwk
();
...
...
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