(window.webpackJsonp=window.webpackJsonp||[]).push([[306],{732:function(t,e,s){"use strict";s.r(e);var a=s(56),n=Object(a.a)({},(function(){var t=this,e=t.$createElement,s=t._self._c||e;return s("ContentSlotsDistributor",{attrs:{"slot-key":t.$parent.slotKey}},[s("h1",{attrs:{id:"testing-http-basic-authentication"}},[s("a",{staticClass:"header-anchor",attrs:{href:"#testing-http-basic-authentication"}},[t._v("#")]),t._v(" Testing HTTP Basic Authentication")]),t._v(" "),s("p",[t._v("While it has always been possible to authenticate with HTTP Basic, it was a bit tedious to remember the header name, format, and encode the values.\nNow this can be done using Spring Security’s "),s("code",[t._v("httpBasic")]),t._v(" "),s("RouterLink",{attrs:{to:"/en/spring-security/request-post-processors.html"}},[s("code",[t._v("RequestPostProcessor")])]),t._v(".\nFor example, the snippet below:")],1),t._v(" "),s("p",[t._v("Java")]),t._v(" "),s("div",{staticClass:"language- extra-class"},[s("pre",{pre:!0,attrs:{class:"language-text"}},[s("code",[t._v('mvc\n\t.perform(get("/").with(httpBasic("user","password")))\n')])])]),s("p",[t._v("Kotlin")]),t._v(" "),s("div",{staticClass:"language- extra-class"},[s("pre",{pre:!0,attrs:{class:"language-text"}},[s("code",[t._v('mvc.get("/") {\n with(httpBasic("user","password"))\n}\n')])])]),s("p",[t._v('will attempt to use HTTP Basic to authenticate a user with the username "user" and the password "password" by ensuring the following header is populated on the HTTP Request:')]),t._v(" "),s("div",{staticClass:"language- extra-class"},[s("pre",{pre:!0,attrs:{class:"language-text"}},[s("code",[t._v("Authorization: Basic dXNlcjpwYXNzd29yZA==\n")])])]),s("p",[s("RouterLink",{attrs:{to:"/en/spring-security/form-login.html"}},[t._v("Mocking Form Login")]),s("RouterLink",{attrs:{to:"/en/spring-security/oauth2.html"}},[t._v("Mocking OAuth2")])],1)])}),[],!1,null,null,null);e.default=n.exports}}]);