• 设为首页
  • 点击收藏
  • 手机版
    手机扫一扫访问
    迪恩网络手机版
  • 关注官方公众号
    微信扫一扫关注
    迪恩网络公众号

Java WithUserDetails类代码示例

原作者: [db:作者] 来自: [db:来源] 收藏 邀请

本文整理汇总了Java中org.springframework.security.test.context.support.WithUserDetails的典型用法代码示例。如果您正苦于以下问题:Java WithUserDetails类的具体用法?Java WithUserDetails怎么用?Java WithUserDetails使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。



WithUserDetails类属于org.springframework.security.test.context.support包,在下文中一共展示了WithUserDetails类的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的Java代码示例。

示例1: test_user1_defaultAfterLogin

import org.springframework.security.test.context.support.WithUserDetails; //导入依赖的package包/类
@Test
@WithUserDetails("[email protected]")
public void test_user1_defaultAfterLogin() throws Exception {
    mvc
            .perform(get("/default"))
            .andExpect(status().is3xxRedirection())
            .andExpect(redirectedUrl("/"))
            .andDo(print())
    ;
}
 
开发者ID:PacktPublishing,项目名称:Spring-Security-Third-Edition,代码行数:11,代码来源:DefaultControllerTests.java


示例2: testGetVoteMvc

import org.springframework.security.test.context.support.WithUserDetails; //导入依赖的package包/类
@Test
@WithUserDetails("jos")
public void testGetVoteMvc() throws Exception {
    final long qaId = 123;
    final Vote vote = new Vote(null, null, true);

    final CustomUserDetails josUserDetails = (CustomUserDetails)this.userDetailsService.loadUserByUsername("jos");

    given(this.voteService.getVoteByUser(qaId, josUserDetails)).willReturn(vote);

    this.mvc.perform(get("/vote/" + qaId)
            .with(csrf())
            .accept(MediaType.APPLICATION_JSON))
            .andDo(print())
            .andExpect(status().isOk())
            .andExpect(jsonPath("$.up", is(vote.isUp())));
}
 
开发者ID:kdg-ti,项目名称:programmeren3,代码行数:18,代码来源:RestControllerMvcTests.java


示例3: withoutPermissionTest

import org.springframework.security.test.context.support.WithUserDetails; //导入依赖的package包/类
@Test
@WithUserDetails("joao")
public void withoutPermissionTest() {
    List<BoxConfigurationData> groupDTOs = new ArrayList<BoxConfigurationData>();

    BoxConfigurationData b = new BoxConfigurationData();
    b.setId("box1");
    b.setBoxesDefinition(new ArrayList<BoxDefinitionData>());
    b.setProcesses(new ArrayList<RequirementDefinitionDTO>());
    groupDTOs.add(b);

    BoxConfigurationData b2 = new BoxConfigurationData();
    b2.setId("box2");
    b2.setBoxesDefinition(new ArrayList<BoxDefinitionData>());
    b2.setProcesses(new ArrayList<RequirementDefinitionDTO>());
    groupDTOs.add(b2);

    String idUsuario = "joao";

    authorizationService.filterBoxWithPermissions(groupDTOs, idUsuario);
    Assert.assertEquals(0, groupDTOs.size());
}
 
开发者ID:opensingular,项目名称:singular-server,代码行数:23,代码来源:AuthorizationServiceTest.java


示例4: testLoadDraft

import org.springframework.security.test.context.support.WithUserDetails; //导入依赖的package包/类
@WithUserDetails("vinicius.nunes")
@Test
public void testLoadDraft() {
    tester = new SingularWicketTester(singularApplication);

    FormPage p = saveDraft();

    RequirementInstance requirement = getRequirementFrom(p);

    ActionContext context = new ActionContext();
    context.setFormName(SPackageFOO.STypeFOO.FULL_NAME);
    context.setFormAction(FormAction.FORM_FILL);
    context.setRequirementId(requirement.getCod());

    FormPage p2 = new FormPage(context);
    tester.startPage(p2);
    tester.assertRenderedPage(FormPage.class);

    TextField<String> t2 = (TextField<String>) new AssertionsWComponent(p2).getSubComponents(TextField.class).first().getTarget();
    assertEquals(SUPER_TESTE_STRING, t2.getDefaultModelObject());
}
 
开发者ID:opensingular,项目名称:singular-server,代码行数:22,代码来源:FormPageTest.java


示例5: deleteItem

