2  * Copyright 2016 Huawei Technologies Co., Ltd.
 
   4  * Licensed under the Apache License, Version 2.0 (the "License");
 
   5  * you may not use this file except in compliance with the License.
 
   6  * You may obtain a copy of the License at
 
   8  *     http://www.apache.org/licenses/LICENSE-2.0
 
  10  * Unless required by applicable law or agreed to in writing, software
 
  11  * distributed under the License is distributed on an "AS IS" BASIS,
 
  12  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 
  13  * See the License for the specific language governing permissions and
 
  14  * limitations under the License.
 
  17 package org.onap.vfc.nfvo.vnfm.svnfm.vnfmadapter.service.process;
 
  19 import static org.junit.Assert.assertEquals;
 
  21 import org.junit.Test;
 
  22 import org.onap.vfc.nfvo.vnfm.svnfm.vnfmadapter.common.restclient.RestfulResponse;
 
  23 import org.onap.vfc.nfvo.vnfm.svnfm.vnfmadapter.common.servicetoken.VnfmRestfulUtil;
 
  24 import org.onap.vfc.nfvo.vnfm.svnfm.vnfmadapter.service.constant.Constant;
 
  28 import net.sf.json.JSONObject;
 
  30 public class AuthMgrTest {
 
  33     public void testAuthTokenByDomainNameByJSONException() {
 
  34         AuthMgr authMgr = new AuthMgr();
 
  35         String data = "{\"auth\":{}}";
 
  36         JSONObject params = JSONObject.fromObject(data);
 
  38         JSONObject result = authMgr.authToken(params);
 
  40         JSONObject restJson = new JSONObject();
 
  41         restJson.put("retCode", Constant.REST_FAIL);
 
  42         restJson.put("data", "JSONException");
 
  43         assertEquals(restJson, result);
 
  47     public void testAuthToken() {
 
  48 //        new MockUp<VnfmRestfulUtil>() {
 
  51 //            public RestfulResponse getRestResByDefault(String auth, String method, JSONObject authParams) {
 
  52 //                RestfulResponse response = null;
 
  57         AuthMgr authMgr = new AuthMgr();
 
  58         String data = "{\"auth\":{\"identity\":{\"password\":{\"user\":{\"name\":\"om_team\",\"password\":\"123\"}}}}}";
 
  59         JSONObject params = JSONObject.fromObject(data);
 
  61         JSONObject result = authMgr.authToken(params);
 
  62         assertEquals(Constant.REST_FAIL, result.getInt("retCode"));