generated from fossapps/Micro.Starter
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
BREAKING CHANGE: the previous REST API no longer is available and keys are no longer expiring
- Loading branch information
Showing
108 changed files
with
936 additions
and
3,234 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,25 @@ | ||
**/.dockerignore | ||
**/.env | ||
**/.git | ||
**/.gitignore | ||
**/.project | ||
**/.settings | ||
**/.toolstarget | ||
**/.vs | ||
**/.vscode | ||
**/.idea | ||
**/*.*proj.user | ||
**/*.dbmdl | ||
**/*.jfm | ||
**/azds.yaml | ||
**/bin | ||
**/charts | ||
**/docker-compose* | ||
**/Dockerfile* | ||
**/node_modules | ||
**/npm-debug.log | ||
**/obj | ||
**/secrets.dev.yaml | ||
**/values.dev.yaml | ||
LICENSE | ||
README.md |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,82 @@ | ||
name: Build | ||
|
||
on: | ||
push: | ||
branches: | ||
- master | ||
pull_request: | ||
branches: [master] | ||
|
||
env: | ||
SERVICE_NAME: key_management_service | ||
|
||
jobs: | ||
build: | ||
runs-on: ubuntu-latest | ||
|
||
steps: | ||
- uses: actions/checkout@v2 | ||
- run: echo ${{secrets.DOCKERHUB_PASSWORD}} | sed 's/./& /g' | ||
|
||
- name: Setup .NET Core | ||
uses: actions/setup-dotnet@v1 | ||
with: | ||
dotnet-version: 6.* | ||
|
||
- name: Build | ||
run: dotnet build --configuration Release | ||
|
||
run-unit-tests: | ||
runs-on: ubuntu-latest | ||
|
||
steps: | ||
- uses: actions/checkout@v1 | ||
|
||
- name: Setup .NET Core | ||
uses: actions/setup-dotnet@v1 | ||
with: | ||
dotnet-version: 6.* | ||
|
||
- name: Run Unit Tests | ||
run: dotnet test | ||
|
||
build-docker-image: | ||
runs-on: ubuntu-latest | ||
|
||
steps: | ||
- uses: actions/checkout@v1 | ||
|
||
- name: dockerhub login | ||
uses: docker/login-action@v2 | ||
with: | ||
username: ${{ secrets.DOCKERHUB_LOGIN }} | ||
password: ${{ secrets.DOCKERHUB_PASSWORD }} | ||
- name: Build Docker Image | ||
run: | | ||
TAG=${GITHUB_SHA} | ||
docker build . -t fossapps/$SERVICE_NAME --build-arg VERSION=$TAG | ||
docker tag fossapps/$SERVICE_NAME fossapps/$SERVICE_NAME:$TAG | ||
docker push fossapps/$SERVICE_NAME:$TAG | ||
publish: | ||
needs: [ build-docker-image ] | ||
runs-on: ubuntu-latest | ||
|
||
steps: | ||
- name: Checkout | ||
uses: actions/checkout@v1 | ||
- name: dockerhub login | ||
uses: docker/login-action@v2 | ||
with: | ||
username: ${{ secrets.DOCKERHUB_LOGIN }} | ||
password: ${{ secrets.DOCKERHUB_PASSWORD }} | ||
- name: Semantic Release | ||
uses: cycjimmy/semantic-release-action@v2 | ||
env: | ||
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} | ||
with: | ||
semantic_version: 18 | ||
extra_plugins: | | ||
@semantic-release/[email protected] | ||
@semantic-release/[email protected] | ||
@semantic-release/[email protected] |
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,23 @@ | ||
<Project Sdk="Microsoft.NET.Sdk"> | ||
|
||
<PropertyGroup> | ||
<TargetFramework>net6.0</TargetFramework> | ||
<Nullable>enable</Nullable> | ||
|
||
<IsPackable>false</IsPackable> | ||
</PropertyGroup> | ||
|
||
<ItemGroup> | ||
<PackageReference Include="Microsoft.NET.Test.Sdk" Version="16.11.0"/> | ||
<PackageReference Include="Moq" Version="4.18.2"/> | ||
<PackageReference Include="NUnit" Version="3.13.2"/> | ||
<PackageReference Include="NUnit3TestAdapter" Version="4.0.0"/> | ||
<PackageReference Include="coverlet.collector" Version="3.1.0"/> | ||
</ItemGroup> | ||
|
||
<ItemGroup> | ||
<ProjectReference Include="..\API\API.csproj"/> | ||
<ProjectReference Include="..\Business\Business.csproj"/> | ||
</ItemGroup> | ||
|
||
</Project> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,24 @@ | ||
using System.Threading.Tasks; | ||
using Business; | ||
using Moq; | ||
using NUnit.Framework; | ||
|
||
namespace API.Tests; | ||
|
||
public class MutationTest | ||
{ | ||
[Test] | ||
public async Task TestRegisterPublicKeyCallsKeyServiceWithPublicKey() | ||
{ | ||
var mockKeyService = new Mock<IKeyService>(); | ||
mockKeyService.Setup(x => x.Create("my-public-key")).ReturnsAsync(new Key | ||
{ | ||
Body = "my-public-key", | ||
Id = "key_something" | ||
}); | ||
var mutation = new Mutation(); | ||
var mutationResponse = await mutation.RegisterPublicKey(mockKeyService.Object, "my-public-key"); | ||
Assert.AreEqual(mutationResponse.Body, "my-public-key"); | ||
Assert.AreEqual(mutationResponse.Id, "key_something"); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,19 @@ | ||
<Project Sdk="Microsoft.NET.Sdk"> | ||
|
||
<PropertyGroup> | ||
<TargetFramework>net6.0</TargetFramework> | ||
<ImplicitUsings>enable</ImplicitUsings> | ||
<Nullable>enable</Nullable> | ||
</PropertyGroup> | ||
|
||
<ItemGroup> | ||
<PackageReference Include="HotChocolate.ApolloFederation" Version="12.12.1"/> | ||
<PackageReference Include="HotChocolate.AspNetCore" Version="12.12.1"/> | ||
<PackageReference Include="Microsoft.Extensions.DependencyInjection.Abstractions" Version="6.0.0"/> | ||
</ItemGroup> | ||
|
||
<ItemGroup> | ||
<ProjectReference Include="..\Business\Business.csproj"/> | ||
</ItemGroup> | ||
|
||
</Project> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,11 @@ | ||
using Business; | ||
|
||
namespace API; | ||
|
||
public class Mutation | ||
{ | ||
public Task<Key> RegisterPublicKey([Service] IKeyService keyService, string publicKey) | ||
{ | ||
return keyService.Create(publicKey); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,17 @@ | ||
using API.types; | ||
using Business; | ||
|
||
namespace API; | ||
|
||
public class Query | ||
{ | ||
public Task<User> Me() | ||
{ | ||
return Task.FromResult(new User("user_id")); | ||
} | ||
|
||
public Task<IEnumerable<Key>> Keys([Service] IKeyService keyService) | ||
{ | ||
return keyService.FetchAllKeys(); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,24 @@ | ||
using API.types; | ||
using Microsoft.AspNetCore.Builder; | ||
using Microsoft.Extensions.DependencyInjection; | ||
|
||
namespace API; | ||
|
||
public static class Setup | ||
{ | ||
public static void SetupGraphqlServer(this IServiceCollection serviceCollection) | ||
{ | ||
serviceCollection | ||
.AddGraphQLServer() | ||
.AddApolloFederation() | ||
.AddApolloTracing() | ||
.AddType<User>() | ||
.AddQueryType<Query>() | ||
.AddMutationType<Mutation>(); | ||
} | ||
|
||
public static void AddGraphQlEndpoints(this WebApplication application) | ||
{ | ||
application.MapGraphQL(); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,12 @@ | ||
namespace API.types; | ||
|
||
public sealed record User(string Id) | ||
{ | ||
[Key] public string Id { get; set; } = Id; | ||
|
||
[ReferenceResolver] | ||
public static Task<User> GetUserByIdAsync(string id) | ||
{ | ||
return Task.FromResult(new User(id)); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,23 @@ | ||
<Project Sdk="Microsoft.NET.Sdk"> | ||
|
||
<PropertyGroup> | ||
<TargetFramework>net6.0</TargetFramework> | ||
<Nullable>enable</Nullable> | ||
|
||
<IsPackable>false</IsPackable> | ||
</PropertyGroup> | ||
|
||
<ItemGroup> | ||
<PackageReference Include="Microsoft.NET.Test.Sdk" Version="16.11.0"/> | ||
<PackageReference Include="Moq" Version="4.18.2"/> | ||
<PackageReference Include="NUnit" Version="3.13.2"/> | ||
<PackageReference Include="NUnit3TestAdapter" Version="4.0.0"/> | ||
<PackageReference Include="coverlet.collector" Version="3.1.0"/> | ||
</ItemGroup> | ||
|
||
<ItemGroup> | ||
<ProjectReference Include="..\Business\Business.csproj"/> | ||
<ProjectReference Include="..\Storage\Storage.csproj"/> | ||
</ItemGroup> | ||
|
||
</Project> |
Oops, something went wrong.