import org.springframework.security.test.context.support.WithUserDetails; //导入依赖的package包/类
@WithUserDetails("vinicius.nunes")
@Test(expected = RestartResponseException.class)
public void deleteItem() {
    tester = new SingularWicketTester(singularApplication);
    BoxPage boxPage = new BoxPage(null);
    tester.startPage(boxPage);
    tester.assertRenderedPage(BoxPage.class);
    tester.assertNoErrorMessage();

    Component deleteButton = tester.getAssertionsPage()
            .getSubComponentWithId("actions")
            .getSubComponentWithId("3")
            .getSubComponentWithId("link")
            .getTarget();
    tester.executeAjaxEvent(deleteButton, "click");
    tester.assertNoErrorMessage();

    Component confirmButton = tester.getAssertionsPage()
            .getSubComponentWithId("confirm-btn")
            .getTarget();
    tester.executeAjaxEvent(confirmButton, "click");
    tester.assertNoErrorMessage();

    tester.assertRenderedPage(BoxPage.class);
    tester.assertNoErrorMessage();
}
 
开发者ID:opensingular,项目名称:singular-server,代码行数:27,代码来源:BoxPageTest.java


示例6: cancelDeleteItem

import org.springframework.security.test.context.support.WithUserDetails; //导入依赖的package包/类
@WithUserDetails("vinicius.nunes")
@Test(expected = RestartResponseException.class)
public void cancelDeleteItem() {
    tester = new SingularWicketTester(singularApplication);
    BoxPage boxPage = new BoxPage(null);
    tester.startPage(boxPage);
    tester.assertRenderedPage(BoxPage.class);

    Component deleteButton = tester.getAssertionsPage()
            .getSubComponentWithId("actions")
            .getSubComponentWithId("3")
            .getSubComponentWithId("link")
            .getTarget();
    tester.executeAjaxEvent(deleteButton, "click");
    tester.assertNoErrorMessage();

    Component confirmButton = tester.getAssertionsPage()
            .getSubComponentWithId("cancel-btn")
            .getTarget();
    tester.executeAjaxEvent(confirmButton, "click");

    tester.assertRenderedPage(BoxPage.class);
    tester.assertNoErrorMessage();
}
 
开发者ID:opensingular,项目名称:singular-server,代码行数:25,代码来源:BoxPageTest.java


示例7: historyForm

import org.springframework.security.test.context.support.WithUserDetails; //导入依赖的package包/类
@WithUserDetails("vinicius.nunes")
@Test(expected = RestartResponseException.class)
public void historyForm() {
    tester = new SingularWicketTester(singularApplication);
    sendRequirement(tester, SPackageFOO.STypeFOO.FULL_NAME, this::fillForm);

    BoxPage boxPage = new BoxPage(null);
    tester.startPage(boxPage);
    Component historyLink = tester.getAssertionsPage()
            .getSubComponentWithId("actions")
            .getSubComponentWithId("5")
            .getSubComponentWithId("link")
            .getTarget();
    tester.clickLink(historyLink);

    tester.assertRenderedPage(HistoryPage.class);
}
 
开发者ID:opensingular,项目名称:singular-server,代码行数:18,代码来源:BoxPageTest.java


示例8: testGetArtistMostPopularTracks

import org.springframework.security.test.context.support.WithUserDetails; //导入依赖的package包/类
@Test
@WithUserDetails("[email protected]")
public void testGetArtistMostPopularTracks() throws Exception {

    final Track track1 = new Track("track1", new Artist("The Beatles"), "album1", "/root/track1.mp3", null);
    final Track track2 = new Track("track2", new Artist("The Beatles"), "album2", "/root/track2.mp3", null);
    final Track track3 = new Track("track3", new Artist("Not The Beatles"), "album3", "/root/track3.mp3", null);
    final Track track4 = new Track("track4", new Artist("The Beatles"), "album4", "/root/track4.mp3", null);

    trackService.save(track1);
    trackService.save(track2);
    trackService.save(track3);
    trackService.save(track4);
    final List<Integer> trackIds = Arrays.asList(track1.getId(), track2.getId(), track3.getId(), track4.getId());
    dbHistoryPopulateService.populateTrackListened(trackIds, SecurityUtil.currentUser().getId());

    assertEquals(trackIds.size() - 1, trackService.getArtistMostPopularTracks("The Beatles").size());
}
 
开发者ID:music-for-all,项目名称:music-for-all-application,代码行数:19,代码来源:TrackServiceTest.java


示例9: testGetArtistMostPopularAlbums

