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;
}
};
}
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;
}
};
}
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);
}
Aggregations