Skip to content

Commit

Permalink
TempURL fixed according to commit in:
Browse files Browse the repository at this point in the history
  • Loading branch information
Thomas Ritscher committed Jan 8, 2018
1 parent 02430c6 commit 991cea5
Show file tree
Hide file tree
Showing 2 changed files with 75 additions and 73 deletions.
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());
}
}

0 comments on commit 991cea5

Please sign in to comment.