アノテーションインターフェース WithMockUser


@TargetSE({METHODSE,TYPESE}) @RetentionSE(RUNTIMESE) @InheritedSE @DocumentedSE @WithSecurityContext(factory=org.springframework.security.test.context.support.WithMockUserSecurityContextFactory.class) public @interface WithMockUser
WithSecurityContextTestExecutionListener と共に使用する場合、このアノテーションをテストメソッドに追加して、モックされたユーザーでの実行をエミュレートできます。MockMvc を使用するには、使用される SecurityContext に次のプロパティがあります。
導入:
4.0
関連事項:
  • 要素の詳細

    • value

      StringSE value
      ユーザー名を指定するための便利なメカニズム。デフォルトは "user" です。username() が指定されている場合、value() の代わりに使用されます
      戻り値:
      デフォルト:
      " ユーザー "
    • username

      StringSE username
      使用するユーザー名。value()username() のシノニムですが、username() が指定されている場合は優先されます。
      戻り値:
      デフォルト:
      ""
    • roles

      StringSE[] roles

      使用するロール。デフォルトは "USER" です。GrantedAuthority は、ロール内の各値に対して作成されます。ロールの各値には、自動的に "ROLE_" がプレフィックスとして付けられます。例: デフォルトでは "ROLE_USER" が使用されます。

      authorities() が指定されている場合、このプロパティはデフォルトから変更できません。

      戻り値:
      デフォルト:
      {"USER"}
    • authorities

      StringSE[] authorities

      使用する権限。各値に対して GrantedAuthority が作成されます。

      このプロパティが指定されている場合、roles() は使用されません。これは、roles() とは異なり、自動的に渡される値にプレフィックスを付けません。

      戻り値:
      デフォルト:
      {}
    • password

      StringSE password
      使用するパスワード。デフォルトは "password" です。
      戻り値:
      デフォルト:
      " パスワード "
    • setupBefore

      @AliasFor(annotation=WithSecurityContext.class) TestExecutionEvent setupBefore
      SecurityContext がいつセットアップされるかを決定します。デフォルトは、TestExecutionListener.beforeTestMethod(TestContext) の間に発生する TestExecutionEvent.TEST_METHOD の前です。
      戻り値:
      前に初期化する TestExecutionEvent
      導入:
      5.1
      デフォルト:
      TEST_METHOD