Search in sources :

Example 6 with UserPasswordCredential

use of me.vertretungsplan.objects.credential.UserPasswordCredential in project substitution-schedule-parser by vertretungsplanme.

the class LoginHandlerTest method setUp.

@Before
public void setUp() throws JSONException {
    baseurl = "http://localhost:" + wireMockRule.port();
    correct = new UserPasswordCredential("user", "password");
    wrong = new UserPasswordCredential("user", "wrong");
    JSONObject loginBasic = new JSONObject();
    loginBasic.put("type", "basic");
    dataBasic = getSubstitutionScheduleData(loginBasic);
    JSONObject loginBasicUrl = new JSONObject();
    loginBasicUrl.put("type", "basic");
    loginBasicUrl.put("url", baseurl + "/index.html");
    dataBasicUrl = getSubstitutionScheduleData(loginBasicUrl);
    JSONObject loginFixed = new JSONObject();
    loginFixed.put("type", "fixed");
    loginFixed.put("login", correct.getUsername());
    loginFixed.put("password", correct.getPassword());
    dataFixed = getSubstitutionScheduleData(loginFixed);
    JSONObject loginPost = new JSONObject();
    loginPost.put("type", "post");
    loginPost.put("url", baseurl + "/index.html");
    JSONObject postData = new JSONObject();
    postData.put("user", "_login");
    postData.put("password", "_password");
    loginPost.put("data", postData);
    dataPost = getSubstitutionScheduleData(loginPost);
    JSONObject loginPostCheckUrl = new JSONObject();
    loginPostCheckUrl.put("type", "post");
    loginPostCheckUrl.put("url", baseurl + "/index.html");
    loginPostCheckUrl.put("checkUrl", baseurl + "/index.html");
    loginPostCheckUrl.put("checkText", "please login");
    loginPostCheckUrl.put("data", postData);
    dataPostCheckUrl = getSubstitutionScheduleData(loginPostCheckUrl);
    JSONObject loginPostCheckText = new JSONObject();
    loginPostCheckText.put("type", "post");
    loginPostCheckText.put("url", baseurl + "/index.html");
    loginPostCheckText.put("checkText", "wrong");
    loginPostCheckText.put("data", postData);
    dataPostCheckText = getSubstitutionScheduleData(loginPostCheckText);
    JSONObject loginPostFormData = new JSONObject();
    loginPostFormData.put("type", "post");
    loginPostFormData.put("url", baseurl + "/index.html");
    loginPostFormData.put("form-data", true);
    loginPostFormData.put("data", postData);
    dataPostFormData = getSubstitutionScheduleData(loginPostFormData);
}
Also used : JSONObject(org.json.JSONObject) UserPasswordCredential(me.vertretungsplan.objects.credential.UserPasswordCredential) Before(org.junit.Before)

Aggregations

UserPasswordCredential (me.vertretungsplan.objects.credential.UserPasswordCredential)6 JSONObject (org.json.JSONObject)4 IOException (java.io.IOException)3 CredentialInvalidException (me.vertretungsplan.exception.CredentialInvalidException)3 ArrayList (java.util.ArrayList)2 PasswordCredential (me.vertretungsplan.objects.credential.PasswordCredential)2 HttpResponseException (org.apache.http.client.HttpResponseException)2 Document (org.jsoup.nodes.Document)2 Claims (io.jsonwebtoken.Claims)1 SignatureException (io.jsonwebtoken.SignatureException)1 BigInteger (java.math.BigInteger)1 URL (java.net.URL)1 InvalidKeyException (java.security.InvalidKeyException)1 NoSuchAlgorithmException (java.security.NoSuchAlgorithmException)1 InvalidKeySpecException (java.security.spec.InvalidKeySpecException)1 RSAPublicKeySpec (java.security.spec.RSAPublicKeySpec)1 BadPaddingException (javax.crypto.BadPaddingException)1 Cipher (javax.crypto.Cipher)1 IllegalBlockSizeException (javax.crypto.IllegalBlockSizeException)1 NoSuchPaddingException (javax.crypto.NoSuchPaddingException)1