forked from dillenmeister/Trello.NET
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathAuthorizationTests.cs
136 lines (100 loc) · 3.63 KB
/
AuthorizationTests.cs
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
using System;
using NUnit.Framework;
namespace TrelloNet.Tests
{
[TestFixture]
public class AuthorizationTests : TrelloTestBase
{
[Test]
public void GetAuthorizationlUrl_ApplicationNameIsEmpty_Throw()
{
var trello = new Trello("key");
Assert.That(() => trello.GetAuthorizationUrl("", Scope.ReadOnly),
Throws.InstanceOf<ArgumentException>().With.Matches<ArgumentException>(e => e.ParamName == "applicationName"));
}
[Test]
public void GetAuthorizationlUrl_Always_ContainsKeyPassedInConstructor()
{
var trello = new Trello("123");
var url = trello.GetAuthorizationUrl("dummy", Scope.ReadOnly);
Assert.That(url.ToString(), Is.StringContaining("key=123"));
}
[Test]
public void GetAuthorizationlUrl_Always_ContainsApplicationName()
{
var trello = new Trello("dummy");
var url = trello.GetAuthorizationUrl("appname", Scope.ReadOnly);
Assert.That(url.ToString(), Is.StringContaining("name=appname"));
}
[Test]
public void GetAuthorizationlUrl_Always_ContainsResponseTypeToken()
{
var trello = new Trello("dummy");
var url = trello.GetAuthorizationUrl("dummy", Scope.ReadOnly);
Assert.That(url.ToString(), Is.StringContaining("response_type=token"));
}
[Test]
public void GetAuthorizationlUrl_ScopeReadonly_ContainsRead()
{
var trello = new Trello("dummy");
var url = trello.GetAuthorizationUrl("dummy", Scope.ReadOnly);
Assert.That(url.ToString(), Is.StringContaining("scope=read"));
Assert.That(url.ToString(), Is.Not.StringContaining("write"));
}
[Test]
public void GetAuthorizationlUrl_ScopeReadWrite_ContainsReadWrite()
{
var trello = new Trello("dummy");
var url = trello.GetAuthorizationUrl("dummy", Scope.ReadWrite);
Assert.That(url.ToString(), Is.StringContaining("scope=read,write"));
}
[Test]
public void GetAuthorizationlUrl_ScopeReadOnlyAccount_ContainsReadOnlyAccount()
{
var trello = new Trello("dummy");
var url = trello.GetAuthorizationUrl("dummy", Scope.ReadOnlyAccount);
Assert.That(url.ToString(), Is.StringContaining("scope=read,account"));
}
[Test]
public void GetAuthorizationlUrl_ScopeReadWriteAccount_ContainsReadWriteAccount()
{
var trello = new Trello("dummy");
var url = trello.GetAuthorizationUrl("dummy", Scope.ReadWriteAccount);
Assert.That(url.ToString(), Is.StringContaining("scope=read,write,account"));
}
[Test]
public void GetAuthorizationlUrl_DefaultExpiration_Contains30days()
{
var trello = new Trello("dummy");
var url = trello.GetAuthorizationUrl("dummy", Scope.ReadWrite);
Assert.That(url.ToString(), Is.StringContaining("expiration=30days"));
}
[Test]
public void GetAuthorizationlUrl_ExpirationNever_ContainsNever()
{
var trello = new Trello("dummy");
var url = trello.GetAuthorizationUrl("dummy", Scope.ReadWrite, Expiration.Never);
Assert.That(url.ToString(), Is.StringContaining("expiration=never"));
}
[Test]
public void GetAuthorizationlUrl_ExpirationOneHour_Contains1hour()
{
var trello = new Trello("dummy");
var url = trello.GetAuthorizationUrl("dummy", Scope.ReadWrite, Expiration.OneHour);
Assert.That(url.ToString(), Is.StringContaining("expiration=1hour"));
}
[Test]
public void GetAuthorizationlUrl_ExpirationOneHour_Contains1day()
{
var trello = new Trello("dummy");
var url = trello.GetAuthorizationUrl("dummy", Scope.ReadWrite, Expiration.OneDay);
Assert.That(url.ToString(), Is.StringContaining("expiration=1day"));
}
[Test]
public void Deauthorize_WhenCalled_DeauthorizesTrello()
{
_trelloReadOnly.Deauthorize();
Assert.That(() => _trelloReadOnly.Members.Me(), Throws.TypeOf<TrelloException>());
}
}
}