File tree Expand file tree Collapse file tree 2 files changed +47
-5
lines changed
Test/Notion.IntegrationTests Expand file tree Collapse file tree 2 files changed +47
-5
lines changed Original file line number Diff line number Diff line change 1+ using System . Threading . Tasks ;
2+ using Notion . Client ;
3+ using Xunit ;
4+
5+ namespace Notion . IntegrationTests ;
6+
7+ public class AuthenticationTests : IntegrationTestBase
8+ {
9+ private readonly string _clientId = GetEnvironmentVariableRequired ( "NOTION_CLIENT_ID" ) ;
10+ private readonly string _clientSecret = GetEnvironmentVariableRequired ( "NOTION_CLIENT_SECRET" ) ;
11+
12+ [ Fact ]
13+ public async Task Create_and_revoke_token ( )
14+ {
15+ // Arrange
16+ var createRequest = new CreateTokenRequest
17+ {
18+ Code = "03b3bd2d-6b96-4104-a9f4-ee04d881532c" ,
19+ ClientId = _clientId ,
20+ ClientSecret = _clientSecret ,
21+ RedirectUri = "https://localhost:5001" ,
22+ } ;
23+
24+ // Act
25+ var response = await Client . AuthenticationClient . CreateTokenAsync ( createRequest ) ;
26+
27+ // Assert
28+ Assert . NotNull ( response ) ;
29+ Assert . NotNull ( response . AccessToken ) ;
30+
31+ // revoke token
32+ await Client . AuthenticationClient . RevokeTokenAsync ( new RevokeTokenRequest
33+ {
34+ Token = response . AccessToken ,
35+ ClientId = _clientId ,
36+ ClientSecret = _clientSecret
37+ } ) ;
38+ }
39+ }
Original file line number Diff line number Diff line change @@ -15,10 +15,13 @@ protected IntegrationTestBase()
1515
1616 Client = NotionClientFactory . Create ( options ) ;
1717
18- ParentPageId = Environment . GetEnvironmentVariable ( "NOTION_PARENT_PAGE_ID" )
19- ?? throw new InvalidOperationException ( "Parent page id is required." ) ;
20-
21- ParentDatabaseId = Environment . GetEnvironmentVariable ( "NOTION_PARENT_DATABASE_ID" )
22- ?? throw new InvalidOperationException ( "Parent database id is required." ) ;
18+ ParentPageId = GetEnvironmentVariableRequired ( "NOTION_PARENT_PAGE_ID" ) ;
19+ ParentDatabaseId = GetEnvironmentVariableRequired ( "NOTION_PARENT_DATABASE_ID" ) ;
20+ }
21+
22+ protected static string GetEnvironmentVariableRequired ( string envName )
23+ {
24+ return Environment . GetEnvironmentVariable ( envName ) ??
25+ throw new InvalidOperationException ( $ "Environment variable '{ envName } ' is required.") ;
2326 }
2427}
You can’t perform that action at this time.
0 commit comments