forked from ServiceStack/ServiceStack
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathAuthWebTests.cs
More file actions
50 lines (41 loc) · 1.42 KB
/
AuthWebTests.cs
File metadata and controls
50 lines (41 loc) · 1.42 KB
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
using System.Collections.Generic;
using System.Net;
using NUnit.Framework;
using ServiceStack.Text;
namespace ServiceStack.AuthWeb.Tests
{
[TestFixture]
public class AuthWebTests
{
public const string BaseUri = "http://localhost:11001/";
[Test]
public void Can_authenticate_with_WindowsAuth()
{
var client = new JsonServiceClient(BaseUri);
var response = client.Get(new RequiresAuth { Name = "Haz Access!" });
Assert.That(response.Name, Is.EqualTo("Haz Access!"));
}
[Test]
public void Can_authenticate_with_DefaultCredentials()
{
var client = new JsonServiceClient(BaseUri)
{
Credentials = CredentialCache.DefaultCredentials,
//Credentials = new NetworkCredential("mythz", "invalid", "macbook")
};
var response = client.Get(new RequiresAuth { Name = "Haz Access!" });
Assert.That(response.Name, Is.EqualTo("Haz Access!"));
}
[Test]
public void Can_Authenticate_with_Metadata()
{
var client = new JsonServiceClient(BaseUri);
var response = client.Send(new Authenticate
{
UserName = "demis.bellot@gmail.com",
Password = "test",
Meta = new Dictionary<string, string> { { "custom", "metadata" } }
});
}
}
}