Search in sources :

Example 6 with ApiKeyValidatorFilter

use of org.ff4j.web.api.filter.ApiKeyValidatorFilter in project ff4j by ff4j.

the class ApiKeyValidatorFilterTest method testApiKeyValidaton.

@Test
public void testApiKeyValidaton() throws Exception {
    Map<String, ApiKey> initMap = new HashMap<>();
    ApiKey ak1 = new ApiKey();
    ak1.setUserId("user1");
    ak1.setValue("key1");
    ak1.setExpirationTime(new Date(System.currentTimeMillis() + 20000));
    initMap.put(ak1.getValue(), ak1);
    new ApiKeyValidatorFilter(initMap);
    Assert.assertTrue(ApiKeyValidatorFilter.getValidApiKeysMap().containsKey("key1"));
    ApiKeyValidatorFilter.setValidApiKeysMap(initMap);
}
Also used : ApiKey(org.ff4j.web.api.filter.ApiKey) HashMap(java.util.HashMap) MultivaluedHashMap(javax.ws.rs.core.MultivaluedHashMap) ApiKeyValidatorFilter(org.ff4j.web.api.filter.ApiKeyValidatorFilter) Date(java.util.Date) Test(org.junit.Test)

Aggregations

MultivaluedHashMap (javax.ws.rs.core.MultivaluedHashMap)6 ApiKeyValidatorFilter (org.ff4j.web.api.filter.ApiKeyValidatorFilter)6 Test (org.junit.Test)6 ContainerRequestContext (javax.ws.rs.container.ContainerRequestContext)5 Date (java.util.Date)4 HashMap (java.util.HashMap)4 ApiKey (org.ff4j.web.api.filter.ApiKey)4