Skip to content
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
110 changes: 89 additions & 21 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,6 +1,67 @@
## Welcome to the port of JabbR to ASP.NET Core
---
This is an open source, cross platform version of David Fowler's [JabbR](https://github.com/JabbR/JabbR) running on .NET Core.
This is an open source, cross platform version of David Fowler's [JabbR](https://github.com/JabbR/JabbR) running on .NET Core.

Further documentation below on
[setting up for local development](#setting-up-for-local-development),
[accessing stored user secrets](#how-to-access-your-stored-user-secrets),
[configuring social authentication](#configuring-social-authentication), and
[testing](#testing).

## Features and commands
JabbR is a chat application similar to IRC, built with ASP.NET Core, using SignalR and Entity Framework.

#### Commands
Below is a list of commands to use while chatting.

Join and leave a room.
```
/join [roomName]
To join a private room /join [roomName] [inviteCode]
/leave [roomName]
```
Find users.
```
Type /who without parameters to list who's in the room.
/who [userName]
/where [userName]
```
Set a status. Use Afk to set your away message.
```
Type /note "Status message" to set your status message, and /note to clear it.
/afk "Away message"
/flag [countryAbreviation] to set your country.
```
Personalize your room.
```
/topic "Set the topic"
/welcome "Set the welcome command"
```
Make a meme!
```
/meme [memeName] "top-text" "bottom-text"
The top and bottom text is optional, make sure any space between words is denoted with a dash.
```
If you ever get lost,
```
Type /? - to show the full list of JabbR Commands
```

#### Content Provider Support
Inline image and content support for your favorite sites:
- BBC News
- Dictionary.com
- GitHub (issues and comments)
- Imgur
- Nerd Dinner
- Slideshare
- Soundcloud
- Spotify
- Twitter
- Xkcd
- Youtube
- 9gag


## Setting up for Local Development
For security, connection strings and other sensitive information must be stored in environment variables.
Expand All @@ -27,7 +88,7 @@ No executable found matching command "dotnet-user-secrets"
To set a user secret, you need to use `dotnet user-secrets set <key> <value>`, like so

```bash
$ dotnet user-secrets set "connectionString" "Server=MYAPPNAME.database.windows.net,1433;Initial Catalog=MYCATALOG;Persist Security Info=False;User ID={plaintext user};Password={plaintext password};MultipleActiveResultSets=False;Encrypt=True;TrustServerCertificate=False;Connection Timeout=30;"
$ dotnet user-secrets set "connectionString" "Server=MYAPPNAME.database.windows.net,1433;Initial Catalog=MYCATALOG;Persist Security Info=False;User ID={plaintext user};Password={plaintext password};MultipleActiveResultSets=True;Encrypt=True;TrustServerCertificate=False;Connection Timeout=30;"
```

Alternatively, if you want to use [LocalDB, an alternative built in database](https://blogs.msdn.microsoft.com/sqlexpress/2011/07/12/introducing-localdb-an-improved-sql-express/), you
Expand Down Expand Up @@ -83,7 +144,7 @@ We've used the structure of a connection string hosted on Azure, but **you will
## Configuring Social Authentication

If you want your users to have the option to autenticate via external providers such as Facebook, Google, Twitter and Microsoft
you will need to obtain API keys from these providers and configure them as user secrets. We will use Facebook as an example.
you will need to obtain API keys from these providers and configure them as user secrets.

Find out how to obtain API keys [here.](https://docs.asp.net/en/latest/security/authentication/sociallogins.html)

Expand All @@ -94,23 +155,6 @@ $ dotnet user-secrets set "Authentication:<ProviderName>:AppId" "<AppId>"
$ dotnet user-secrets set "Authentication:<ProviderName>:AppSecret" "<AppSecret>"
```

Then enable the middleware for each provider by installing the proper NuGet package `Microsoft.AspNetCore.Authentication.<ProviderName>`.

Lastly, configure the options for each provider in your Configure() method of Startup.cs as shown below.

```csharp
var facebookAppId = _configuration["Authentication:Facebook:AppId"];
var facebookAppSecret = _configuration["Authentication:Facebook:AppSecret"];
if (!string.IsNullOrEmpty(facebookAppId) && !string.IsNullOrEmpty(facebookAppSecret))
{
app.UseFacebookAuthentication(new FacebookOptions()
{
AppId = facebookAppId,
AppSecret = facebookAppSecret
});
}
```

## NOTE

- You **need** to replace the above connection string with your own.
Expand All @@ -119,4 +163,28 @@ if (!string.IsNullOrEmpty(facebookAppId) && !string.IsNullOrEmpty(facebookAppSec
*"Help, I can't find my connection string!"*
[No problem, read more about Azure DB's and connections here](https://azure.microsoft.com/en-us/documentation/articles/sql-database-develop-dotnet-simple/)

[Learn more about safe storage of user secrets in .NET](https://docs.asp.net/en/latest/fundamentals/configuration.html)
[Learn more about safe storage of user secrets in .NET](https://docs.asp.net/en/latest/fundamentals/configuration.html)

## Testing

### To Run

You can run the written tests from either Visual Studio or your Console.

#### From the Console
In order to run the written tests, you must open a command prompt or PowerShell command window. In the window, navigate to folder containing the source code of your test project (this will be in test\JabbR-Core.Tests).
To run the .NET CLI test runner, type `dotnet test` and press enter. It should run the tests and print out if there were any that had errors, skipped, or failed, along with where they might have failed.

#### From Visual Studio
Show the Test Explorer window by choosing **Test > Windows > Test Explorer**. The Test Explorer window will show inside Visual Studio, and your tests should be visible (if they're not, try building your project to kick off the test discovery process).
If you click the Run All link in the Test Explorer window, it will run your tests and show you successes and failurees. You can click on an individual test result to get failure information as well as stack trace information.

### To Write

We used xUnit to write our tests. A verbose guide on writing tests for .Net Core with xUnit can be found
[here](https://xunit.github.io/docs/getting-started-dotnet-core.html).
Basically:
- A reference to xUnit is already in the project.json of the JabbR-Core.Tests library.
- Make sure your class has a using statement for xUnit. (`using Xunit;`)
- Tests should use the `[Fact]` tag and always have an assertion statement.
- You can also write Theories, which are tests that are true for a particular set of data.