config.go (4176B)
1 // GoToSocial 2 // Copyright (C) GoToSocial Authors admin@gotosocial.org 3 // SPDX-License-Identifier: AGPL-3.0-or-later 4 // 5 // This program is free software: you can redistribute it and/or modify 6 // it under the terms of the GNU Affero General Public License as published by 7 // the Free Software Foundation, either version 3 of the License, or 8 // (at your option) any later version. 9 // 10 // This program is distributed in the hope that it will be useful, 11 // but WITHOUT ANY WARRANTY; without even the implied warranty of 12 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 13 // GNU Affero General Public License for more details. 14 // 15 // You should have received a copy of the GNU Affero General Public License 16 // along with this program. If not, see <http://www.gnu.org/licenses/>. 17 18 package testrig 19 20 import ( 21 "time" 22 23 "codeberg.org/gruf/go-bytesize" 24 "github.com/coreos/go-oidc/v3/oidc" 25 "github.com/superseriousbusiness/gotosocial/internal/config" 26 ) 27 28 // InitTestConfig initializes viper configuration with test defaults. 29 func InitTestConfig() { 30 config.Config(func(cfg *config.Configuration) { 31 *cfg = testDefaults 32 }) 33 } 34 35 var testDefaults = config.Configuration{ 36 LogLevel: "trace", 37 LogDbQueries: true, 38 ApplicationName: "gotosocial", 39 LandingPageUser: "", 40 ConfigPath: "", 41 Host: "localhost:8080", 42 AccountDomain: "localhost:8080", 43 Protocol: "http", 44 BindAddress: "127.0.0.1", 45 Port: 8080, 46 TrustedProxies: []string{"127.0.0.1/32", "::1"}, 47 48 DbType: "sqlite", 49 DbAddress: ":memory:", 50 DbPort: 5432, 51 DbUser: "postgres", 52 DbPassword: "postgres", 53 DbDatabase: "postgres", 54 DbTLSMode: "disable", 55 DbTLSCACert: "", 56 DbMaxOpenConnsMultiplier: 8, 57 DbSqliteJournalMode: "WAL", 58 DbSqliteSynchronous: "NORMAL", 59 DbSqliteCacheSize: 8 * bytesize.MiB, 60 DbSqliteBusyTimeout: time.Minute * 5, 61 62 WebTemplateBaseDir: "./web/template/", 63 WebAssetBaseDir: "./web/assets/", 64 65 InstanceExposePeers: true, 66 InstanceExposeSuspended: true, 67 InstanceExposeSuspendedWeb: true, 68 InstanceDeliverToSharedInboxes: true, 69 70 AccountsRegistrationOpen: true, 71 AccountsApprovalRequired: true, 72 AccountsReasonRequired: true, 73 AccountsAllowCustomCSS: true, 74 AccountsCustomCSSLength: 10000, 75 76 MediaImageMaxSize: 10485760, // 10mb 77 MediaVideoMaxSize: 41943040, // 40mb 78 MediaDescriptionMinChars: 0, 79 MediaDescriptionMaxChars: 500, 80 MediaRemoteCacheDays: 30, 81 MediaEmojiLocalMaxSize: 51200, // 50kb 82 MediaEmojiRemoteMaxSize: 102400, // 100kb 83 84 // the testrig only uses in-memory storage, so we can 85 // safely set this value to 'test' to avoid running storage 86 // migrations, and other silly things like that 87 StorageBackend: "test", 88 StorageLocalBasePath: "", 89 90 StatusesMaxChars: 5000, 91 StatusesCWMaxChars: 100, 92 StatusesPollMaxOptions: 6, 93 StatusesPollOptionMaxChars: 50, 94 StatusesMediaMaxFiles: 6, 95 96 LetsEncryptEnabled: false, 97 LetsEncryptPort: 0, 98 LetsEncryptCertDir: "", 99 LetsEncryptEmailAddress: "", 100 101 OIDCEnabled: false, 102 OIDCIdpName: "", 103 OIDCSkipVerification: false, 104 OIDCIssuer: "", 105 OIDCClientID: "", 106 OIDCClientSecret: "", 107 OIDCScopes: []string{oidc.ScopeOpenID, "profile", "email", "groups"}, 108 OIDCLinkExisting: false, 109 110 SMTPHost: "", 111 SMTPPort: 0, 112 SMTPUsername: "", 113 SMTPPassword: "", 114 SMTPFrom: "GoToSocial", 115 SMTPDiscloseRecipients: false, 116 117 TracingEnabled: false, 118 TracingEndpoint: "localhost:4317", 119 TracingTransport: "grpc", 120 TracingInsecureTransport: true, 121 122 SyslogEnabled: false, 123 SyslogProtocol: "udp", 124 SyslogAddress: "localhost:514", 125 126 AdvancedCookiesSamesite: "lax", 127 AdvancedRateLimitRequests: 0, // disabled 128 AdvancedThrottlingMultiplier: 0, // disabled 129 AdvancedSenderMultiplier: 0, // 1 sender only, regardless of CPU 130 131 SoftwareVersion: "0.0.0-testrig", 132 133 // simply use cache defaults. 134 Cache: config.Defaults.Cache, 135 }