aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--Timeline.Tests/QCloudCosServiceUnitTest.cs68
-rw-r--r--Timeline/Migrations/20190719115321_Add-User-Version.Designer.cs49
-rw-r--r--Timeline/Migrations/20190719115321_Add-User-Version.cs23
-rw-r--r--Timeline/Migrations/DatabaseContextModelSnapshot.cs5
-rw-r--r--Timeline/Models/DatabaseContext.cs3
-rw-r--r--Timeline/Services/JwtService.cs1
6 files changed, 111 insertions, 38 deletions
diff --git a/Timeline.Tests/QCloudCosServiceUnitTest.cs b/Timeline.Tests/QCloudCosServiceUnitTest.cs
index 0940c70d..c330cce0 100644
--- a/Timeline.Tests/QCloudCosServiceUnitTest.cs
+++ b/Timeline.Tests/QCloudCosServiceUnitTest.cs
@@ -1,10 +1,6 @@
using Microsoft.AspNetCore.Mvc.Testing;
-using Microsoft.Extensions.DependencyInjection;
using System;
using System.Collections.Generic;
-using System.Net;
-using System.Net.Http;
-using System.Threading.Tasks;
using Timeline.Services;
using Timeline.Tests.Helpers;
using Xunit;
@@ -65,40 +61,40 @@ namespace Timeline.Tests
Assert.Equal("q-sign-algorithm=sha1&q-ak=AKIDQjz3ltompVjBni5LitkWHFlFpwkn9U5q&q-sign-time=1417773892;1417853898&q-key-time=1417773892;1417853898&q-header-list=host;x-cos-content-sha1;x-cos-storage-class&q-url-param-list=&q-signature=0ab12f43e74cbe148d705cd9fae8adc9a6d39cc1", QCloudCosService.GenerateSign(credential, request, signValidTime));
}
-/*
-// Tests in this part need secret configs in cos.
-#region SecretTests
- [Fact]
- public async Task ObjectExistsTest()
- {
- using (var serviceScope = _factory.Server.Host.Services.CreateScope())
- {
- var services = serviceScope.ServiceProvider;
- var service = services.GetRequiredService<IQCloudCosService>();
- Assert.True(await service.IsObjectExists("avatar", "__default"));
- Assert.False(await service.IsObjectExists("avatar", "haha"));
- Assert.False(await service.IsObjectExists("haha", "haha"));
- }
- }
+ /*
+ // Tests in this part need secret configs in cos.
+ #region SecretTests
+ [Fact]
+ public async Task ObjectExistsTest()
+ {
+ using (var serviceScope = _factory.Server.Host.Services.CreateScope())
+ {
+ var services = serviceScope.ServiceProvider;
+ var service = services.GetRequiredService<IQCloudCosService>();
+ Assert.True(await service.IsObjectExists("avatar", "__default"));
+ Assert.False(await service.IsObjectExists("avatar", "haha"));
+ Assert.False(await service.IsObjectExists("haha", "haha"));
+ }
+ }
- [Fact]
- public async Task GenerateObjectGetUrlTest()
- {
- using (var serviceScope = _factory.Server.Host.Services.CreateScope())
- {
- var services = serviceScope.ServiceProvider;
- var service = services.GetRequiredService<IQCloudCosService>();
- var url = service.GenerateObjectGetUrl("avatar", "__default");
- // never use the following line! Because client created by factory can't access Internet.
- //using (var client = _factory.CreateClient())
- using (var client = services.GetRequiredService<IHttpClientFactory>().CreateClient())
+ [Fact]
+ public async Task GenerateObjectGetUrlTest()
{
- var res = await client.GetAsync(url);
- Assert.Equal(HttpStatusCode.OK, res.StatusCode);
+ using (var serviceScope = _factory.Server.Host.Services.CreateScope())
+ {
+ var services = serviceScope.ServiceProvider;
+ var service = services.GetRequiredService<IQCloudCosService>();
+ var url = service.GenerateObjectGetUrl("avatar", "__default");
+ // never use the following line! Because client created by factory can't access Internet.
+ //using (var client = _factory.CreateClient())
+ using (var client = services.GetRequiredService<IHttpClientFactory>().CreateClient())
+ {
+ var res = await client.GetAsync(url);
+ Assert.Equal(HttpStatusCode.OK, res.StatusCode);
+ }
+ }
}
- }
- }
-#endregion
-*/
+ #endregion
+ */
}
}
diff --git a/Timeline/Migrations/20190719115321_Add-User-Version.Designer.cs b/Timeline/Migrations/20190719115321_Add-User-Version.Designer.cs
new file mode 100644
index 00000000..42eeeb40
--- /dev/null
+++ b/Timeline/Migrations/20190719115321_Add-User-Version.Designer.cs
@@ -0,0 +1,49 @@
+// <auto-generated />
+using Microsoft.EntityFrameworkCore;
+using Microsoft.EntityFrameworkCore.Infrastructure;
+using Microsoft.EntityFrameworkCore.Migrations;
+using Microsoft.EntityFrameworkCore.Storage.ValueConversion;
+using Timeline.Models;
+
+namespace Timeline.Migrations
+{
+ [DbContext(typeof(DatabaseContext))]
+ [Migration("20190719115321_Add-User-Version")]
+ partial class AddUserVersion
+ {
+ protected override void BuildTargetModel(ModelBuilder modelBuilder)
+ {
+#pragma warning disable 612, 618
+ modelBuilder
+ .HasAnnotation("ProductVersion", "2.2.6-servicing-10079")
+ .HasAnnotation("Relational:MaxIdentifierLength", 64);
+
+ modelBuilder.Entity("Timeline.Models.User", b =>
+ {
+ b.Property<long>("Id")
+ .ValueGeneratedOnAdd()
+ .HasColumnName("id");
+
+ b.Property<string>("EncryptedPassword")
+ .IsRequired()
+ .HasColumnName("password");
+
+ b.Property<string>("Name")
+ .IsRequired()
+ .HasColumnName("name");
+
+ b.Property<string>("RoleString")
+ .IsRequired()
+ .HasColumnName("roles");
+
+ b.Property<long>("Version")
+ .HasColumnName("version");
+
+ b.HasKey("Id");
+
+ b.ToTable("user");
+ });
+#pragma warning restore 612, 618
+ }
+ }
+}
diff --git a/Timeline/Migrations/20190719115321_Add-User-Version.cs b/Timeline/Migrations/20190719115321_Add-User-Version.cs
new file mode 100644
index 00000000..715af909
--- /dev/null
+++ b/Timeline/Migrations/20190719115321_Add-User-Version.cs
@@ -0,0 +1,23 @@
+using Microsoft.EntityFrameworkCore.Migrations;
+
+namespace Timeline.Migrations
+{
+ public partial class AddUserVersion : Migration
+ {
+ protected override void Up(MigrationBuilder migrationBuilder)
+ {
+ migrationBuilder.AddColumn<long>(
+ name: "version",
+ table: "user",
+ nullable: false,
+ defaultValue: 0L);
+ }
+
+ protected override void Down(MigrationBuilder migrationBuilder)
+ {
+ migrationBuilder.DropColumn(
+ name: "version",
+ table: "user");
+ }
+ }
+}
diff --git a/Timeline/Migrations/DatabaseContextModelSnapshot.cs b/Timeline/Migrations/DatabaseContextModelSnapshot.cs
index a833d2dc..7d244969 100644
--- a/Timeline/Migrations/DatabaseContextModelSnapshot.cs
+++ b/Timeline/Migrations/DatabaseContextModelSnapshot.cs
@@ -13,7 +13,7 @@ namespace Timeline.Migrations
{
#pragma warning disable 612, 618
modelBuilder
- .HasAnnotation("ProductVersion", "2.2.3-servicing-35854")
+ .HasAnnotation("ProductVersion", "2.2.6-servicing-10079")
.HasAnnotation("Relational:MaxIdentifierLength", 64);
modelBuilder.Entity("Timeline.Models.User", b =>
@@ -34,6 +34,9 @@ namespace Timeline.Migrations
.IsRequired()
.HasColumnName("roles");
+ b.Property<long>("Version")
+ .HasColumnName("version");
+
b.HasKey("Id");
b.ToTable("user");
diff --git a/Timeline/Models/DatabaseContext.cs b/Timeline/Models/DatabaseContext.cs
index 1e89ea82..87c0fd17 100644
--- a/Timeline/Models/DatabaseContext.cs
+++ b/Timeline/Models/DatabaseContext.cs
@@ -18,6 +18,9 @@ namespace Timeline.Models
[Column("roles"), Required]
public string RoleString { get; set; }
+
+ [Column("version"), Required]
+ public long Version { get; set; }
}
public class DatabaseContext : DbContext
diff --git a/Timeline/Services/JwtService.cs b/Timeline/Services/JwtService.cs
index f5df59a5..2139ba56 100644
--- a/Timeline/Services/JwtService.cs
+++ b/Timeline/Services/JwtService.cs
@@ -7,7 +7,6 @@ using System.Linq;
using System.Security.Claims;
using System.Text;
using Timeline.Configs;
-using Timeline.Entities;
namespace Timeline.Services
{