Search in sources :

Example 1 with AuthHandlerBoot

use of org.apache.servicecomb.AuthHandlerBoot in project java-chassis by ServiceComb.

the class TestAuthHandlerBoot method testMicroserviceInstancePublicKey.

@Test
public void testMicroserviceInstancePublicKey() {
    AuthHandlerBoot authHandlerBoot = new AuthHandlerBoot();
    BootEvent bootEvent = new BootEvent();
    bootEvent.setEventType(BootListener.EventType.BEFORE_REGISTRY);
    authHandlerBoot.onBootEvent(bootEvent);
    String publicKey = RegistrationManager.INSTANCE.getMicroserviceInstance().getProperties().get(DefinitionConst.INSTANCE_PUBKEY_PRO);
    Assert.assertNotNull(publicKey);
}
Also used : AuthHandlerBoot(org.apache.servicecomb.AuthHandlerBoot) BootEvent(org.apache.servicecomb.core.BootListener.BootEvent) Test(org.junit.Test)

Example 2 with AuthHandlerBoot

use of org.apache.servicecomb.AuthHandlerBoot in project incubator-servicecomb-java-chassis by apache.

the class TestAuthHandlerBoot method testGenerateRSAKey.

@Test
public void testGenerateRSAKey() {
    MicroserviceInstance microserviceInstance = new MicroserviceInstance();
    Microservice microservice = new Microservice();
    microservice.setInstance(microserviceInstance);
    new Expectations(RegistryUtils.class) {

        {
            RegistryUtils.getMicroserviceInstance();
            result = microserviceInstance;
        }
    };
    AuthHandlerBoot authHandlerBoot = new AuthHandlerBoot();
    BootEvent bootEvent = new BootEvent();
    bootEvent.setEventType(BootListener.EventType.BEFORE_REGISTRY);
    authHandlerBoot.onBootEvent(bootEvent);
    Assert.assertNotNull(RSAKeypair4Auth.INSTANCE.getPrivateKey());
    Assert.assertNotNull(RSAKeypair4Auth.INSTANCE.getPublicKey());
}
Also used : Expectations(mockit.Expectations) Microservice(org.apache.servicecomb.serviceregistry.api.registry.Microservice) AuthHandlerBoot(org.apache.servicecomb.AuthHandlerBoot) BootEvent(org.apache.servicecomb.core.BootListener.BootEvent) MicroserviceInstance(org.apache.servicecomb.serviceregistry.api.registry.MicroserviceInstance) Test(org.junit.Test)

Example 3 with AuthHandlerBoot

use of org.apache.servicecomb.AuthHandlerBoot in project java-chassis by ServiceComb.

the class TestAuthHandlerBoot method testGenerateRSAKey.

@Test
public void testGenerateRSAKey() {
    MicroserviceInstance microserviceInstance = new MicroserviceInstance();
    Microservice microservice = new Microservice();
    microservice.setInstance(microserviceInstance);
    AuthHandlerBoot authHandlerBoot = new AuthHandlerBoot();
    BootEvent bootEvent = new BootEvent();
    bootEvent.setEventType(BootListener.EventType.BEFORE_REGISTRY);
    authHandlerBoot.onBootEvent(bootEvent);
    Assert.assertNotNull(RSAKeypair4Auth.INSTANCE.getPrivateKey());
    Assert.assertNotNull(RSAKeypair4Auth.INSTANCE.getPublicKey());
}
Also used : Microservice(org.apache.servicecomb.registry.api.registry.Microservice) AuthHandlerBoot(org.apache.servicecomb.AuthHandlerBoot) BootEvent(org.apache.servicecomb.core.BootListener.BootEvent) MicroserviceInstance(org.apache.servicecomb.registry.api.registry.MicroserviceInstance) Test(org.junit.Test)

Aggregations

AuthHandlerBoot (org.apache.servicecomb.AuthHandlerBoot)3 BootEvent (org.apache.servicecomb.core.BootListener.BootEvent)3 Test (org.junit.Test)3 Expectations (mockit.Expectations)1 Microservice (org.apache.servicecomb.registry.api.registry.Microservice)1 MicroserviceInstance (org.apache.servicecomb.registry.api.registry.MicroserviceInstance)1 Microservice (org.apache.servicecomb.serviceregistry.api.registry.Microservice)1 MicroserviceInstance (org.apache.servicecomb.serviceregistry.api.registry.MicroserviceInstance)1