mirror of
https://github.com/scm-manager/scm-manager.git
synced 2025-11-08 14:35:45 +01:00
Fix time format
This commit is contained in:
@@ -5,14 +5,20 @@ import sonia.scm.security.AccessToken;
|
|||||||
|
|
||||||
import java.text.SimpleDateFormat;
|
import java.text.SimpleDateFormat;
|
||||||
import java.util.Collections;
|
import java.util.Collections;
|
||||||
|
import java.util.TimeZone;
|
||||||
|
|
||||||
|
class ExpiringAction extends Response.Action {
|
||||||
|
private static final SimpleDateFormat DATE_FORMAT = new SimpleDateFormat("yyyy-MM-dd'T'HH:mm:ss'Z'");
|
||||||
|
static {
|
||||||
|
DATE_FORMAT.setTimeZone(TimeZone.getTimeZone("GMT"));
|
||||||
|
}
|
||||||
|
|
||||||
@SuppressWarnings({"squid:S00116"})
|
@SuppressWarnings({"squid:S00116"})
|
||||||
// This class is used for json serialization, only
|
// This class is used for json serialization, only
|
||||||
class ExpiringAction extends Response.Action {
|
|
||||||
public final String expires_at;
|
public final String expires_at;
|
||||||
|
|
||||||
ExpiringAction(String href, AccessToken accessToken) {
|
ExpiringAction(String href, AccessToken accessToken) {
|
||||||
this.expires_at = new SimpleDateFormat("yyyy-MM-dd'T'HH:MM:ss'Z'").format(accessToken.getExpiration());
|
this.expires_at = DATE_FORMAT.format(accessToken.getExpiration());
|
||||||
this.href = href;
|
this.href = href;
|
||||||
this.header = Collections.singletonMap("Authorization", "Bearer " + accessToken.compact());
|
this.header = Collections.singletonMap("Authorization", "Bearer " + accessToken.compact());
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -79,7 +79,7 @@ class LFSAuthCommandTest {
|
|||||||
CommandContext commandContext = createCommandContext();
|
CommandContext commandContext = createCommandContext();
|
||||||
commandInterpreter.getProtocolHandler().handle(commandContext, createRepositoryContext());
|
commandInterpreter.getProtocolHandler().handle(commandContext, createRepositoryContext());
|
||||||
assertThat(commandContext.getOutputStream().toString())
|
assertThat(commandContext.getOutputStream().toString())
|
||||||
.isEqualTo("{\"href\":\"http://example.com/repo/space/X.git/info/lfs/\",\"header\":{\"Authorization\":\"Bearer ACCESS_TOKEN\"},\"expires_at\":\"2007-05-03T12:05:30Z\"}");
|
.isEqualTo("{\"href\":\"http://example.com/repo/space/X.git/info/lfs/\",\"header\":{\"Authorization\":\"Bearer ACCESS_TOKEN\"},\"expires_at\":\"2007-05-03T10:15:30Z\"}");
|
||||||
}
|
}
|
||||||
|
|
||||||
private CommandContext createCommandContext() {
|
private CommandContext createCommandContext() {
|
||||||
|
|||||||
Reference in New Issue
Block a user