Add callback for delete operation.
[cyberduck.git] / test / ch / cyberduck / core / openstack / SwiftHpUrlProviderTest.java
blobdbed2f7fcee8b6fd27a48a6cc6a2c063976388c8
1 package ch.cyberduck.core.openstack;
3 /*
4 * Copyright (c) 2002-2013 David Kocher. All rights reserved.
5 * http://cyberduck.ch/
7 * This program is free software; you can redistribute it and/or modify
8 * it under the terms of the GNU General Public License as published by
9 * the Free Software Foundation; either version 2 of the License, or
10 * (at your option) any later version.
12 * This program is distributed in the hope that it will be useful,
13 * but WITHOUT ANY WARRANTY; without even the implied warranty of
14 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
15 * GNU General Public License for more details.
17 * Bug fixes, suggestions and comments should be sent to feedback@cyberduck.ch
20 import ch.cyberduck.core.AbstractTestCase;
21 import ch.cyberduck.core.Credentials;
22 import ch.cyberduck.core.DescriptiveUrl;
23 import ch.cyberduck.core.DisabledPasswordStore;
24 import ch.cyberduck.core.Host;
25 import ch.cyberduck.core.Path;
26 import ch.cyberduck.core.Scheme;
28 import org.junit.Test;
30 import java.net.URI;
31 import java.util.EnumSet;
32 import java.util.Iterator;
34 import ch.iterate.openstack.swift.model.Region;
36 import static org.junit.Assert.assertEquals;
38 /**
39 * @version $Id$
41 public class SwiftHpUrlProviderTest extends AbstractTestCase {
43 @Test
44 public void testSigned() throws Exception {
45 final SwiftProtocol protocol = new SwiftProtocol() {
46 @Override
47 public String getContext() {
48 return "/v2.0/tokens";
51 final Host host = new Host(protocol, "region-a.geo-1.identity.hpcloudsvc.com", 35357, new Credentials(
52 properties.getProperty("hpcloud.key"), properties.getProperty("hpcloud.secret")
53 ));
54 final SwiftSession session = new SwiftSession(host);
55 final Path container = new Path("test.cyberduck.ch", EnumSet.of(Path.Type.directory, Path.Type.volume));
56 final Path file = new Path(container, "a", EnumSet.of(Path.Type.file));
57 final SwiftHpUrlProvider provider = new SwiftHpUrlProvider(session, new DisabledPasswordStore() {
58 @Override
59 public String getPassword(final Scheme scheme, final int port, final String hostname, final String user) {
60 return properties.getProperty("hpcloud.secret");
62 });
63 final Iterator<DescriptiveUrl> iterator = provider.sign(new Region("region-a.geo-1", URI.create("https://region-a.geo-1.objects.hpcloudsvc.com/v1/88650632417788"), null),
64 file, 1379500716).iterator();
65 assertEquals("http://region-a.geo-1.objects.hpcloudsvc.com/v1/88650632417788/test.cyberduck.ch/a?temp_url_sig=88650632417788:5C84TLCPJJ5FSSG6EDML:c4ff78486459b66d2ce45f8a3a51061e318f233a&temp_url_expires=1379500716",
66 iterator.next().getUrl());
67 assertEquals("https://region-a.geo-1.objects.hpcloudsvc.com/v1/88650632417788/test.cyberduck.ch/a?temp_url_sig=88650632417788:5C84TLCPJJ5FSSG6EDML:c4ff78486459b66d2ce45f8a3a51061e318f233a&temp_url_expires=1379500716",
68 iterator.next().getUrl());