package com.offcn.api.nwn.process;

import io.restassured.response.Response;

import java.util.HashMap;

import com.offcn.TestUnti.RequestDataUtils;
import com.offcn.interfaces.API;
import com.offcn.process.NWN;



/**
 *获取encode
 * 
 * @author Lyy
 *
 */
public class logon extends NWN implements API {
	
	@Override
	public void initialize(HashMap<String, Object> data) {
	}

	@Override
	public HashMap<String, Object> handleInput(HashMap<String, Object> data) {
		return data;
	}

	@Override
	public Response SendRequest(HashMap<String, Object> data, String Url,
			String Request) {
//		postGet.HttpPostWithJson(nwn_url, "", "{\"admin_login_ssid\":"+admin_login_ssid+"}");
		String re = RequestDataUtils.Get_two_cookie_shop(data,"http://dianshang.t.eoffcn.com/p/user/logon","admin_login_ssid",admin_login_ssid,"go_session_id",go_session_id);
//		try {
//			Process p = Runtime.getRuntime().exec("python src/main/java/testTools/tools/python/login.py "+admin_login_ssid+" "+PHPSESSID+" "+nwn_url);
//		} catch (IOException e) {
//			// TODO Auto-generated catch block
//			e.printStackTrace();
//		}
     	System.out.println(re);
     
		return null;
	}

	@Override
	public String handleOutput(Response re, HashMap<String, Object> data) {
		
//		String body=re.asString();
////		InputStream input = new FileInputStream(file);  
//		StringBuffer buffer = new StringBuffer();  
//		
//		boolean result = true;  
//		String failReason = "";  
//		
//		if(body.contains("<title>")){
//			int Alength="<title>".length();
//			int start=body.indexOf("<title>");
//			int end=body.indexOf("</title>")+1;
//			body=body.substring(start+Alength, end-1);
//		}
////		http://zgadmin.test.eoffcn.com/sso/login.html?action=check_login&encode=f086da4a32899a75e07a83476de9035f%3AiYF9fPjJbhmmEDswMBNi3KO3%2FsPCu1JSYyet723Xays%2FrXdnPRskyrutMZvbMlG0yiAjI1ibhfZtTotQsZf6VA%3D%3D&app_id=31&ref=http://nwn.t.eoffcn.com/admin/package/packagelist
////	    http://nwn.t.eoffcn.comhttp://zgadmin.test.eoffcn.com/sso/login.html?action=check_login&encode=f086da4a32899a75e07a83476de9035f%3AiYF9fPjJbhmmEDswMBNi3KO3%2FsPCu1JSYyet723Xays%2FrXdnPRskyrutMZvbMlG0yiAjI1ibhfZtTotQsZf6VA%3D%3D&app_id=31&ref=http://nwn.t.eoffcn.com/admin/package/packagelist
//	
//		if(data.get("custom") != null && body!=null){
//			if(!(body.equals(data.get("custom")))){
//				result = result && false;
//				failReason = failReason + "custom is expected "
//						+ data.get("custom").toString() + " but actually "
//						+ body + ".";
////				admin_login_ssid=re.getCookie("admin_login_ssid");
//				admin_31_encode=re.getCookie("admin_31_encode");
//			}else{
//				
//				System.out.println(re.asString());
//
//			}
//		}
//			
			
			return "Pass";
	

}}
