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 PrivacyTest
\r
24 public static void Initialize(TestContext context)
\r
26 SnifferTest.Initialize(context);
\r
30 public void RemoveToken()
\r
32 const string request = "api%5Fverno=1&api%5Ftoken=0123456abcdef&api%5Fport=0123456789";
\r
33 PAssert.That(() => RemoveToken(request) == "api%5Fverno=1&api%5Fport=0123456789", "トークンが中間");
\r
34 const string request2 = "api%5Fverno=1&api%5Ftoken=0123456abcdef";
\r
35 PAssert.That(() => RemoveToken(request2) == @"api%5Fverno=1", "トークンが末尾");
\r
36 const string request3 = "api%5Ftoken=0123456abcdef&api%5Fverno=1";
\r
37 PAssert.That(() => RemoveToken(request3) == @"api%5Fverno=1", "トークンが先頭");
\r
38 const string request4 = "api%5Ftoken=0123456abcdef";
\r
39 PAssert.That(() => RemoveToken(request4) == "", "トークン単独");
\r
40 const string request5 = "api%5Fbtime=83026279&api%5Ftoken=0123456abcdef&api%5Fverno=1";
\r
41 PAssert.That(() => RemoveToken(request5) == "api%5Fverno=1", "戦闘APIの時刻印を削除");
\r
48 public void RemoveToken2()
\r
50 var request = "api_verno=1&api_token=0123456abcdef&api_port=0123456789";
\r
51 PAssert.That(() => RemoveToken(request) == "api_verno=1&api_port=0123456789", "トークンが中間");
\r
52 var request5 = "api_btime=83026279&api_token=0123456abcdef&api_verno=1";
\r
53 PAssert.That(() => RemoveToken(request5) == "api_verno=1", "戦闘APIの時刻印を削除");
\r
57 public void RemoveName()
\r
59 const string response1 =
\r
60 @"{""api_result"":1,""api_result_msg"":""成功"",""api_data"":{""api_basic"":{""api_member_id"":""123456""," +
\r
61 @"""api_nickname"":""ぱんなこった"",""api_nickname_id"":""12345678"",""api_active_flag"":1}}}";
\r
62 const string result1 =
\r
63 @"{""api_result"":1,""api_result_msg"":""成功"",""api_data"":{""api_basic"":{""api_active_flag"":1}}}";
\r
64 PAssert.That(() => RemoveName(response1) == result1);
\r
65 const string response2 =
\r
66 @"{""api_deck_data"":[{""api_member_id"":123456,""api_id"":1,""api_name"":""第一艦隊"",""api_name_id"":""123456"",""api_mission"":[0,0,0,0],""api_flagship"":""0""}]}";
\r
67 const string result2 =
\r
68 @"{""api_deck_data"":[{""api_id"":1,""api_mission"":[0,0,0,0],""api_flagship"":""0""}]}";
\r
69 PAssert.That(() => RemoveName(response2) == result2);
\r
70 const string response3 =
\r
71 @"{""api_deck_data"":[{""api_member_id"":123456,""api_id"":1,""api_name"":""第\\/一艦\\""隊\\"""",""api_name_id"":""123456"",""api_mission"":[0,0,0,0],""api_flagship"":""0""}]}";
\r
72 PAssert.That(() => RemoveName(response3) == result2);
\r
75 private string RemoveToken(string query)
\r
77 var s = new Main.Session(query, null, null);
\r
82 private string RemoveName(string response)
\r
84 var s = new Main.Session(null, null, response);
\r