Skip to content

Commit

Permalink
fix: add test
Browse files Browse the repository at this point in the history
  • Loading branch information
mustafasalfiti committed Mar 19, 2024
1 parent 2224f6e commit 012a2c4
Showing 1 changed file with 47 additions and 0 deletions.
Original file line number Diff line number Diff line change
@@ -0,0 +1,47 @@
package org.eclipse.tractusx.ssi.lib.serialization.jwt;

import static org.junit.Assert.assertNotNull;

import com.nimbusds.jwt.SignedJWT;
import java.util.LinkedHashMap;
import org.eclipse.tractusx.ssi.lib.SsiLibrary;
import org.eclipse.tractusx.ssi.lib.crypt.octet.OctetKeyPairFactory;
import org.eclipse.tractusx.ssi.lib.jwt.SignedJwtFactory;
import org.eclipse.tractusx.ssi.lib.util.identity.TestIdentity;
import org.eclipse.tractusx.ssi.lib.util.identity.TestIdentityFactory;
import org.junit.jupiter.api.BeforeAll;
import org.junit.jupiter.api.DisplayName;
import org.junit.jupiter.api.Test;

public class SignedJwtFactoryTest {

private static TestIdentity credentialIssuer;

@BeforeAll
public static void beforeAll() {
SsiLibrary.initialize();
credentialIssuer = TestIdentityFactory.newIdentityWithED25519Keys();
}

@Test
@DisplayName(
"Should return a signed Jwt with the given Map of claims and the given private key.")
void shouldReturnSignedJWT() {

LinkedHashMap<String, Object> claims = new LinkedHashMap<>();
SignedJwtFactory signedJwtFactory = new SignedJwtFactory(new OctetKeyPairFactory());
String keyId = "key-1";
// When

SignedJWT signedJWT =
signedJwtFactory.create(
credentialIssuer.getDid(),
credentialIssuer.getDid(),
claims,
credentialIssuer.getPrivateKey(),
keyId);

// Then
assertNotNull(signedJWT);
}
}

0 comments on commit 012a2c4

Please sign in to comment.