import org.springframework.security.test.context.support.WithUserDetails; //导入依赖的package包/类
@Test
@WithUserDetails("[email protected]")
public void testGetArtistMostPopularAlbums() throws Exception {

    final Track track1 = new Track("track1", new Artist("Johann Sebastian Bach"), "The Best", "/root/track1.mp3", null);
    final Track track2 = new Track("track2", new Artist("Johann Sebastian Bach"), "The Best", "/root/track2.mp3", null);
    final Track track3 = new Track("track3", new Artist("Johann Sebastian Bach"), "The Best", "/root/track3.mp3", null);
    final Track track4 = new Track("track4", new Artist("Johann Sebastian Bach"), "Not The Best", "/root/track4.mp3", null);

    trackService.save(track1);
    trackService.save(track2);
    trackService.save(track3);
    trackService.save(track4);
    final List<Integer> trackIds = Arrays.asList(track1.getId(), track2.getId(), track3.getId(), track4.getId());
    dbHistoryPopulateService.populateTrackListened(trackIds, SecurityUtil.currentUser().getId());

    assertEquals(2, trackService.getArtistMostPopularAlbums("Johann Sebastian Bach").size());
}
 
开发者ID:music-for-all,项目名称:music-for-all-application,代码行数:19,代码来源:TrackServiceTest.java


示例10: registeredUserCannotAccessAdmin

import org.springframework.security.test.context.support.WithUserDetails; //导入依赖的package包/类
@Test
@WithUserDetails(value = "erwin",
        userDetailsServiceBeanName = "currentUserDetailsService")
public void registeredUserCannotAccessAdmin() throws Exception {

    // Erwin a registered user but not in ROLE_POSTS
    RequestBuilder request = get("/admin").with(csrf());
    mvc.perform(request)
            .andExpect(status().isForbidden())
            .andExpect(forwardedUrl("/403"));
}
 
开发者ID:mintster,项目名称:nixmash-blog,代码行数:12,代码来源:AdminControllerTests.java


示例11: userLikedPosts_LoadsLikesView

import org.springframework.security.test.context.support.WithUserDetails; //导入依赖的package包/类
@Test
@WithUserDetails(value = "keith")
public void userLikedPosts_LoadsLikesView() throws Exception {
    this.mockMvc.perform(get("/posts/likes/3"))
            .andExpect(status().isOk())
            .andExpect(view().name(POSTS_LIKES_VIEW));
}
 
开发者ID:mintster,项目名称:nixmash-blog,代码行数:8,代码来源:PostsControllerTests.java


示例12: postPathsforAuthenticatedUsers

import org.springframework.security.test.context.support.WithUserDetails; //导入依赖的package包/类
@Test
@WithUserDetails(value = "keith", userDetailsServiceBeanName = "currentUserDetailsService")
public void postPathsforAuthenticatedUsers() throws Exception {

    // liked posts
    mockMvc.perform(get("/json/posts/likes/3/page/2"))
            .andExpect(status().isOk());
}
 
开发者ID:mintster,项目名称:nixmash-blog,代码行数:9,代码来源:PostsRestControllerTests.java


示例13: newLikedPostReturnsPlusOne

import org.springframework.security.test.context.support.WithUserDetails; //导入依赖的package包/类
@Test
@WithUserDetails(value = "erwin", userDetailsServiceBeanName = "currentUserDetailsService")
public void newLikedPostReturnsPlusOne() throws Exception {
    // no pre-existing post likes for Erwin
    mockMvc.perform(get("/json/posts/post/like/3"))
            .andExpect(content().string("1"))
            .andExpect(content().contentTypeCompatibleWith(MediaType.APPLICATION_JSON));
}
 
开发者ID:mintster,项目名称:nixmash-blog,代码行数:9,代码来源:PostsRestControllerTests.java


示例14: existingLikedPostClickReturnsMinusOne

import org.springframework.security.test.context.support.WithUserDetails; //导入依赖的package包/类
@Test
@WithUserDetails(value = "keith", userDetailsServiceBeanName = "currentUserDetailsService")
public void existingLikedPostClickReturnsMinusOne() throws Exception {
    // pre-existing postId 3 like for Keith
    mockMvc.perform(get("/json/posts/post/like/3"))
            .andExpect(content().string("-1"))
            .andExpect(content().contentTypeCompatibleWith(MediaType.APPLICATION_JSON));
}
 
开发者ID:mintster,项目名称:nixmash-blog,代码行数:9,代码来源:PostsRestControllerTests.java


示例15: loggedInUserCanAccessResetPasswordPage

import org.springframework.security.test.context.support.WithUserDetails; //导入依赖的package包/类
@Test
@WithUserDetails(value = "keith", userDetailsServiceBeanName = "currentUserDetailsService")
public void loggedInUserCanAccessResetPasswordPage() throws Exception {
    RequestBuilder request = get("/users/resetpassword").with(csrf());
    mvc.perform(request)
            .andExpect(status().isOk())
            .andExpect(model().attributeExists("userPasswordDTO"))
            .andExpect(view().name(USER_CHANGEPASSWORD_VIEW));
}
 
