Search in sources :

Example 31 with RegistryPartner

use of org.jbei.ice.lib.dto.web.RegistryPartner in project ice by JBEI.

the class WebPartnersTest method createRemoteContact.

private RemoteContact createRemoteContact() {
    return new RemoteContact() {

        public RegistryPartner refreshPartnerKey(RegistryPartner partner, String url, String worToken) {
            TokenVerification tokenVerification = new TokenVerification();
            Assert.assertNotNull(tokenVerification.verifyPartnerToken(partner.getUrl(), worToken));
            return otherPartner.updateRemoteAPIKey(partner.getUrl(), partner);
        }

        public RegistryPartner contactPotentialPartner(RegistryPartner partner, String url) {
            AccessTokens.setToken(partner.getUrl(), partner.getApiKey());
            return otherPartner.processRemoteWebPartnerAdd(partner);
        }

        public boolean apiKeyValidates(String myURL, RegistryPartner registryPartner) {
            RegistryPartner partner = otherPartner.get(registryPartner.getApiKey(), registryPartner.getUrl());
            return partner != null;
        }
    };
}
Also used : RegistryPartner(org.jbei.ice.lib.dto.web.RegistryPartner) TokenVerification(org.jbei.ice.lib.access.TokenVerification)

Example 32 with RegistryPartner

use of org.jbei.ice.lib.dto.web.RegistryPartner in project ice by JBEI.

the class WebPartnersTest method setUp.

@Before
public void setUp() throws Exception {
    HibernateUtil.initializeMock();
    HibernateUtil.beginTransaction();
    thisPartner = createThisPartnerObject();
    RemoteContact remoteContact = new RemoteContact() {

        public RegistryPartner contactPotentialPartner(RegistryPartner partner, String url) {
            AccessTokens.setToken(url, partner.getApiKey());
            return thisPartner.processRemoteWebPartnerAdd(partner);
        }

        public boolean apiKeyValidates(String myURL, RegistryPartner registryPartner) {
            RegistryPartner partner = thisPartner.get(registryPartner.getApiKey(), registryPartner.getUrl());
            return partner != null;
        }
    };
    otherPartner = new WebPartners(remoteContact) {

        final String myURL = "registry-test20.jbei.org";

        protected boolean isInWebOfRegistries() {
            return true;
        }

        protected RegistryPartner getThisInstanceWithNewApiKey() {
            RegistryPartner thisPartner = new RegistryPartner();
            String myName = "Registry test2";
            thisPartner.setName(myName);
            thisPartner.setUrl(myURL);
            thisPartner.setApiKey("abc");
            return thisPartner;
        }

        protected String getThisUri() {
            return myURL;
        }
    };
}
Also used : RegistryPartner(org.jbei.ice.lib.dto.web.RegistryPartner) Before(org.junit.Before)

Example 33 with RegistryPartner

use of org.jbei.ice.lib.dto.web.RegistryPartner in project ice by JBEI.

the class WebPartnersTest method testUpdateAPIKey.

@Test
public void testUpdateAPIKey() throws Exception {
    Account admin = AccountCreator.createTestAccount("WebPartnersTest.testUpdateAPIKey", true);
    String adminUser = admin.getEmail();
    // add reg-test2 as new partner
    RegistryPartner partner = new RegistryPartner();
    partner.setUrl("registry-test20.jbei.org");
    WebPartners webPartners = createThisPartnerObject();
    RegistryPartner added = webPartners.addNewPartner(adminUser, partner);
    Assert.assertNotNull(added);
    Assert.assertEquals(added.getStatus(), RemotePartnerStatus.APPROVED);
    String apiKey = partner.getApiKey();
    Assert.assertNotNull(apiKey);
    // update api keys with new partner
    RegistryPartner partner2 = webPartners.updateAPIKey(adminUser, added.getId());
    Assert.assertNotNull(partner2);
}
Also used : Account(org.jbei.ice.storage.model.Account) RegistryPartner(org.jbei.ice.lib.dto.web.RegistryPartner) Test(org.junit.Test)

Aggregations

RegistryPartner (org.jbei.ice.lib.dto.web.RegistryPartner)33 RemotePartner (org.jbei.ice.storage.model.RemotePartner)11 PermissionException (org.jbei.ice.lib.access.PermissionException)6 AccountTransfer (org.jbei.ice.lib.account.AccountTransfer)3 Account (org.jbei.ice.storage.model.Account)3 ArrayList (java.util.ArrayList)2 RemoteUser (org.jbei.ice.lib.dto.web.RemoteUser)2 Test (org.junit.Test)2 HashMap (java.util.HashMap)1 LinkedList (java.util.LinkedList)1 Consumes (javax.ws.rs.Consumes)1 POST (javax.ws.rs.POST)1 Path (javax.ws.rs.Path)1 Produces (javax.ws.rs.Produces)1 WebApplicationException (javax.ws.rs.WebApplicationException)1 RemoteAccess (org.jbei.ice.lib.access.RemoteAccess)1 TokenVerification (org.jbei.ice.lib.access.TokenVerification)1 AccountController (org.jbei.ice.lib.account.AccountController)1 FeaturedDNASequence (org.jbei.ice.lib.dto.FeaturedDNASequence)1 AccessPermission (org.jbei.ice.lib.dto.access.AccessPermission)1