From 991cea513367b3974b1c398a8aaf05ffec9436ef Mon Sep 17 00:00:00 2001 From: Thomas Ritscher Date: Mon, 8 Jan 2018 14:01:44 +0100 Subject: [PATCH] TempURL fixed according to commit in: https://github.com/javaswift/joss/pull/90/commits/105f70c8d4a3409b5de3504ba3eb07444f8b607c --- .../shared/identity/access/AccessBasic.java | 94 ++++++++++--------- .../identity/access/AccessBasicTest.java | 54 +++++------ 2 files changed, 75 insertions(+), 73 deletions(-) diff --git a/src/main/java/org/javaswift/joss/command/shared/identity/access/AccessBasic.java b/src/main/java/org/javaswift/joss/command/shared/identity/access/AccessBasic.java index 54691389..49b48f76 100644 --- a/src/main/java/org/javaswift/joss/command/shared/identity/access/AccessBasic.java +++ b/src/main/java/org/javaswift/joss/command/shared/identity/access/AccessBasic.java @@ -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; + } +} diff --git a/src/test/java/org/javaswift/joss/command/shared/identity/access/AccessBasicTest.java b/src/test/java/org/javaswift/joss/command/shared/identity/access/AccessBasicTest.java index fdda685f..e1c95f3c 100644 --- a/src/test/java/org/javaswift/joss/command/shared/identity/access/AccessBasicTest.java +++ b/src/test/java/org/javaswift/joss/command/shared/identity/access/AccessBasicTest.java @@ -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()); + } +}