Search in sources :

Example 1 with ZmsKeystore

use of com.yahoo.vespa.hosted.controller.api.integration.athenz.ZmsKeystore in project vespa by vespa-engine.

the class NTokenValidatorTest method failing_to_find_key_should_throw_exception.

@Test
public void failing_to_find_key_should_throw_exception() throws InvalidTokenException {
    ZmsKeystore keystore = (athensService, keyId) -> {
        throw new RuntimeException();
    };
    NTokenValidator validator = new NTokenValidator(keystore);
    NToken token = createNToken(IDENTITY, Instant.now(), TRUSTED_KEY.getPrivate(), "0");
    exceptionRule.expect(InvalidTokenException.class);
    exceptionRule.expectMessage("Failed to retrieve public key");
    validator.validate(token);
}
Also used : KeyPair(java.security.KeyPair) InvalidTokenException(com.yahoo.vespa.hosted.controller.api.integration.athenz.InvalidTokenException) AthenzUser(com.yahoo.vespa.athenz.api.AthenzUser) AthenzIdentity(com.yahoo.vespa.athenz.api.AthenzIdentity) Test(org.junit.Test) PrincipalToken(com.yahoo.athenz.auth.token.PrincipalToken) Instant(java.time.Instant) NToken(com.yahoo.vespa.athenz.api.NToken) ZmsKeystore(com.yahoo.vespa.hosted.controller.api.integration.athenz.ZmsKeystore) ZMS_ATHENZ_SERVICE(com.yahoo.vespa.athenz.utils.AthenzIdentities.ZMS_ATHENZ_SERVICE) Rule(org.junit.Rule) AthenzPrincipal(com.yahoo.vespa.athenz.api.AthenzPrincipal) PrivateKey(java.security.PrivateKey) NoSuchAlgorithmException(java.security.NoSuchAlgorithmException) Optional(java.util.Optional) ExpectedException(org.junit.rules.ExpectedException) Assert.assertEquals(org.junit.Assert.assertEquals) NToken(com.yahoo.vespa.athenz.api.NToken) ZmsKeystore(com.yahoo.vespa.hosted.controller.api.integration.athenz.ZmsKeystore) Test(org.junit.Test)

Aggregations

PrincipalToken (com.yahoo.athenz.auth.token.PrincipalToken)1 AthenzIdentity (com.yahoo.vespa.athenz.api.AthenzIdentity)1 AthenzPrincipal (com.yahoo.vespa.athenz.api.AthenzPrincipal)1 AthenzUser (com.yahoo.vespa.athenz.api.AthenzUser)1 NToken (com.yahoo.vespa.athenz.api.NToken)1 ZMS_ATHENZ_SERVICE (com.yahoo.vespa.athenz.utils.AthenzIdentities.ZMS_ATHENZ_SERVICE)1 InvalidTokenException (com.yahoo.vespa.hosted.controller.api.integration.athenz.InvalidTokenException)1 ZmsKeystore (com.yahoo.vespa.hosted.controller.api.integration.athenz.ZmsKeystore)1 KeyPair (java.security.KeyPair)1 NoSuchAlgorithmException (java.security.NoSuchAlgorithmException)1 PrivateKey (java.security.PrivateKey)1 Instant (java.time.Instant)1 Optional (java.util.Optional)1 Assert.assertEquals (org.junit.Assert.assertEquals)1 Rule (org.junit.Rule)1 Test (org.junit.Test)1 ExpectedException (org.junit.rules.ExpectedException)1