Skip to content

Commit

Permalink
Added ConfigValidatorUtilTest, Removed unused imports in UIDOperatorV…
Browse files Browse the repository at this point in the history
…erticleTest
  • Loading branch information
Behnam Mozafari committed Dec 18, 2024
1 parent 491025b commit 8018196
Show file tree
Hide file tree
Showing 2 changed files with 32 additions and 3 deletions.
3 changes: 0 additions & 3 deletions src/test/java/com/uid2/operator/UIDOperatorVerticleTest.java
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,6 @@
import com.uid2.operator.util.Tuple;
import com.uid2.operator.vertx.OperatorShutdownHandler;
import com.uid2.operator.vertx.UIDOperatorVerticle;
import com.uid2.operator.vertx.ClientInputValidationException;
import com.uid2.shared.Utils;
import com.uid2.shared.auth.ClientKey;
import com.uid2.shared.auth.Keyset;
Expand All @@ -27,9 +26,7 @@
import com.uid2.shared.secret.KeyHasher;
import com.uid2.shared.store.*;
import com.uid2.shared.store.reader.RotatingKeysetProvider;
import io.micrometer.core.instrument.Counter;
import io.micrometer.core.instrument.Metrics;
import io.micrometer.core.instrument.search.MeterNotFoundException;
import io.micrometer.core.instrument.simple.SimpleMeterRegistry;
import io.vertx.core.AsyncResult;
import io.vertx.core.Future;
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
package com.uid2.operator.service;

import org.junit.jupiter.api.Test;

import static org.junit.jupiter.api.Assertions.*;

public class ConfigValidatorUtilTest {
@Test
void testValidateIdentityRefreshTokens() {
// identityExpiresAfter is greater than refreshExpiresAfter
assertFalse(ConfigValidatorUtil.validateIdentityRefreshTokens(10, 5, 3));

// refreshIdentityAfter is greater than identityExpiresAfter
assertFalse(ConfigValidatorUtil.validateIdentityRefreshTokens(5, 10, 6));

// refreshIdentityAfter is greater than refreshExpiresAfter
assertFalse(ConfigValidatorUtil.validateIdentityRefreshTokens(5, 10, 11));

// all conditions are valid
assertTrue(ConfigValidatorUtil.validateIdentityRefreshTokens(5, 10, 3));
}

@Test
void testValidateBidstreamLifetime() {
// maxBidstreamLifetimeSeconds is less than identityTokenExpiresAfterSeconds
assertFalse(ConfigValidatorUtil.validateBidstreamLifetime(5, 10));

// maxBidstreamLifetimeSeconds is greater than or equal to identityTokenExpiresAfterSeconds
assertTrue(ConfigValidatorUtil.validateBidstreamLifetime(10, 5));
assertTrue(ConfigValidatorUtil.validateBidstreamLifetime(10, 10));
}
}

0 comments on commit 8018196

Please sign in to comment.