Skip to content

Commit

Permalink
Fix adding user owner, add GetCurrentTime()
Browse files Browse the repository at this point in the history
  • Loading branch information
hsluoyz committed Oct 31, 2023
1 parent 16737ae commit a8953fb
Show file tree
Hide file tree
Showing 21 changed files with 82 additions and 96 deletions.
11 changes: 5 additions & 6 deletions casdoorsdk/adapter_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,6 @@ package casdoorsdk

import (
"testing"
"time"
)

func TestAdapter(t *testing.T) {
Expand All @@ -26,11 +25,11 @@ func TestAdapter(t *testing.T) {

// Add a new object
adapter := &Adapter{
Owner: "admin",
Name: name,
CreatedTime: time.Now().Format(time.RFC3339),
User: name,
Host: "https://casdoor.org",
Owner: "admin",
Name: name,
CreatedTime: GetCurrentTime(),
User: name,
Host: "https://casdoor.org",
}
_, err := AddAdapter(adapter)
if err != nil {
Expand Down
3 changes: 1 addition & 2 deletions casdoorsdk/application_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,6 @@ package casdoorsdk

import (
"testing"
"time"
)

func TestApplication(t *testing.T) {
Expand All @@ -28,7 +27,7 @@ func TestApplication(t *testing.T) {
application := &Application{
Owner: "admin",
Name: name,
CreatedTime: time.Now().Format(time.RFC3339),
CreatedTime: GetCurrentTime(),
DisplayName: name,
Logo: "https://cdn.casbin.org/img/casdoor-logo_1185x256.png",
HomepageUrl: "https://casdoor.org",
Expand Down
7 changes: 3 additions & 4 deletions casdoorsdk/cert_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,6 @@ package casdoorsdk

import (
"testing"
"time"
)

func TestCert(t *testing.T) {
Expand All @@ -28,13 +27,13 @@ func TestCert(t *testing.T) {
cert := &Cert{
Owner: "admin",
Name: name,
CreatedTime: time.Now().Format(time.RFC3339),
CreatedTime: GetCurrentTime(),
DisplayName: name,
Scope: "JWT",
Type: "x509",
CryptoAlgorithm: "RS256",
BitSize: 4096,
ExpireInYears: 20,
BitSize: 4096,
ExpireInYears: 20,
}
_, err := AddCert(cert)
if err != nil {
Expand Down
15 changes: 7 additions & 8 deletions casdoorsdk/enforcer_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,6 @@ package casdoorsdk

import (
"testing"
"time"
)

func TestEnforcer(t *testing.T) {
Expand All @@ -26,13 +25,13 @@ func TestEnforcer(t *testing.T) {

// Add a new object
enforcer := &Enforcer{
Owner: "admin",
Name: name,
CreatedTime: time.Now().Format(time.RFC3339),
DisplayName: name,
Model: "built-in/user-model-built-in",
Adapter: "built-in/user-adapter-built-in",
Description: "Casdoor Website",
Owner: "admin",
Name: name,
CreatedTime: GetCurrentTime(),
DisplayName: name,
Model: "built-in/user-model-built-in",
Adapter: "built-in/user-adapter-built-in",
Description: "Casdoor Website",
}
_, err := AddEnforcer(enforcer)
if err != nil {
Expand Down
9 changes: 4 additions & 5 deletions casdoorsdk/group_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,6 @@ package casdoorsdk

import (
"testing"
"time"
)

func TestGroup(t *testing.T) {
Expand All @@ -26,10 +25,10 @@ func TestGroup(t *testing.T) {

// Add a new object
group := &Group{
Owner: "admin",
Name: name,
CreatedTime: time.Now().Format(time.RFC3339),
DisplayName: name,
Owner: "admin",
Name: name,
CreatedTime: GetCurrentTime(),
DisplayName: name,
}
_, err := AddGroup(group)
if err != nil {
Expand Down
9 changes: 4 additions & 5 deletions casdoorsdk/model_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,6 @@ package casdoorsdk

import (
"testing"
"time"
)

func TestModel(t *testing.T) {
Expand All @@ -26,10 +25,10 @@ func TestModel(t *testing.T) {

// Add a new object
model := &Model{
Owner: "casbin",
Name: name,
CreatedTime: time.Now().Format(time.RFC3339),
DisplayName: name,
Owner: "casbin",
Name: name,
CreatedTime: GetCurrentTime(),
DisplayName: name,
ModelText: `[request_definition]
r = sub, obj, act
Expand Down
3 changes: 1 addition & 2 deletions casdoorsdk/organization_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,6 @@ package casdoorsdk

import (
"testing"
"time"
)

func TestOrganization(t *testing.T) {
Expand All @@ -28,7 +27,7 @@ func TestOrganization(t *testing.T) {
organization := &Organization{
Owner: "admin",
Name: name,
CreatedTime: time.Now().Format(time.RFC3339),
CreatedTime: GetCurrentTime(),
DisplayName: name,
WebsiteUrl: "https://example.com",
PasswordType: "plain",
Expand Down
11 changes: 5 additions & 6 deletions casdoorsdk/payment_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,6 @@ package casdoorsdk

import (
"testing"
"time"
)

func TestPayment(t *testing.T) {
Expand All @@ -26,11 +25,11 @@ func TestPayment(t *testing.T) {

// Add a new object
payment := &Payment{
Owner: "admin",
Name: name,
CreatedTime: time.Now().Format(time.RFC3339),
DisplayName: name,
ProductName: "casbin",
Owner: "admin",
Name: name,
CreatedTime: GetCurrentTime(),
DisplayName: name,
ProductName: "casbin",
}
_, err := AddPayment(payment)
if err != nil {
Expand Down
3 changes: 1 addition & 2 deletions casdoorsdk/permission_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,6 @@ package casdoorsdk

import (
"testing"
"time"
)

func TestPermission(t *testing.T) {
Expand All @@ -28,7 +27,7 @@ func TestPermission(t *testing.T) {
permission := &Permission{
Owner: "casbin",
Name: name,
CreatedTime: time.Now().Format(time.RFC3339),
CreatedTime: GetCurrentTime(),
DisplayName: name,
Description: "Casdoor Website",
Users: []string{"casbin/*"},
Expand Down
11 changes: 5 additions & 6 deletions casdoorsdk/plan_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,6 @@ package casdoorsdk

import (
"testing"
"time"
)

func TestPlan(t *testing.T) {
Expand All @@ -26,11 +25,11 @@ func TestPlan(t *testing.T) {

// Add a new object
plan := &Plan{
Owner: "admin",
Name: name,
CreatedTime: time.Now().Format(time.RFC3339),
DisplayName: name,
Description: "Casdoor Website",
Owner: "admin",
Name: name,
CreatedTime: GetCurrentTime(),
DisplayName: name,
Description: "Casdoor Website",
}
_, err := AddPlan(plan)
if err != nil {
Expand Down
13 changes: 6 additions & 7 deletions casdoorsdk/pricing_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,6 @@ package casdoorsdk

import (
"testing"
"time"
)

func TestPricing(t *testing.T) {
Expand All @@ -26,12 +25,12 @@ func TestPricing(t *testing.T) {

// Add a new object
pricing := &Pricing{
Owner: "admin",
Name: name,
CreatedTime: time.Now().Format(time.RFC3339),
DisplayName: name,
Application: "app-admin",
Description: "Casdoor Website",
Owner: "admin",
Name: name,
CreatedTime: GetCurrentTime(),
DisplayName: name,
Application: "app-admin",
Description: "Casdoor Website",
}
_, err := AddPricing(pricing)
if err != nil {
Expand Down
13 changes: 6 additions & 7 deletions casdoorsdk/product_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,6 @@ package casdoorsdk

import (
"testing"
"time"
)

func TestProduct(t *testing.T) {
Expand All @@ -26,18 +25,18 @@ func TestProduct(t *testing.T) {

// Add a new object
product := &Product{
Owner: "admin",
Name: name,
CreatedTime: time.Now().Format(time.RFC3339),
DisplayName: name,
Owner: "admin",
Name: name,
CreatedTime: GetCurrentTime(),
DisplayName: name,

Image: "https://cdn.casbin.org/img/casdoor-logo_1185x256.png",
Description: "Casdoor Website",
Description: "Casdoor Website",
Tag: "auto_created_product_for_plan",

Quantity: 999,
Sold: 0,
State: "Published",
State: "Published",
}
_, err := AddProduct(product)
if err != nil {
Expand Down
9 changes: 4 additions & 5 deletions casdoorsdk/provider_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,6 @@ package casdoorsdk

import (
"testing"
"time"
)

func TestProvider(t *testing.T) {
Expand All @@ -26,10 +25,10 @@ func TestProvider(t *testing.T) {

// Add a new object
provider := &Provider{
Owner: "admin",
Name: name,
CreatedTime: time.Now().Format(time.RFC3339),
DisplayName: name,
Owner: "admin",
Name: name,
CreatedTime: GetCurrentTime(),
DisplayName: name,
Category: "Captcha",
Type: "Default",
}
Expand Down
3 changes: 1 addition & 2 deletions casdoorsdk/resource_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,6 @@ import (
"io"
"os"
"testing"
"time"
)

func (resource *Resource) GetId() string {
Expand All @@ -46,7 +45,7 @@ func TestResource(t *testing.T) {
resource := &Resource{
Owner: "casbin",
Name: name,
CreatedTime: time.Now().Format(time.RFC3339),
CreatedTime: GetCurrentTime(),
Description: "Casdoor Website",
User: "casbin",
FileName: filename,
Expand Down
11 changes: 5 additions & 6 deletions casdoorsdk/role_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,6 @@ package casdoorsdk

import (
"testing"
"time"
)

func TestRole(t *testing.T) {
Expand All @@ -26,11 +25,11 @@ func TestRole(t *testing.T) {

// Add a new object
role := &Role{
Owner: "admin",
Name: name,
CreatedTime: time.Now().Format(time.RFC3339),
DisplayName: name,
Description: "Casdoor Website",
Owner: "admin",
Name: name,
CreatedTime: GetCurrentTime(),
DisplayName: name,
Description: "Casdoor Website",
}
_, err := AddRole(role)
if err != nil {
Expand Down
13 changes: 6 additions & 7 deletions casdoorsdk/session_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,6 @@ package casdoorsdk

import (
"testing"
"time"
)

func TestSession(t *testing.T) {
Expand All @@ -26,11 +25,11 @@ func TestSession(t *testing.T) {

// Add a new object
Session := &Session{
Owner: "casbin",
Name: name,
CreatedTime: time.Now().Format(time.RFC3339),
Application: "app-built-in",
SessionId: []string{},
Owner: "casbin",
Name: name,
CreatedTime: GetCurrentTime(),
Application: "app-built-in",
SessionId: []string{},
}
_, err := AddSession(Session)
if err != nil {
Expand Down Expand Up @@ -63,7 +62,7 @@ func TestSession(t *testing.T) {
}

// Update the object
UpdateTime := time.Now().Format(time.RFC3339)
UpdateTime := GetCurrentTime()
Session.CreatedTime = UpdateTime
_, err = UpdateSession(Session)
if err != nil {
Expand Down
Loading

0 comments on commit a8953fb

Please sign in to comment.