use of org.eclipse.userstorage.IStorageService in project epp.mpc by eclipse.
the class MarketplaceStorageService method getStorageCredentials.
private Credentials getStorageCredentials() {
ICredentialsProvider provider = getStorage().getCredentialsProvider();
if (provider == null) {
return null;
}
IStorageService service = getStorage().getService();
return provider.hasCredentials(service) ? provider.getCredentials(service) : null;
}
use of org.eclipse.userstorage.IStorageService in project epp.mpc by eclipse.
the class MarketplaceStorageServiceRegistrationTest method testCleanupDuplicateStorageService.
@Test
public void testCleanupDuplicateStorageService() throws Exception {
IStorageService withSlash = storageServices.provide("WithSlash", "https://api-test.example.org/");
IStorageService withoutSlash = storageServices.provide("WithoutSlash", "https://api-test.example.org");
((StorageService) withSlash).getSecurePreferences().remove("username");
((StorageService) withoutSlash).getSecurePreferences().put("username", "testuser", false);
IMarketplaceStorageService registered = serviceLocator.registerStorageService(DefaultMarketplaceService.DEFAULT_SERVICE_LOCATION, "https://api-test.example.org", null);
assertNotNull(registered);
assertEquals("https://api-test.example.org/", registered.getServiceUri().toString());
assertSame(withSlash, registered.getStorage().getService());
withoutSlash = IStorageService.Registry.INSTANCE.getService(URI.create("https://api-test.example.org"));
assertNull(withoutSlash);
String username = ((StorageService) withSlash).getSecurePreferences().get("username", null);
assertEquals("testuser", username);
}
use of org.eclipse.userstorage.IStorageService in project epp.mpc by eclipse.
the class MarketplaceStorageServiceRegistrationTest method testCleanupDuplicateEclipseOrgStorageService.
@Test
public void testCleanupDuplicateEclipseOrgStorageService() throws Exception {
IStorageService withSlash = storageServices.provide("WithSlash", "https://api.eclipse.org/");
assertFalse(withSlash instanceof IStorageService.Dynamic);
IStorageService withoutSlash = storageServices.provide("WithoutSlash", "https://api.eclipse.org");
assertTrue(withoutSlash instanceof IStorageService.Dynamic);
IMarketplaceStorageService registered = serviceLocator.registerStorageService(DefaultMarketplaceService.DEFAULT_SERVICE_LOCATION, "https://api.eclipse.org/", null);
assertNotNull(registered);
assertSame(withSlash, registered.getStorage().getService());
withoutSlash = IStorageService.Registry.INSTANCE.getService(URI.create("https://api.eclipse.org"));
assertNull(withoutSlash);
}
use of org.eclipse.userstorage.IStorageService in project epp.mpc by eclipse.
the class MarketplaceStorageServiceRegistrationTest method testRegisterNewStorageServiceWithoutSlash.
@Test
public void testRegisterNewStorageServiceWithoutSlash() {
IMarketplaceStorageService registered = serviceLocator.registerStorageService(DefaultMarketplaceService.DEFAULT_SERVICE_LOCATION, "https://api-test.example.org", null);
assertNotNull(registered);
assertEquals("https://api-test.example.org/", registered.getServiceUri().toString());
IStorageService withoutSlash = IStorageService.Registry.INSTANCE.getService(URI.create("https://api-test.example.org"));
assertNull(withoutSlash);
}
use of org.eclipse.userstorage.IStorageService in project epp.mpc by eclipse.
the class UserFavoritesServiceTest method setUp.
@Before
public void setUp() throws Exception {
marketplaceStorageService = ServiceHelper.getMarketplaceServiceLocator().getDefaultStorageService();
assertNotNull(marketplaceStorageService);
assertEquals(USERSTORAGE_SERVICE_URI, marketplaceStorageService.getServiceUri());
marketplaceStorageService.getStorage().setCredentialsProvider(new AbstractCredentialsProvider() {
@Override
public Credentials provideCredentials(IStorageService service, boolean reauthentication) {
String marketplaceUser;
String marketplacePass;
try {
marketplaceUser = TestProperties.getTestProperty("mpc.storage.user");
marketplacePass = TestProperties.getTestProperty("mpc.storage.pass");
} catch (IOException e) {
throw new AssertionError("Cannot load test properties", e);
}
Assume.assumeNotNull(marketplaceUser, marketplacePass);
return new Credentials(marketplaceUser, marketplacePass);
}
});
favoritesService = ServiceHelper.getMarketplaceServiceLocator().getDefaultFavoritesService();
// assertNotNull(favoritesService);
if (favoritesService == null) {
((ServiceLocator) ServiceHelper.getMarketplaceServiceLocator()).registerFavoritesService(DefaultMarketplaceService.DEFAULT_SERVICE_LOCATION, marketplaceStorageService.getServiceUri().toString(), null);
favoritesService = ServiceHelper.getMarketplaceServiceLocator().getDefaultFavoritesService();
}
assertSame(marketplaceStorageService, favoritesService.getStorageService());
}
Aggregations