1 // Copyright (C) 2017 Kazuhiro Fujieda <fujieda@users.osdn.me>
\r
3 // Licensed under the Apache License, Version 2.0 (the "License");
\r
4 // you may not use this file except in compliance with the License.
\r
5 // You may obtain a copy of the License at
\r
7 // http://www.apache.org/licenses/LICENSE-2.0
\r
9 // Unless required by applicable law or agreed to in writing, software
\r
10 // distributed under the License is distributed on an "AS IS" BASIS,
\r
11 // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
\r
12 // See the License for the specific language governing permissions and
\r
13 // limitations under the License.
\r
15 using ExpressionToCodeLib;
\r
16 using Microsoft.VisualStudio.TestTools.UnitTesting;
\r
18 namespace KancolleSniffer.Test
\r
21 public class ErrorLogTest
\r
24 public void RemoveTokenFromRequest()
\r
27 "api%5Fverno=1&api%5Ftoken=0123456abcdef&api%5Fport=0123456789";
\r
29 ErrorLog.RemoveUnwantedInformation(ref request, ref response);
\r
30 PAssert.That(() => request == "api%5Fverno=1&api%5Fport=0123456789", "トークンが中間");
\r
31 var request2 = "api%5Fverno=1&api%5Ftoken=0123456abcdef";
\r
32 ErrorLog.RemoveUnwantedInformation(ref request2, ref response);
\r
33 PAssert.That(() => request2 == @"api%5Fverno=1", "トークンが末尾");
\r
34 var request3 = "api%5Ftoken=0123456abcdef&api%5Fverno=1";
\r
35 ErrorLog.RemoveUnwantedInformation(ref request3, ref response);
\r
36 PAssert.That(() => request3 == @"api%5Fverno=1", "トークンが先頭");
\r
37 var request4 = "api%5Ftoken=0123456abcdef";
\r
38 ErrorLog.RemoveUnwantedInformation(ref request4, ref response);
\r
39 PAssert.That(() => request4 == "", "トークン単独");
\r
43 public void RemoveUnwantedInformationFromResponse()
\r
46 var response = @"{""api_result"":1,""api_result_msg"":""成功"",""api_data"":" +
\r
47 @"{""api_basic"":{""api_member_id"":""123456""," +
\r
48 @"""api_nickname"":""ぱんなこった"",""api_nickname_id"":""12345678"",""api_active_flag"":1}}}";
\r
49 ErrorLog.RemoveUnwantedInformation(ref request, ref response);
\r
50 PAssert.That(() => response ==
\r
51 @"{""api_result"":1,""api_result_msg"":""成功"",""api_data"":" +
\r
52 @"{""api_basic"":{""api_active_flag"":1}}}");
\r