Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

TempURL fixed #146

Merged
merged 1 commit into from
Jan 15, 2018
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
@@ -1,46 +1,48 @@
package org.javaswift.joss.command.shared.identity.access;

import org.javaswift.joss.client.factory.TempUrlHashPrefixSource;
import org.javaswift.joss.model.Access;

public class AccessBasic implements Access {

private String url;
private String token;

public void setUrl(final String url) {
this.url = url;
}

public void setToken(final String token) {
this.token = token;
}

@Override
public void setPreferredRegion(String preferredRegion) {}

@Override
public String getToken() {
return token;
}

@Override
public String getInternalURL() {
return url;
}

@Override
public String getPublicURL() {
return url;
}

@Override
public boolean isTenantSupplied() {
return true;
}

@Override
public String getTempUrlPrefix(TempUrlHashPrefixSource tempUrlHashPrefixSource) {
return url.endsWith("/") ? url.substring(0, url.length()-1) : url;
}
}
package org.javaswift.joss.command.shared.identity.access;

import org.javaswift.joss.client.factory.TempUrlHashPrefixSource;
import org.javaswift.joss.model.Access;

public class AccessBasic implements Access {

private String url;
private String token;

public void setUrl(final String url) {
this.url = url;
}

public void setToken(final String token) {
this.token = token;
}

@Override
public void setPreferredRegion(String preferredRegion) {
}

@Override
public String getToken() {
return token;
}

@Override
public String getInternalURL() {
return url;
}

@Override
public String getPublicURL() {
return url;
}

@Override
public boolean isTenantSupplied() {
return true;
}

@Override
public String getTempUrlPrefix(TempUrlHashPrefixSource tempUrlHashPrefixSource) {
String tempUrl = TempUrlHashPrefixSource.getPath(url);
return tempUrl.endsWith("/") ? tempUrl.substring(0, tempUrl.length() - 1) : tempUrl;
}
}
Original file line number Diff line number Diff line change
@@ -1,27 +1,27 @@
package org.javaswift.joss.command.shared.identity.access;

import org.junit.Test;

import static junit.framework.Assert.assertTrue;
import static org.junit.Assert.assertEquals;

public class AccessBasicTest {

@Test
public void settersAndGetters() {
String url = "http://www.abc.nl/";
String urlNoSlashAtEnd = "http://www.abc.nl";
String token = "cafebabe";
AccessBasic access = new AccessBasic();
access.setUrl(url);
assertEquals(url, access.getInternalURL());
assertEquals(url, access.getPublicURL());
access.setToken(token);
assertEquals(token, access.getToken());
access.setPreferredRegion(null); // does nothing
assertEquals(urlNoSlashAtEnd, access.getTempUrlPrefix(null));
access.setUrl(urlNoSlashAtEnd);
assertEquals(urlNoSlashAtEnd, access.getTempUrlPrefix(null));
assertTrue(access.isTenantSupplied());
}
}
package org.javaswift.joss.command.shared.identity.access;
import static junit.framework.Assert.assertTrue;
import static org.junit.Assert.assertEquals;
import org.junit.Test;
public class AccessBasicTest {
@Test
public void settersAndGetters() {
String url = "http://www.abc.nl/path/";
String pathNoSlashAtEnd = "/path";
String token = "cafebabe";
AccessBasic access = new AccessBasic();
access.setUrl(url);
assertEquals(url, access.getInternalURL());
assertEquals(url, access.getPublicURL());
access.setToken(token);
assertEquals(token, access.getToken());
access.setPreferredRegion(null); // does nothing
assertEquals(pathNoSlashAtEnd, access.getTempUrlPrefix(null));
access.setUrl(url.substring(0, url.length() - 1));
assertEquals(pathNoSlashAtEnd, access.getTempUrlPrefix(null));
assertTrue(access.isTenantSupplied());
}
}