-
Notifications
You must be signed in to change notification settings - Fork 76
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #275 from opentween/api-connection
ITwitterCredentialとアクセス手段ごとの具象クラスを追加
- Loading branch information
Showing
18 changed files
with
448 additions
and
258 deletions.
There are no files selected for viewing
Large diffs are not rendered by default.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,47 @@ | ||
// OpenTween - Client of Twitter | ||
// Copyright (c) 2023 kim_upsilon (@kim_upsilon) <https://upsilo.net/~upsilon/> | ||
// All rights reserved. | ||
// | ||
// This file is part of OpenTween. | ||
// | ||
// This program is free software; you can redistribute it and/or modify it | ||
// under the terms of the GNU General Public License as published by the Free | ||
// Software Foundation; either version 3 of the License, or (at your option) | ||
// any later version. | ||
// | ||
// This program is distributed in the hope that it will be useful, but | ||
// WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY | ||
// or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License | ||
// for more details. | ||
// | ||
// You should have received a copy of the GNU General Public License along | ||
// with this program. If not, see <http://www.gnu.org/licenses/>, or write to | ||
// the Free Software Foundation, Inc., 51 Franklin Street - Fifth Floor, | ||
// Boston, MA 02110-1301, USA. | ||
|
||
using System.Net.Http; | ||
using Xunit; | ||
|
||
namespace OpenTween.Connection | ||
{ | ||
public class TwitterCredentialCookieTest | ||
{ | ||
[Fact] | ||
public void CreateHttpHandler_Test() | ||
{ | ||
var appToken = new TwitterAppToken | ||
{ | ||
AuthType = APIAuthType.TwitterComCookie, | ||
TwitterComCookie = "aaa=bbb", | ||
}; | ||
var credential = new TwitterCredentialCookie(appToken); | ||
|
||
using var innerHandler = new HttpClientHandler(); | ||
using var handler = credential.CreateHttpHandler(innerHandler); | ||
|
||
var cookieHandler = Assert.IsType<TwitterComCookieHandler>(handler); | ||
Assert.Equal("aaa=bbb", cookieHandler.RawCookie); | ||
Assert.Same(innerHandler, cookieHandler.InnerHandler); | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,51 @@ | ||
// OpenTween - Client of Twitter | ||
// Copyright (c) 2023 kim_upsilon (@kim_upsilon) <https://upsilo.net/~upsilon/> | ||
// All rights reserved. | ||
// | ||
// This file is part of OpenTween. | ||
// | ||
// This program is free software; you can redistribute it and/or modify it | ||
// under the terms of the GNU General Public License as published by the Free | ||
// Software Foundation; either version 3 of the License, or (at your option) | ||
// any later version. | ||
// | ||
// This program is distributed in the hope that it will be useful, but | ||
// WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY | ||
// or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License | ||
// for more details. | ||
// | ||
// You should have received a copy of the GNU General Public License along | ||
// with this program. If not, see <http://www.gnu.org/licenses/>, or write to | ||
// the Free Software Foundation, Inc., 51 Franklin Street - Fifth Floor, | ||
// Boston, MA 02110-1301, USA. | ||
|
||
using System.Net.Http; | ||
using Xunit; | ||
|
||
namespace OpenTween.Connection | ||
{ | ||
public class TwitterCredentialOAuth1Test | ||
{ | ||
[Fact] | ||
public void CreateHttpHandler_Test() | ||
{ | ||
var appToken = new TwitterAppToken | ||
{ | ||
AuthType = APIAuthType.OAuth1, | ||
OAuth1CustomConsumerKey = ApiKey.Create("consumer_key"), | ||
OAuth1CustomConsumerSecret = ApiKey.Create("consumer_secret"), | ||
}; | ||
var credential = new TwitterCredentialOAuth1(appToken, "access_token", "access_secret"); | ||
|
||
using var innerHandler = new HttpClientHandler(); | ||
using var handler = credential.CreateHttpHandler(innerHandler); | ||
|
||
var oauthHandler = Assert.IsType<OAuthHandler>(handler); | ||
Assert.Equal("consumer_key", oauthHandler.ConsumerKey.Value); | ||
Assert.Equal("consumer_secret", oauthHandler.ConsumerSecret.Value); | ||
Assert.Equal("access_token", oauthHandler.AccessToken); | ||
Assert.Equal("access_secret", oauthHandler.AccessSecret); | ||
Assert.Same(innerHandler, oauthHandler.InnerHandler); | ||
} | ||
} | ||
} |
Oops, something went wrong.