Skip to content

Commit

Permalink
Merge commit '93bbda2962beff1052407aa8f33d16c5ecbf3632' into stable
Browse files Browse the repository at this point in the history
Conflicts:
	Rainy/RainyStandaloneServer.cs
  • Loading branch information
Dynalon committed Nov 4, 2013
2 parents 0986987 + 93bbda2 commit 63b6390
Show file tree
Hide file tree
Showing 168 changed files with 26,876 additions and 1,223 deletions.
4 changes: 3 additions & 1 deletion .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,9 @@ test-results/
Rainy/obj/
Rainy-tests/obj/
*.zip

docs/reference
# nuget packages
packages/

# release folders
rainy-?.??
4 changes: 4 additions & 0 deletions .gitmodules
Original file line number Diff line number Diff line change
Expand Up @@ -4,3 +4,7 @@
[submodule "JsonConfig"]
path = JsonConfig
url = https:/Dynalon/JsonConfig.git
[submodule "tomboy-library-websync"]
path = tomboy-library-websync
url = https:/Dynalon/tomboy-library-websync.git

1,781 changes: 1,781 additions & 0 deletions Doxyfile

Large diffs are not rendered by default.

39 changes: 26 additions & 13 deletions Makefile
Original file line number Diff line number Diff line change
@@ -1,8 +1,7 @@
RELEASEVER=0.2.3
RELEASEVER=0.5.0
ZIPDIR=rainy-$(RELEASEVER)
BINDIR=$(shell pwd)/Rainy/bin/Debug
RELEASEDIR=$(shell pwd)/release
TMPDIR=$(shell pwd)/.tmp

MONO=$(shell which mono)
XBUILD=$(shell which xbuild)
Expand All @@ -12,7 +11,10 @@ MKBUNDLE=$(shell which mkbundle)

UNPACKED_EXE=$(BINDIR)/Rainy.exe
PACKED_EXE=Rainy.exe
MIN_MONO_VERSION=2.10.9

# Note this is the min version for building from source; running might work
# on older mono versions
MIN_MONO_VERSION=3.0.0

pack: build
@cp Rainy/settings.conf $(RELEASEDIR)/settings.conf
Expand All @@ -34,17 +36,29 @@ pack: build
@echo ""
@echo ""

build:
## this is not working?
##pkg-config --atleast-version=$(MIN_MONO_VERSION) mono; if [ $$? != "0" ]; then $(error "mono >=2.10.9 is required");

checkout:
ifndef TEAMCITY
# Fetching Rainy's submodules
@git submodule init
@git submodule update
@git submodule update --init --recursive
endif

deps:
# if the next steps fails telling about security authentication, make sure
# you have imported trusted ssl CA certs with this command and re-run:
#
# mozroots --import --sync
#

@mono tools/NuGet.exe install -o packages Rainy/packages.config
@mono tools/NuGet.exe install -o packages Rainy-tests/packages.config
@mono tools/NuGet.exe install -o packages tomboy-library-websync/packages.config
@echo "Successfully fetched dependencies."

build: checkout deps

## this is not working?
##pkg-config --atleast-version=$(MIN_MONO_VERSION) mono; if [ $$? != "0" ]; then $(error "mono >=$MIN_MONO_VERSION is required");

# Fetching tomboy-library's submodules
@cd tomboy-library/ && git submodule init && git submodule update && cd ..

$(XBUILD) $(XBUILD_ARGS) Rainy.sln

