-
Notifications
You must be signed in to change notification settings - Fork 108
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
TempURL fixed according to commit in:
- Loading branch information
Thomas Ritscher
committed
Jan 8, 2018
1 parent
02430c6
commit 991cea5
Showing
2 changed files
with
75 additions
and
73 deletions.
There are no files selected for viewing
94 changes: 48 additions & 46 deletions
94
src/main/java/org/javaswift/joss/command/shared/identity/access/AccessBasic.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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; | ||
} | ||
} |
54 changes: 27 additions & 27 deletions
54
src/test/java/org/javaswift/joss/command/shared/identity/access/AccessBasicTest.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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()); | ||
} | ||
} |