开发者ID:mintster,项目名称:nixmash-blog,代码行数:10,代码来源:UserPasswordControllerTests.java


示例16: saveNewGradeForStudentAndCourseTest

import org.springframework.security.test.context.support.WithUserDetails; //导入依赖的package包/类
@Test
@WithUserDetails("lecturer1")
public void saveNewGradeForStudentAndCourseTest() {
    Totp totp = new Totp(lecturer.getTwoFactorSecret());
    Grade result = gradeService.saveNewGradeForStudentAndCourse(new GradeAuthorizationDTO(validGrade, totp.now()));
    assertEquals(validGrade.getLecturer(), result.getLecturer());
    assertEquals(validGrade.getStudent(), result.getStudent());
    assertEquals(validGrade.getCourse(), result.getCourse());
    assertEquals(validGrade.getMark(), result.getMark());
}
 
开发者ID:university-information-system,项目名称:uis,代码行数:11,代码来源:GradeServiceTests.java


示例17: saveNewGradeForStudentAndCourseTestTwoFactorAuthFail

import org.springframework.security.test.context.support.WithUserDetails; //导入依赖的package包/类
@Ignore //Takes more than a minute
@Test(expected = ValidationException.class)
@WithUserDetails("lecturer1")
public void saveNewGradeForStudentAndCourseTestTwoFactorAuthFail() throws InterruptedException {
    Totp totp = new Totp(lecturer.getTwoFactorSecret());
    String code = totp.now();
    Thread.sleep(2 * TWO_FACTOR_AUTHENTICATION_TIMEOUT_SECONDS  * 1000);
    gradeService.saveNewGradeForStudentAndCourse(new GradeAuthorizationDTO(validGrade, code));
}
 
开发者ID:university-information-system,项目名称:uis,代码行数:10,代码来源:GradeServiceTests.java


示例18: saveNewGradeForStudentAndCourseTestTwoFactorAuthFailWrongCode

import org.springframework.security.test.context.support.WithUserDetails; //导入依赖的package包/类
@Test(expected = ValidationException.class)
@WithUserDetails("lecturer1")
public void saveNewGradeForStudentAndCourseTestTwoFactorAuthFailWrongCode() throws InterruptedException {
    Totp totp = new Totp(lecturer.getTwoFactorSecret());
    String code = "123456";
    gradeService.saveNewGradeForStudentAndCourse(new GradeAuthorizationDTO(validGrade, code));
}
 
开发者ID:university-information-system,项目名称:uis,代码行数:8,代码来源:GradeServiceTests.java


示例19: test_admin1_defaultAfterLogin

import org.springframework.security.test.context.support.WithUserDetails; //导入依赖的package包/类
@Test
@WithUserDetails("admi[email protected]")
public void test_admin1_defaultAfterLogin() throws Exception {
    mvc
            .perform(get("/default"))
            .andExpect(status().is3xxRedirection())
            .andExpect(redirectedUrl("/events/"))
            .andDo(print())
    ;
}
 
开发者ID:PacktPublishing,项目名称:Spring-Security-Third-Edition,代码行数:11,代码来源:DefaultControllerTests.java


示例20: test_admin1_showCreateLink

import org.springframework.security.test.context.support.WithUserDetails; //导入依赖的package包/类
@Test
    @WithUserDetails("[email protected]")
    public void test_admin1_showCreateLink() throws Exception {
//        mvc
//                .perform(get("/showCreateLink"))
//                .andExpect(status().is3xxRedirection())
//                .andExpect(redirectedUrl("/events/"))
//                .andDo(print())
//        ;
    }
 
开发者ID:PacktPublishing,项目名称:Spring-Security-Third-Edition,代码行数:11,代码来源:WelcomeControllerTests.java



注:本文中的org.springframework.security.test.context.support.WithUserDetails类示例整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。


鲜花

握手

雷人

路过

鸡蛋
该文章已有0人参与评论

请发表评论

全部评论

专题导读
上一篇:
Java StartLogSegmentResponseProto类代码示例发布时间:2022-05-22
下一篇:
Java GraphicalEditPolicy类代码示例发布时间:2022-05-22
热门推荐
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

在线客服(服务时间 9:00~18:00)

在线QQ客服
地址:深圳市南山区西丽大学城创智工业园
电邮:jeky_zhao#qq.com
移动电话:139-2527-9053

Powered by 互联科技 X3.4© 2001-2213 极客世界.|Sitemap