Compare commits
5 Commits
9267adbecb
...
main
| Author | SHA1 | Date | |
|---|---|---|---|
| d5a396f53a | |||
| 5a38d132b8 | |||
| 6ebb7390d5 | |||
| 92ceddc32e | |||
| 791034f7a4 |
27
README.md
27
README.md
@@ -6,7 +6,27 @@ An ISC Licensed RoR app to manage your OpenSMTPD users.
|
||||
|
||||
## OpenBSD Instructions.
|
||||
|
||||
doas pkg_add
|
||||
```
|
||||
doas pkg_add ruby
|
||||
|
||||
ln -sf /usr/local/bin/ruby40 /usr/local/bin/ruby
|
||||
ln -sf /usr/local/bin/bundle40 /usr/local/bin/bundle
|
||||
ln -sf /usr/local/bin/bundler40 /usr/local/bin/bundler
|
||||
ln -sf /usr/local/bin/erb40 /usr/local/bin/erb
|
||||
ln -sf /usr/local/bin/gem40 /usr/local/bin/gem
|
||||
ln -sf /usr/local/bin/irb40 /usr/local/bin/irb
|
||||
ln -sf /usr/local/bin/minitest40 /usr/local/bin/minitest
|
||||
ln -sf /usr/local/bin/racc40 /usr/local/bin/racc
|
||||
ln -sf /usr/local/bin/rake40 /usr/local/bin/rake
|
||||
ln -sf /usr/local/bin/rbs40 /usr/local/bin/rbs
|
||||
ln -sf /usr/local/bin/rdbg40 /usr/local/bin/rdbg
|
||||
ln -sf /usr/local/bin/rdoc40 /usr/local/bin/rdoc
|
||||
ln -sf /usr/local/bin/ri40 /usr/local/bin/ri
|
||||
ln -sf /usr/local/bin/syntax_suggest40 /usr/local/bin/syntax_suggest
|
||||
ln -sf /usr/local/bin/test-unit40 /usr/local/bin/test-unit
|
||||
ln -sf /usr/local/bin/typeprof40 /usr/local/bin/typeprof
|
||||
|
||||
```
|
||||
|
||||
## Database schema
|
||||
Is derived from https://github.com/OpenSMTPD/OpenSMTPD-extras/blob/master/extras/tables/table-mysql/table-mysql.5
|
||||
@@ -32,6 +52,11 @@ FLUSH PRIVILEGES;
|
||||
```
|
||||
|
||||
* Database initialization
|
||||
```
|
||||
RAILS_ENV=production rails db:migrate
|
||||
|
||||
RAILS_ENV=production rails console
|
||||
```
|
||||
|
||||
* How to run the test suite
|
||||
|
||||
|
||||
@@ -3,4 +3,8 @@ class User < ApplicationRecord
|
||||
# Include default devise modules. Others available are:
|
||||
# :confirmable, :lockable, :timeoutable, :trackable and :omniauthable
|
||||
devise :recoverable, :rememberable, :validatable, :lockable, :timeoutable, :trackable, :registerable
|
||||
|
||||
def role
|
||||
|
||||
end
|
||||
end
|
||||
|
||||
8
db/migrate/20260427123300_create_domains_admins.rb
Normal file
8
db/migrate/20260427123300_create_domains_admins.rb
Normal file
@@ -0,0 +1,8 @@
|
||||
class CreateDomainsAdmins < ActiveRecord::Migration[8.1]
|
||||
def change
|
||||
create_table :domains_admins, id: false do |t|
|
||||
t.belongs_to :users
|
||||
t.belongs_to :domains
|
||||
end
|
||||
end
|
||||
end
|
||||
@@ -0,0 +1,5 @@
|
||||
class AddDomainRedToCredentials < ActiveRecord::Migration[8.1]
|
||||
def change
|
||||
add_reference :credentials, :domain, null: false, foreign_key: true
|
||||
end
|
||||
end
|
||||
5
db/migrate/20260430152237_add_domain_red_to_virtuals.rb
Normal file
5
db/migrate/20260430152237_add_domain_red_to_virtuals.rb
Normal file
@@ -0,0 +1,5 @@
|
||||
class AddDomainRedToVirtuals < ActiveRecord::Migration[8.1]
|
||||
def change
|
||||
add_reference :virtuals, :domain, null: false, foreign_key: true
|
||||
end
|
||||
end
|
||||
16
db/schema.rb
generated
16
db/schema.rb
generated
@@ -10,12 +10,14 @@
|
||||
#
|
||||
# It's strongly recommended that you check this file into your version control system.
|
||||
|
||||
ActiveRecord::Schema[8.1].define(version: 2024_05_21_090545) do
|
||||
ActiveRecord::Schema[8.1].define(version: 2026_04_30_152237) do
|
||||
create_table "credentials", charset: "latin1", collation: "latin1_swedish_ci", force: :cascade do |t|
|
||||
t.datetime "created_at", null: false
|
||||
t.bigint "domain_id", null: false
|
||||
t.string "email"
|
||||
t.string "password"
|
||||
t.datetime "updated_at", null: false
|
||||
t.index ["domain_id"], name: "index_credentials_on_domain_id"
|
||||
end
|
||||
|
||||
create_table "domains", charset: "latin1", collation: "latin1_swedish_ci", force: :cascade do |t|
|
||||
@@ -24,6 +26,13 @@ ActiveRecord::Schema[8.1].define(version: 2024_05_21_090545) do
|
||||
t.datetime "updated_at", null: false
|
||||
end
|
||||
|
||||
create_table "domains_admins", id: false, charset: "latin1", collation: "latin1_swedish_ci", force: :cascade do |t|
|
||||
t.bigint "domains_id"
|
||||
t.bigint "users_id"
|
||||
t.index ["domains_id"], name: "index_domains_admins_on_domains_id"
|
||||
t.index ["users_id"], name: "index_domains_admins_on_users_id"
|
||||
end
|
||||
|
||||
create_table "users", charset: "latin1", collation: "latin1_swedish_ci", force: :cascade do |t|
|
||||
t.integer "consumed_timestep"
|
||||
t.datetime "created_at", null: false
|
||||
@@ -52,7 +61,12 @@ ActiveRecord::Schema[8.1].define(version: 2024_05_21_090545) do
|
||||
create_table "virtuals", charset: "latin1", collation: "latin1_swedish_ci", force: :cascade do |t|
|
||||
t.datetime "created_at", null: false
|
||||
t.string "destination"
|
||||
t.bigint "domain_id", null: false
|
||||
t.string "email"
|
||||
t.datetime "updated_at", null: false
|
||||
t.index ["domain_id"], name: "index_virtuals_on_domain_id"
|
||||
end
|
||||
|
||||
add_foreign_key "credentials", "domains"
|
||||
add_foreign_key "virtuals", "domains"
|
||||
end
|
||||
|
||||
@@ -5,7 +5,7 @@ class CredentialsControllerTest < ActionDispatch::IntegrationTest
|
||||
|
||||
setup do
|
||||
@credential = credentials(:one)
|
||||
@domain = domains(:one)
|
||||
@domain = domains(:domainone)
|
||||
end
|
||||
|
||||
test "should not get new" do
|
||||
|
||||
@@ -3,7 +3,7 @@ require "test_helper"
|
||||
class DomainsControllerTest < ActionDispatch::IntegrationTest
|
||||
include Devise::Test::IntegrationHelpers
|
||||
setup do
|
||||
@domain = domains(:one)
|
||||
@domain = domains(:domainone)
|
||||
end
|
||||
|
||||
test "not should get index because user not logged in" do
|
||||
|
||||
@@ -5,7 +5,7 @@ class VirtualsControllerTest < ActionDispatch::IntegrationTest
|
||||
|
||||
setup do
|
||||
@virtual = virtuals(:one)
|
||||
@domain = domains(:one)
|
||||
@domain = domains(:domainone)
|
||||
end
|
||||
|
||||
test "should get not get new because we are not logged in" do
|
||||
|
||||
@@ -19,7 +19,12 @@ class CredentialTest < ActiveSupport::TestCase
|
||||
end
|
||||
|
||||
test "domain added to name" do
|
||||
@c = Credential.new(email: "jez@#{domains(:one).domain}", password: "1234567&ab", domain_id: domains(:one).id)
|
||||
@c = Credential.new(email: "jez@#{domains(:domainone).domain}", password: "1234567&ab", domain_id: domains(:domainone).id)
|
||||
assert @c.save
|
||||
end
|
||||
|
||||
test "domain_id not the same as domain" do
|
||||
@c = Credential.new(email: "steve@#{domains(:domainone).domain}", password: "1234567&ab", domain_id: domains(:domainone).id)
|
||||
assert_not @c.save
|
||||
end
|
||||
end
|
||||
|
||||
@@ -43,7 +43,7 @@ class VirtualTest < ActiveSupport::TestCase
|
||||
@v = Virtual.new
|
||||
@v.email = "abuse@example.net"
|
||||
@v.destination = "valid@email.com"
|
||||
@v.domain_id = domains(:one).id + 1234
|
||||
@v.domain_id = domains(:domainone).id + 1234
|
||||
assert !@v.save
|
||||
end
|
||||
|
||||
|
||||
Reference in New Issue
Block a user