Skip to content

Commit

Permalink
Add test. Fix URL for containers with whitespace.
Browse files Browse the repository at this point in the history
Former-commit-id: 827b09af1dbf30d59bec619fa59aa347714208e4
  • Loading branch information
dkocher committed Oct 24, 2013
1 parent dea1a89 commit 40d0be1
Show file tree
Hide file tree
Showing 2 changed files with 21 additions and 1 deletion.
2 changes: 1 addition & 1 deletion source/ch/cyberduck/core/openstack/SwiftUrlProvider.java
Expand Up @@ -102,7 +102,7 @@ public DescriptiveUrlBag toUrl(final Path file) {

protected DescriptiveUrl createTempUrl(final Region region, final Path file, final int seconds) {
final String path = region.getStorageUrl(
containerService.getContainer(file).getName(), containerService.getKey(file)).getPath();
containerService.getContainer(file).getName(), containerService.getKey(file)).getRawPath();
final Calendar expiry = Calendar.getInstance(TimeZone.getTimeZone("UTC"));
expiry.add(Calendar.SECOND, seconds);
final String signature;
Expand Down
20 changes: 20 additions & 0 deletions test/ch/cyberduck/core/openstack/SwiftUrlProviderTest.java
Expand Up @@ -31,9 +31,15 @@

import org.junit.Test;

import java.net.URI;
import java.util.Collections;
import java.util.HashMap;
import java.util.Map;
import java.util.UUID;

import ch.iterate.openstack.swift.model.AccountInfo;
import ch.iterate.openstack.swift.model.Region;

import static org.junit.Assert.*;

/**
Expand Down Expand Up @@ -107,4 +113,18 @@ public void testSignedRax() throws Exception {
}
session.close();
}

@Test
public void testTempUrl() throws Exception {
final SwiftSession session = new SwiftSession(new Host(new SwiftProtocol(), "identity.api.rackspacecloud.com",
new Credentials(properties.getProperty("rackspace.key"), properties.getProperty("rackspace.secret"))
));
final Region region = new Region("DFW", URI.create("http://s"), URI.create("http://m"));
Map accounts = new HashMap();
accounts.put(region, new AccountInfo(1L, 1, "k"));
final Path container = new Path("test w.cyberduck.ch", Path.VOLUME_TYPE);
final Path file = new Path(container, UUID.randomUUID().toString(), Path.FILE_TYPE);
assertNotEquals(DescriptiveUrl.EMPTY, new SwiftUrlProvider(session, accounts).createTempUrl(region,
file, 300));
}
}

0 comments on commit 40d0be1

Please sign in to comment.