Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
FIY695
jenkins
提交
ff90e3de
J
jenkins
项目概览
FIY695
/
jenkins
与 Fork 源项目一致
从无法访问的项目Fork
通知
1
Star
0
Fork
0
代码
文件
提交
分支
Tags
贡献者
分支图
Diff
Issue
0
列表
看板
标记
里程碑
合并请求
0
Wiki
0
Wiki
分析
仓库
DevOps
项目成员
Pages
J
jenkins
项目概览
项目概览
详情
发布
仓库
仓库
文件
提交
分支
标签
贡献者
分支图
比较
Issue
0
Issue
0
列表
看板
标记
里程碑
合并请求
0
合并请求
0
Pages
分析
分析
仓库分析
DevOps
Wiki
0
Wiki
成员
成员
收起侧边栏
关闭侧边栏
动态
分支图
创建新Issue
提交
Issue看板
体验新版 GitCode,发现更多精彩内容 >>
提交
ff90e3de
编写于
4月 19, 2012
作者:
K
Kohsuke Kawaguchi
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
added a test to make sure the certificate is valid for a awhile longer
上级
3d3ccee5
变更
1
隐藏空白更改
内联
并排
Showing
1 changed file
with
21 addition
and
3 deletion
+21
-3
core/src/test/java/hudson/model/UpdateCenterTest.java
core/src/test/java/hudson/model/UpdateCenterTest.java
+21
-3
未找到文件。
core/src/test/java/hudson/model/UpdateCenterTest.java
浏览文件 @
ff90e3de
...
@@ -23,12 +23,22 @@
...
@@ -23,12 +23,22 @@
*/
*/
package
hudson.model
;
package
hudson.model
;
import
com.trilead.ssh2.crypto.Base64
;
import
hudson.util.FormValidation
;
import
hudson.util.FormValidation.Kind
;
import
hudson.util.TimeUnit2
;
import
junit.framework.TestCase
;
import
junit.framework.TestCase
;
import
net.sf.json.JSONObject
;
import
net.sf.json.JSONObject
;
import
org.apache.commons.io.IOUtils
;
import
org.apache.commons.io.IOUtils
;
import
java.io.ByteArrayInputStream
;
import
java.io.IOException
;
import
java.io.IOException
;
import
java.net.URL
;
import
java.net.URL
;
import
java.security.cert.CertificateExpiredException
;
import
java.security.cert.CertificateFactory
;
import
java.security.cert.CertificateNotYetValidException
;
import
java.security.cert.X509Certificate
;
import
java.util.Date
;
/**
/**
* Quick test for {@link UpdateCenter}.
* Quick test for {@link UpdateCenter}.
...
@@ -36,7 +46,7 @@ import java.net.URL;
...
@@ -36,7 +46,7 @@ import java.net.URL;
* @author Kohsuke Kawaguchi
* @author Kohsuke Kawaguchi
*/
*/
public
class
UpdateCenterTest
extends
TestCase
{
public
class
UpdateCenterTest
extends
TestCase
{
public
void
testData
()
throws
IO
Exception
{
public
void
testData
()
throws
Exception
{
// check if we have the internet connectivity. See HUDSON-2095
// check if we have the internet connectivity. See HUDSON-2095
try
{
try
{
new
URL
(
"http://updates.jenkins-ci.org/"
).
openStream
();
new
URL
(
"http://updates.jenkins-ci.org/"
).
openStream
();
...
@@ -47,12 +57,20 @@ public class UpdateCenterTest extends TestCase {
...
@@ -47,12 +57,20 @@ public class UpdateCenterTest extends TestCase {
URL
url
=
new
URL
(
"http://updates.jenkins-ci.org/update-center.json?version=build"
);
URL
url
=
new
URL
(
"http://updates.jenkins-ci.org/update-center.json?version=build"
);
String
jsonp
=
IOUtils
.
toString
(
url
.
openStream
());
String
jsonp
=
IOUtils
.
toString
(
url
.
openStream
());
String
json
=
jsonp
.
substring
(
jsonp
.
indexOf
(
'('
)+
1
,
jsonp
.
lastIndexOf
(
')'
));
JSONObject
json
=
JSONObject
.
fromObject
(
jsonp
.
substring
(
jsonp
.
indexOf
(
'('
)
+
1
,
jsonp
.
lastIndexOf
(
')'
)
));
UpdateSite
us
=
new
UpdateSite
(
"default"
,
url
.
toExternalForm
());
UpdateSite
us
=
new
UpdateSite
(
"default"
,
url
.
toExternalForm
());
UpdateSite
.
Data
data
=
us
.
new
Data
(
JSONObject
.
fromObject
(
json
)
);
UpdateSite
.
Data
data
=
us
.
new
Data
(
json
);
assertTrue
(
data
.
core
.
url
.
startsWith
(
"http://updates.jenkins-ci.org/"
));
assertTrue
(
data
.
core
.
url
.
startsWith
(
"http://updates.jenkins-ci.org/"
));
assertTrue
(
data
.
plugins
.
containsKey
(
"rake"
));
assertTrue
(
data
.
plugins
.
containsKey
(
"rake"
));
System
.
out
.
println
(
data
.
core
.
url
);
System
.
out
.
println
(
data
.
core
.
url
);
// make sure the certificate is valid for a while more
CertificateFactory
cf
=
CertificateFactory
.
getInstance
(
"X509"
);
JSONObject
signature
=
json
.
getJSONObject
(
"signature"
);
for
(
Object
cert
:
signature
.
getJSONArray
(
"certificates"
))
{
X509Certificate
c
=
(
X509Certificate
)
cf
.
generateCertificate
(
new
ByteArrayInputStream
(
Base64
.
decode
(
cert
.
toString
().
toCharArray
())));
c
.
checkValidity
(
new
Date
(
System
.
currentTimeMillis
()
+
TimeUnit2
.
DAYS
.
toMillis
(
30
)));
}
}
}
}
}
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录