Title: Add tests for generating, writing and reading the bootstrap secret by JohnAkindipe · Pull Request #3 · pullbase/pullbase · GitHub
Open Graph Title: Add tests for generating, writing and reading the bootstrap secret by JohnAkindipe · Pull Request #3 · pullbase/pullbase
X Title: Add tests for generating, writing and reading the bootstrap secret by JohnAkindipe · Pull Request #3 · pullbase/pullbase
Description: Add tests for bootstrap secret functions Summary Adds unit tests for the three bootstrap secret functions in server/cmd/server/main.go: generateBootstrapSecret, writeBootstrapSecretFile, and readBootstrapSecretFile. Tests added TestGenerateBootstrapSecret Tests generateBootstrapSecret(). Condition Expected behaviour Function is called successfully Returns no error Returned secret Is not an empty string Returned secret Is valid base64 RawURL encoding (i.e. can be decoded without error) TestWriteBootstrapSecretFile Tests writeBootstrapSecretFile() — happy path, writing to a file in the same directory. Condition Expected behaviour File is written successfully Returns no error Created file permissions 0600 (owner read/write only) File content when read back via readBootstrapSecretFile Equals the secret that was written TestWriteBootstrapSecretFileDifferentDirectory Tests writeBootstrapSecretFile() when the target file is in a subdirectory that does not yet exist. Condition Expected behaviour Parent directory does not exist Returns no error (directory is created automatically) Created directory permissions 0700 (owner read/write/execute only) TestWriteBootstrapSecretFileEmptyPath Tests writeBootstrapSecretFile() with an empty path string. Condition Expected behaviour Path argument is "" Returns a non-nil error TestReadBootstrapSecretFile (table-driven) Tests readBootstrapSecretFile() across four sub-cases: Sub-test Condition Expected behaviour path is invalid Path does not exist on disk Error containing "failed to stat path" path is directory Path points to a directory instead of a file Error containing "is a directory" file permissions are invalid File exists but has default (0666) permissions (group/world readable) Error containing "must not be group- or world-accessible" valid secret file File was written by writeBootstrapSecretFile (permissions 0600) No error; returned secret matches the one that was written Test results All new tests pass. Pre-existing tests also continue to pass: === RUN TestGeneratePrivateKey --- PASS: TestGeneratePrivateKey (0.00s) === RUN TestGenerateCertificate --- PASS: TestGenerateCertificate (0.00s) === RUN TestGenerateCertificateInvalidKey --- PASS: TestGenerateCertificateInvalidKey (0.00s) === RUN TestGenerateSelfSignedCerts --- PASS: TestGenerateSelfSignedCerts (0.00s) === RUN TestGenerateSelfSignedCertsDifferentDirectories --- PASS: TestGenerateSelfSignedCertsDifferentDirectories (0.00s) === RUN TestGenerateSelfSignedCertsCurrentDirectory --- PASS: TestGenerateSelfSignedCertsCurrentDirectory (0.00s) === RUN TestGenerateBootstrapSecret --- PASS: TestGenerateBootstrapSecret (0.00s) === RUN TestWriteBootstrapSecretFile --- PASS: TestWriteBootstrapSecretFile (0.32s) === RUN TestWriteBootstrapSecretFileDifferentDirectory --- PASS: TestWriteBootstrapSecretFileDifferentDirectory (0.38s) === RUN TestWriteBootstrapSecretFileEmptyPath --- PASS: TestWriteBootstrapSecretFileEmptyPath (0.00s) === RUN TestReadBootstrapSecretFile === RUN TestReadBootstrapSecretFile/path_is_invalid === RUN TestReadBootstrapSecretFile/path_is_directory === RUN TestReadBootstrapSecretFile/file_permissions_are_invalid === RUN TestReadBootstrapSecretFile/valid_secret_file --- PASS: TestReadBootstrapSecretFile (0.26s) --- PASS: TestReadBootstrapSecretFile/path_is_invalid (0.00s) --- PASS: TestReadBootstrapSecretFile/path_is_directory (0.00s) --- PASS: TestReadBootstrapSecretFile/file_permissions_are_invalid (0.00s) --- PASS: TestReadBootstrapSecretFile/valid_secret_file (0.25s) PASS ok github.com/pullbase/pullbase/server/cmd/server 0.979s Summary by CodeRabbit Bug Fixes Startup now shows a clearer error when a configured bootstrap secret file can’t be read, including the file path in the message. Improved handling for bootstrap secret file access issues, including invalid paths, directory paths, and permission problems. Tests Added coverage for bootstrap secret generation, file writing, and file reading. Added checks for output formatting and expected file/directory permissions when creating secret files.
Open Graph Description: Add tests for bootstrap secret functions Summary Adds unit tests for the three bootstrap secret functions in server/cmd/server/main.go: generateBootstrapSecret, writeBootstrapSecretFile, and readBo...
X Description: Add tests for bootstrap secret functions Summary Adds unit tests for the three bootstrap secret functions in server/cmd/server/main.go: generateBootstrapSecret, writeBootstrapSecretFile, and readBo...
Opengraph URL: https://github.com/pullbase/pullbase/pull/3
X: @github
Domain: github.com
| react-profiling | 0 |
| react-import-map | react,react-dom,react-dom/client,react-dom/profiling,react-is,react/compiler-runtime,react/jsx-dev-runtime,react/jsx-runtime,scheduler@b8488ee2c322 |
| route-pattern | /:user_id/:repository/pull/:id/files(.:format) |
| route-controller | pull_requests |
| route-action | files |
| fetch-nonce | v2:a7e0b6ff-1f84-cad4-e469-22b28b0bc372 |
| current-catalog-service-hash | ae870bc5e265a340912cde392f23dad3671a0a881730ffdadd82f2f57d81641b |
| request-id | D3CE:2463BD:F69009:13D43C1:6B00FF30 |
| html-safe-nonce | 1b8b32b1f39333e2477b128ba36bbacb435da67ce3b2fbea8a977303d05c79ef |
| visitor-payload | eyJyZWZlcnJlciI6IiIsInJlcXVlc3RfaWQiOiJEM0NFOjI0NjNCRDpGNjkwMDk6MTNENDNDMTo2QjAwRkYzMCIsInZpc2l0b3JfaWQiOiIzODM2NTQwMzUxMzg5MTcxNTA0IiwicmVnaW9uX2VkZ2UiOiJpYWQiLCJyZWdpb25fcmVuZGVyIjoiaWFkIn0= |
| visitor-hmac | a585289badd52370d063cb8a92cecce1342476d078c75a42d49da87f5a9112a5 |
| hovercard-subject-tag | pull_request:3947685983 |
| github-keyboard-shortcuts | repository,pull-request-list,pull-request-conversation,pull-request-files-changed,copilot |
| google-site-verification | Apib7-x98H0j5cPqHWwSMm6dNU4GmODRoqxLiDzdx9I |
| octolytics-url | https://collector.github.com/github/collect |
| analytics-location | / |
| fb:app_id | 1401488693436528 |
| apple-itunes-app | app-id=1477376905, app-argument=https://github.com/pullbase/pullbase/pull/3/files |
| twitter:image | https://avatars.githubusercontent.com/u/85188938?s=400&v=4 |
| twitter:card | summary_large_image |
| og:image | https://avatars.githubusercontent.com/u/85188938?s=400&v=4 |
| og:image:alt | Add tests for bootstrap secret functions Summary Adds unit tests for the three bootstrap secret functions in server/cmd/server/main.go: generateBootstrapSecret, writeBootstrapSecretFile, and readBo... |
| og:site_name | GitHub |
| og:type | object |
| hostname | github.com |
| expected-hostname | github.com |
| None | cb7fa109eca7d4156c889f474306b0e91336055e9adf8fd4684b61e49094d124 |
| turbo-cache-control | no-preview |
| diff-view | unified |
| go-import | github.com/pullbase/pullbase git https://github.com/pullbase/pullbase.git |
| octolytics-dimension-user_id | 209259101 |
| octolytics-dimension-user_login | pullbase |
| octolytics-dimension-repository_id | 1127492151 |
| octolytics-dimension-repository_nwo | pullbase/pullbase |
| octolytics-dimension-repository_public | true |
| octolytics-dimension-repository_is_fork | false |
| octolytics-dimension-repository_network_root_id | 1127492151 |
| octolytics-dimension-repository_network_root_nwo | pullbase/pullbase |
| turbo-body-classes | logged-out env-production page-responsive full-width |
| disable-turbo | true |
| browser-stats-url | https://api.github.com/_private/browser/stats |
| browser-errors-url | https://api.github.com/_private/browser/errors |
| release | 2b59d31a4e44f08b7af67a4b67f8fd0af3befe2a |
| ui-target | full |
| theme-color | #1e2327 |
| color-scheme | light dark |
Links:
Viewport: width=device-width