release: clean pack
Expand All @@ -62,7 +76,6 @@ clean:
rm -rf Rainy/obj/*
rm -rf $(ZIPDIR)
rm -rf $(ZIPDIR).zip
rm -rf $(TMPDIR)
rm -rf $(BINDIR)/*
rm -rf $(RELEASEDIR)/*.exe
rm -rf $(RELEASEDIR)/*.mdb
Expand Down
192 changes: 192 additions & 0 deletions Rainy-tests/Admin/TestUserManagement.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,192 @@
using System;
using System.Collections.Generic;
using System.Linq;
using NUnit.Framework;
using Rainy.UserManagement;
using Rainy.WebService.Management;
using ServiceStack.ServiceClient.Web;
using Rainy.Tests.Db;

namespace Rainy.Tests.RestApi.Management
{
[TestFixture()]
public class TestUserManagement : DbTestsBase
{
protected JsonServiceClient adminClient;
protected DTOUser[] GetSampleUser ()
{
var user = new List<DTOUser> ();

user.Add (new DTOUser () {
Username = "johndoe",
Password = "none",
EmailAddress = "[email protected]",
FirstName = "John",
LastName = "Doe",
AdditionalData = ""
});
user.Add (new DTOUser () {
Username = "janedoe",
Password = "none",
EmailAddress = "[email protected]",
FirstName = "Jane",
LastName = "Doe",
AdditionalData = "Jane, John's wife"
});

return user.ToArray<DTOUser> ();
}

[SetUp]
public new void SetUp ()
{
adminClient = GetAdminServiceClient ();

// add some sample users to the server
var client = GetAdminServiceClient ();
var url = new UserRequest ().ToUrl("POST");
foreach (DTOUser user in GetSampleUser ()) {
client.Post<UserRequest> (url, user);
}
}

[Test]
[ExpectedException(typeof(WebServiceException),ExpectedMessage="Unauthorized.")]
public void UnauthorizedAccessFails ()
{
var alluser_url = new AllUserRequest ().ToUrl("GET");
var client = GetServiceClient ();
try {
client.Get<DTOUser[]> (alluser_url);
} catch (WebServiceException e) {
Assert.AreEqual (401, e.StatusCode);
throw e;
}
}

[Test]
public void AddNewUser ()
{
var user = new DTOUser ();
user.Username = "michael";
user.EmailAddress = "[email protected]";
user.Password = "none";
user.AdditionalData = "Some more info about Michael";

var user_url = new UserRequest ().ToUrl("POST");
adminClient.Post<UserRequest> (user_url, user);

var user_get_url = new UserRequest () { Username = "michael" }.ToUrl("GET");
var resp = adminClient.Get<DTOUser[]> (user_get_url);

Assert.AreEqual (1, resp.Length);
Assert.AreEqual (user.Username, resp[0].Username);
Assert.AreEqual (user.EmailAddress, resp[0].EmailAddress);
Assert.AreEqual (user.AdditionalData, resp[0].AdditionalData);

}

[Test]
[ExpectedException(typeof(WebServiceException))]
public void AddNewUserWithEmptyPasswordFails ()
{
var user = new DTOUser ();
user.Username = "michael";
user.EmailAddress = "[email protected]";
user.Password = "";
user.AdditionalData = "Some more info about Michael";

var user_url = new UserRequest ().ToUrl("POST");
try {
adminClient.Post<UserRequest> (user_url, user);
} catch (WebServiceException e) {
Assert.AreEqual (400, e.StatusCode);
throw e;
}
}

[Test]
public void ChangeUserPassword ()
{
var user = new DTOUser ();
user.Username = "michael";
user.EmailAddress = "[email protected]";
user.Password = "thisissecret";
user.AdditionalData = "Some more info about Michael";

var user_url = new UserRequest ().ToUrl("POST");
adminClient.Post<UserRequest> (user_url, user);

user.Password = "thisismynewpassword";
var update_url = new UserRequest ().ToUrl ("PUT");
adminClient.Put<UserRequest> (update_url, user);

// authorization with the old password fails for the user
Assert.Fail ("TODO: Password changing not possible with encryption");

// TODO: authorization with the new password works
}

[Test]
public void DeleteUser ()
{
var user_delete_url = new UserRequest () { Username = "johndoe" }.ToUrl ("DELETE");
adminClient.Delete<UserRequest> (user_delete_url);

// make sure johndoe is not in the list of our users
var alluser_url = new AllUserRequest ().ToUrl ("GET");
var allusers = adminClient.Get<DTOUser[]> (alluser_url);

var list_of_johndoes = allusers.Where(u => u.Username == "johndoe").ToArray ();
Assert.AreEqual (0, list_of_johndoes.Count ());
}

[Test]
public void DeleteUserDeletesAllData ()
{
Assert.Fail ("TODO: implement me");
}

[Test]
public void UpdateUser ()
{
var user = new DTOUser () {
Username = "johndoe",
Password = "abc123",
EmailAddress = "[email protected]",
AdditionalData = "some text",
FirstName = "Jane",
LastName = "Doeson"
};

var user_url = new UserRequest ().ToUrl ("PUT");
adminClient.Put<UserRequest> (user_url, user);

var all_users_url = new AllUserRequest ().ToUrl ("GET");
var all_users = adminClient.Get<DTOUser[]> (all_users_url);

var johndoe = all_users.First (u => u.Username == "johndoe");
Assert.AreEqual (user.Username, johndoe.Username);
//password is not returned
Assert.AreEqual (string.Empty, johndoe.Password);
Assert.AreEqual (user.EmailAddress, johndoe.EmailAddress);
Assert.AreEqual (user.AdditionalData, johndoe.AdditionalData);
Assert.AreEqual (user.FirstName, johndoe.FirstName);
Assert.AreEqual (user.LastName, johndoe.LastName);

}


[Test]
[ExpectedException (typeof(WebServiceException))]
public void UpdateUserForUnknownUsername ()
{
var user = new DTOUser () {
Username = "foobar"
};
var user_url = new UserRequest ().ToUrl ("PUT");
adminClient.Put<DTOUser> (user_url, user);
}
}
}

Loading

0 comments on commit 63b6390

Please sign in to comment.