Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
xxadev
jenkins
提交
2e7fe04d
J
jenkins
项目概览
xxadev
/
jenkins
与 Fork 源项目一致
从无法访问的项目Fork
通知
3
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,发现更多精彩内容 >>
提交
2e7fe04d
编写于
4月 07, 2017
作者:
J
Jesse Glick
浏览文件
操作
浏览文件
下载
差异文件
Merge branch 'master' into SSH-CLI-JENKINS-41745
上级
6ffc57ae
1ca9c880
变更
7
显示空白变更内容
内联
并排
Showing
7 changed file
with
98 addition
and
49 deletion
+98
-49
core/src/main/java/hudson/model/UpdateCenter.java
core/src/main/java/hudson/model/UpdateCenter.java
+0
-1
core/src/main/java/hudson/search/FixedSet.java
core/src/main/java/hudson/search/FixedSet.java
+9
-12
core/src/main/java/hudson/search/UserSearchProperty.java
core/src/main/java/hudson/search/UserSearchProperty.java
+9
-6
core/src/main/resources/hudson/model/UpdateCenter/DownloadJob/Skipped/status.jelly
...udson/model/UpdateCenter/DownloadJob/Skipped/status.jelly
+28
-0
core/src/test/java/hudson/model/ViewTest.java
core/src/test/java/hudson/model/ViewTest.java
+2
-1
core/src/test/java/jenkins/widgets/HistoryPageFilterTest.java
.../src/test/java/jenkins/widgets/HistoryPageFilterTest.java
+15
-16
test/src/test/java/jenkins/widgets/HistoryPageFilterCaseSensitiveSearchTest.java
...ins/widgets/HistoryPageFilterCaseSensitiveSearchTest.java
+35
-13
未找到文件。
core/src/main/java/hudson/model/UpdateCenter.java
浏览文件 @
2e7fe04d
...
...
@@ -1870,7 +1870,6 @@ public class UpdateCenter extends AbstractModelObject implements Saveable, OnMas
// Do this first so we can avoid duplicate downloads, too
// check to see if the plugin is already installed at the same version and skip it
LOGGER
.
info
(
"Skipping duplicate install of: "
+
plugin
.
getDisplayName
()
+
"@"
+
plugin
.
version
);
//throw new Skipped(); // TODO set skipped once we have a status indicator for it
return
;
}
try
{
...
...
core/src/main/java/hudson/search/FixedSet.java
浏览文件 @
2e7fe04d
...
...
@@ -27,12 +27,15 @@ import java.util.Arrays;
import
java.util.Collection
;
import
java.util.List
;
import
org.apache.commons.lang.StringUtils
;
/**
* Set of {@link SearchItem}s that are statically known upfront.
*
* @author Kohsuke Kawaguchi
*/
public
class
FixedSet
implements
SearchIndex
{
private
final
Collection
<?
extends
SearchItem
>
items
;
public
FixedSet
(
Collection
<?
extends
SearchItem
>
items
)
{
...
...
@@ -45,27 +48,21 @@ public class FixedSet implements SearchIndex {
public
void
find
(
String
token
,
List
<
SearchItem
>
result
)
{
boolean
caseInsensitive
=
UserSearchProperty
.
isCaseInsensitive
();
for
(
SearchItem
i
:
items
){
for
(
SearchItem
i
:
items
)
{
String
name
=
i
.
getSearchName
();
if
(
caseInsensitive
){
token
=
token
.
toLowerCase
();
name
=
name
.
toLowerCase
();
}
if
(
token
.
equals
(
i
.
getSearchName
()))
if
(
name
.
equals
(
token
)
||
(
caseInsensitive
&&
name
.
equalsIgnoreCase
(
token
)))
{
result
.
add
(
i
);
}
}
}
public
void
suggest
(
String
token
,
List
<
SearchItem
>
result
)
{
boolean
caseInsensitive
=
UserSearchProperty
.
isCaseInsensitive
();
for
(
SearchItem
i
:
items
){
for
(
SearchItem
i
:
items
)
{
String
name
=
i
.
getSearchName
();
if
(
caseInsensitive
){
token
=
token
.
toLowerCase
();
name
=
name
.
toLowerCase
();
}
if
(
name
.
contains
(
token
))
if
(
name
.
contains
(
token
)
||
(
caseInsensitive
&&
StringUtils
.
containsIgnoreCase
(
name
,
token
)))
{
result
.
add
(
i
);
}
}
}
}
core/src/main/java/hudson/search/UserSearchProperty.java
浏览文件 @
2e7fe04d
...
...
@@ -12,6 +12,8 @@ import org.kohsuke.stapler.export.Exported;
public
class
UserSearchProperty
extends
hudson
.
model
.
UserProperty
{
private
static
final
boolean
DEFAULT_SEARCH_CASE_INSENSITIVE_MODE
=
true
;
private
final
boolean
insensitiveSearch
;
public
UserSearchProperty
(
boolean
insensitiveSearch
)
{
...
...
@@ -25,11 +27,12 @@ public class UserSearchProperty extends hudson.model.UserProperty {
public
static
boolean
isCaseInsensitive
(){
User
user
=
User
.
current
();
boolean
caseInsensitive
=
false
;
if
(
user
!=
null
&&
user
.
getProperty
(
UserSearchProperty
.
class
).
getInsensitiveSearch
()){
//Searching for anonymous user is case-sensitive
caseInsensitive
=
true
;
if
(
user
==
null
)
{
return
DEFAULT_SEARCH_CASE_INSENSITIVE_MODE
;
}
return
caseInsensitive
;
return
user
.
getProperty
(
UserSearchProperty
.
class
).
getInsensitiveSearch
();
}
...
...
@@ -40,7 +43,7 @@ public class UserSearchProperty extends hudson.model.UserProperty {
}
public
UserProperty
newInstance
(
User
user
)
{
return
new
UserSearchProperty
(
false
);
//default setting is case-sensitive searching
return
new
UserSearchProperty
(
DEFAULT_SEARCH_CASE_INSENSITIVE_MODE
);
}
@Override
...
...
core/src/main/resources/hudson/model/UpdateCenter/DownloadJob/Skipped/status.jelly
0 → 100644
浏览文件 @
2e7fe04d
<!--
The MIT License
Copyright (c) 2004-2009, Sun Microsystems, Inc., Kohsuke Kawaguchi
Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
in the Software without restriction, including without limitation the rights
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
copies of the Software, and to permit persons to whom the Software is
furnished to do so, subject to the following conditions:
The above copyright notice and this permission notice shall be included in
all copies or substantial portions of the Software.
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
THE SOFTWARE.
-->
<?jelly escape-by-default='true'?>
<j:jelly xmlns:j="jelly:core" xmlns:st="jelly:stapler" xmlns:d="jelly:define" xmlns:l="/lib/layout" xmlns:t="/lib/hudson" xmlns:f="/lib/form">
<l:icon class="icon-grey icon-md"/> ${%Skipped}
</j:jelly>
core/src/test/java/hudson/model/ViewTest.java
浏览文件 @
2e7fe04d
...
...
@@ -13,6 +13,7 @@ import java.io.IOException;
import
java.util.ArrayList
;
import
java.util.Arrays
;
import
java.util.Collection
;
import
java.util.Collections
;
import
java.util.List
;
import
javax.servlet.ServletException
;
...
...
@@ -98,7 +99,7 @@ public class ViewTest {
final
TopLevelItem
rightJob
=
createJob
(
"rightJob"
);
Mockito
.
when
(
leftView
.
getItems
()).
thenReturn
(
Arrays
.
asList
(
leftJob
,
sharedJob
));
Mockito
.
when
(
rightView
.
getItems
()).
thenReturn
(
Arrays
.
as
List
(
rightJob
));
Mockito
.
when
(
rightView
.
getItems
()).
thenReturn
(
Collections
.
singleton
List
(
rightJob
));
final
TopLevelItem
[]
expected
=
new
TopLevelItem
[]
{
rootJob
,
sharedJob
,
leftJob
,
rightJob
};
...
...
core/src/test/java/jenkins/widgets/HistoryPageFilterTest.java
浏览文件 @
2e7fe04d
...
...
@@ -37,8 +37,8 @@ import hudson.model.Run;
import
hudson.model.StringParameterValue
;
import
org.junit.Assert
;
import
org.junit.Ignore
;
import
org.junit.Test
;
import
org.jvnet.hudson.test.Issue
;
import
org.mockito.Mockito
;
import
java.io.IOException
;
...
...
@@ -326,24 +326,21 @@ public class HistoryPageFilterTest {
}
@Test
public
void
test_search_should_be_case_sensitive_for_anonymous_user
()
throws
IOException
{
//given
HistoryPageFilter
<
ModelObject
>
historyPageFilter
=
newPage
(
5
,
null
,
null
);
//and
historyPageFilter
.
setSearchString
(
"failure"
);
//and
@Issue
(
"JENKINS-42645"
)
public
void
should_be_case_insensitive_by_default
()
throws
IOException
{
List
<
ModelObject
>
runs
=
Lists
.<
ModelObject
>
newArrayList
(
new
MockRun
(
2
,
Result
.
FAILURE
),
new
MockRun
(
1
,
Result
.
SUCCESS
));
List
<
Queue
.
Item
>
queueItems
=
newQueueItems
(
3
,
4
);
//when
historyPageFilter
.
add
(
runs
,
queueItems
);
assertOneMatchingBuildForGivenSearchStringAndRunItems
(
"failure"
,
runs
);
}
//then
Assert
.
assertEquals
(
0
,
historyPageFilter
.
runs
.
size
());
@Test
public
void
should_lower_case_search_string_in_case_insensitive_search
()
throws
IOException
{
List
<
ModelObject
>
runs
=
Lists
.<
ModelObject
>
newArrayList
(
new
MockRun
(
2
,
Result
.
FAILURE
),
new
MockRun
(
1
,
Result
.
SUCCESS
));
assertOneMatchingBuildForGivenSearchStringAndRunItems
(
"FAILure"
,
runs
);
}
@Test
public
void
test_search_builds_by_build_variables
()
throws
IOException
{
@Issue
(
"JENKINS-40718"
)
public
void
should_search_builds_by_build_variables
()
throws
IOException
{
List
<
ModelObject
>
runs
=
ImmutableList
.<
ModelObject
>
of
(
new
MockBuild
(
2
).
withBuildVariables
(
ImmutableMap
.
of
(
"env"
,
"dummyEnv"
)),
new
MockBuild
(
1
).
withBuildVariables
(
ImmutableMap
.
of
(
"env"
,
"otherEnv"
)));
...
...
@@ -351,7 +348,8 @@ public class HistoryPageFilterTest {
}
@Test
public
void
test_search_builds_by_build_params
()
throws
IOException
{
@Issue
(
"JENKINS-40718"
)
public
void
should_search_builds_by_build_params
()
throws
IOException
{
List
<
ModelObject
>
runs
=
ImmutableList
.<
ModelObject
>
of
(
new
MockBuild
(
2
).
withBuildParameters
(
ImmutableMap
.
of
(
"env"
,
"dummyEnv"
)),
new
MockBuild
(
1
).
withBuildParameters
(
ImmutableMap
.
of
(
"env"
,
"otherEnv"
)));
...
...
@@ -359,7 +357,8 @@ public class HistoryPageFilterTest {
}
@Test
public
void
test_ignore_sensitive_parameters_in_search_builds_by_build_params
()
throws
IOException
{
@Issue
(
"JENKINS-40718"
)
public
void
should_ignore_sensitive_parameters_in_search_builds_by_build_params
()
throws
IOException
{
List
<
ModelObject
>
runs
=
ImmutableList
.<
ModelObject
>
of
(
new
MockBuild
(
2
).
withBuildParameters
(
ImmutableMap
.
of
(
"plainPassword"
,
"pass1plain"
)),
new
MockBuild
(
1
).
withSensitiveBuildParameters
(
"password"
,
"pass1"
));
...
...
test/src/test/java/jenkins/widgets/HistoryPageFilter
Ins
ensitiveSearchTest.java
→
test/src/test/java/jenkins/widgets/HistoryPageFilter
CaseS
ensitiveSearchTest.java
浏览文件 @
2e7fe04d
...
...
@@ -8,6 +8,7 @@ import org.acegisecurity.providers.UsernamePasswordAuthenticationToken;
import
org.junit.Assert
;
import
org.junit.Rule
;
import
org.junit.Test
;
import
org.jvnet.hudson.test.Issue
;
import
org.jvnet.hudson.test.JenkinsRule
;
import
org.mockito.Mockito
;
...
...
@@ -25,8 +26,11 @@ import hudson.security.AuthorizationStrategy;
/**
* TODO: Code partially duplicated with HistoryPageFilterTest in core
*
* Search in case insensitive mode is tested by unit tests in HistoryPageFilterTest.
*/
public
class
HistoryPageFilterInsensitiveSearchTest
{
@Issue
({
"JENKINS-40718"
,
"JENKINS-42645"
})
public
class
HistoryPageFilterCaseSensitiveSearchTest
{
private
static
final
String
TEST_USER_NAME
=
"testUser"
;
...
...
@@ -34,31 +38,45 @@ public class HistoryPageFilterInsensitiveSearchTest {
public
JenkinsRule
j
=
new
JenkinsRule
();
@Test
public
void
should_search_insensitively_when_enabled_for_user
()
throws
IOException
{
setUserContextAndAssertCaseInsensitivitySearchForGivenSearchString
(
"failure"
);
public
void
should_search_case_sensitively_when_enabled_for_user
()
throws
IOException
{
setCaseSensitiveSearchForUserAndCheckAssertionForGivenSearchString
(
"FAILURE"
,
new
SearchResultAssertFunction
()
{
@Override
public
void
doAssertion
(
HistoryPageFilter
<
ModelObject
>
historyPageFilter
)
{
Assert
.
assertEquals
(
1
,
historyPageFilter
.
runs
.
size
());
Assert
.
assertEquals
(
HistoryPageEntry
.
getEntryId
(
2
),
historyPageFilter
.
runs
.
get
(
0
).
getEntryId
());
}
});
}
@Test
public
void
should_also_lower_search_query_in_insensitive_search_enabled
()
throws
IOException
{
setUserContextAndAssertCaseInsensitivitySearchForGivenSearchString
(
"FAILure"
);
public
void
should_skip_result_with_different_capitalization_when_case_sensitively_search_is_enabled_for_user
()
throws
IOException
{
setCaseSensitiveSearchForUserAndCheckAssertionForGivenSearchString
(
"failure"
,
new
SearchResultAssertFunction
()
{
@Override
public
void
doAssertion
(
HistoryPageFilter
<
ModelObject
>
historyPageFilter
)
{
Assert
.
assertEquals
(
0
,
historyPageFilter
.
runs
.
size
());
}
});
}
private
void
setUserContextAndAssertCaseInsensitivitySearchForGivenSearchString
(
final
String
searchString
)
throws
IOException
{
private
void
setCaseSensitiveSearchForUserAndCheckAssertionForGivenSearchString
(
final
String
searchString
,
SearchResultAssertFunction
assertionOnSearchResults
)
throws
IOException
{
AuthorizationStrategy
.
Unsecured
strategy
=
new
AuthorizationStrategy
.
Unsecured
();
j
.
jenkins
.
setAuthorizationStrategy
(
strategy
);
j
.
jenkins
.
setSecurityRealm
(
j
.
createDummySecurityRealm
());
UsernamePasswordAuthenticationToken
testUserAuthentication
=
new
UsernamePasswordAuthenticationToken
(
TEST_USER_NAME
,
"any"
);
try
(
ACLContext
acl
=
ACL
.
as
(
testUserAuthentication
))
{
User
.
get
(
TEST_USER_NAME
).
addProperty
(
new
UserSearchProperty
(
tru
e
));
try
(
ACLContext
ignored
=
ACL
.
as
(
testUserAuthentication
))
{
User
.
get
(
TEST_USER_NAME
).
addProperty
(
new
UserSearchProperty
(
fals
e
));
//test logic
List
<
ModelObject
>
runs
=
ImmutableList
.<
ModelObject
>
of
(
new
MockRun
(
2
,
Result
.
FAILURE
),
new
MockRun
(
1
,
Result
.
SUCCESS
));
assert
OneMatchingBuildForGivenSearchStringAndRunItems
(
searchString
,
run
s
);
final
List
<
ModelObject
>
runs
=
ImmutableList
.<
ModelObject
>
of
(
new
MockRun
(
2
,
Result
.
FAILURE
),
new
MockRun
(
1
,
Result
.
SUCCESS
));
assert
NoMatchingBuildsForGivenSearchStringAndRunItems
(
searchString
,
runs
,
assertionOnSearchResult
s
);
}
}
private
void
assertOneMatchingBuildForGivenSearchStringAndRunItems
(
String
searchString
,
List
<
ModelObject
>
runs
)
{
private
void
assertNoMatchingBuildsForGivenSearchStringAndRunItems
(
String
searchString
,
List
<
ModelObject
>
runs
,
SearchResultAssertFunction
assertionOnSearchResults
)
{
//given
HistoryPageFilter
<
ModelObject
>
historyPageFilter
=
new
HistoryPageFilter
<>(
5
);
//and
...
...
@@ -68,8 +86,7 @@ public class HistoryPageFilterInsensitiveSearchTest {
historyPageFilter
.
add
(
runs
,
Collections
.<
Queue
.
Item
>
emptyList
());
//then
Assert
.
assertEquals
(
1
,
historyPageFilter
.
runs
.
size
());
Assert
.
assertEquals
(
HistoryPageEntry
.
getEntryId
(
2
),
historyPageFilter
.
runs
.
get
(
0
).
getEntryId
());
assertionOnSearchResults
.
doAssertion
(
historyPageFilter
);
}
@SuppressWarnings
(
"unchecked"
)
...
...
@@ -111,4 +128,9 @@ public class HistoryPageFilterInsensitiveSearchTest {
return
(
int
)
queueId
;
}
}
//Waiting for Java 8... - coming soon - April 2017?
private
interface
SearchResultAssertFunction
{
void
doAssertion
(
HistoryPageFilter
<
ModelObject
>
historyPageFilter
);
}
}
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录