Files
Gokapi/internal/models/Configuration_test.go
Marc Bulling d88f649209 Add support for multiple different users, rewrote API, breaking API changes, UI changes
* Require 1.9.6 for upgrade, add function to get userID from request

* Automatically add user when successfully authenticated with headers / oauth, disallow modifing own user permissions

* Dont show user/pw page when using header authentication

* Only display redacted versions of API keys #228, fixed deployment password

* Added animation for deleting API key

* Only create salt once

* Disable elements on upload UI if insufficient permissions

* BREAKING: User field must be email for OAUTH2, added warning in setup when changing database

* BREAKING: Added option to restrict to only registered users

* Fixed crash due to concurrent map iteration

* Replace /uploadComplete with API call, BREAKING API is now in headers

* BREAKING: require true|false instead of only checking for true

* BREAKING API: Renamed apiKeyToModify parameter to targetKey
2025-02-04 09:22:55 +01:00

50 lines
1.9 KiB
Go

package models
import (
"github.com/forceu/gokapi/internal/test"
"strings"
"testing"
)
var testConfig = Configuration{
Authentication: AuthenticationConfig{
Method: 0,
SaltAdmin: "saltadmin",
SaltFiles: "saltfiles",
Username: "admin",
HeaderKey: "",
OAuthProvider: "",
OAuthClientId: "",
OAuthClientSecret: "",
},
Port: ":12345",
ServerUrl: "https://testserver.com/",
RedirectUrl: "https://test.com",
DatabaseUrl: "sqlite://./test/gokapitest.sqlite",
ConfigVersion: 14,
LengthId: 5,
DataDir: "test",
MaxMemory: 50,
UseSsl: true,
MaxFileSizeMB: 20,
PublicName: "public-name",
Encryption: Encryption{
Level: 1,
Cipher: []byte{0x00},
Salt: "encsalt",
Checksum: "encsum",
ChecksumSalt: "encsumsalt",
},
PicturesAlwaysLocal: true,
}
func TestConfiguration_ToJson(t *testing.T) {
test.IsEqualBool(t, strings.Contains(string(testConfig.ToJson()), "\"SaltAdmin\": \"saltadmin\""), true)
}
func TestConfiguration_ToString(t *testing.T) {
test.IsEqualString(t, testConfig.ToString(), exptectedUnidentedOutput)
}
const exptectedUnidentedOutput = `{"Authentication":{"Method":0,"SaltAdmin":"saltadmin","SaltFiles":"saltfiles","Username":"admin","HeaderKey":"","OauthProvider":"","OAuthClientId":"","OAuthClientSecret":"","OauthGroupScope":"","OAuthRecheckInterval":0,"OAuthGroups":null,"OnlyRegisteredUsers":false},"Port":":12345","ServerUrl":"https://testserver.com/","RedirectUrl":"https://test.com","PublicName":"public-name","DataDir":"test","DatabaseUrl":"sqlite://./test/gokapitest.sqlite","ConfigVersion":14,"LengthId":5,"MaxFileSizeMB":20,"MaxMemory":50,"ChunkSize":0,"MaxParallelUploads":0,"Encryption":{"Level":1,"Cipher":"AA==","Salt":"encsalt","Checksum":"encsum","ChecksumSalt":"encsumsalt"},"UseSsl":true,"PicturesAlwaysLocal":true,"SaveIp":false,"IncludeFilename":false}`