2
我想爲我的一個應用程序使用rest-assured,問題是我無法進行身份驗證。Rest-Assured表單身份驗證不起作用
以下是我試圖
baseURI = "http://localhost:8080/api";
given()
.auth().form("admin", "admin", new FormAuthConfig("/authentication/", "j_username", "j_password"))
.when()
.get("/formAuth")
.then()
.log().all()
.statusCode(200);
我曾嘗試下面的選項以及代碼,沒有什麼作品出來 401錯誤的下面和上面的代碼
form("admin", "admin", new FormAuthConfig("/", "j_username", "j_password"))
下列選項不工作,顯示無法解析登錄頁面。檢查登錄頁面上的錯誤或指定FormAuthConfig。錯誤
.auth().form("admin", "admin", formAuthConfig().withAutoDetectionOfCsrf())
以下爲形式
<form class="form ng-pristine ng-valid" role="form" ng-submit="login($event)">
<div class="form-group">
<label for="username" translate="global.form.username" class="ng-scope">Login</label>
<input type="text" class="form-control ng-pristine ng-valid ng-touched" id="username" placeholder="Your login" ng-model="username" autocomplete="off">
</div>
<div class="form-group">
<label for="password" translate="login.form.password" class="ng-scope">Password</label>
<input type="password" class="form-control ng-pristine ng-untouched ng-valid" id="password" placeholder="Your password" ng-model="password">
</div>
<div class="form-group">
<label for="rememberMe">
<input type="checkbox" id="rememberMe" ng-model="rememberMe" checked="" class="ng-pristine ng-untouched ng-valid">
<span translate="login.form.rememberme" class="ng-scope">Automatic Login</span>
</label>
</div>
<button type="submit" class="btn btn-primary ng-scope" translate="login.form.button">Authenticate</button>
</form>
的代碼,以下是使用郵遞員
URL: http://localhost:8080/api/authentication?cacheBuster=1485280599118
parameter: j_username:admin
j_password:admin