source stringclasses 1
value | repo stringlengths 5 63 | repo_url stringlengths 24 82 | path stringlengths 5 167 | language stringclasses 1
value | license stringclasses 5
values | stars int64 10 51.4k | ref stringclasses 23
values | size_bytes int64 200 258k | text stringlengths 137 258k |
|---|---|---|---|---|---|---|---|---|---|
github | postalserver/postal | https://github.com/postalserver/postal | app/models/concerns/has_soft_destroy.rb | Ruby | mit | 16,477 | main | 384 | # frozen_string_literal: true
module HasSoftDestroy
def self.included(base)
base.define_callbacks :soft_destroy
base.class_eval do
scope :deleted, -> { where.not(deleted_at: nil) }
scope :present, -> { where(deleted_at: nil) }
end
end
def soft_destroy
run_callbacks :soft_destroy do
... |
github | postalserver/postal | https://github.com/postalserver/postal | app/models/concerns/has_authentication.rb | Ruby | mit | 16,477 | main | 1,833 | # frozen_string_literal: true
module HasAuthentication
extend ActiveSupport::Concern
included do
has_secure_password validations: false
validates :password, length: { minimum: 8, allow_blank: true }
validates :password, confirmation: { allow_blank: true }
validate :validate_password_presence
... |
github | postalserver/postal | https://github.com/postalserver/postal | app/controllers/track_domains_controller.rb | Ruby | mit | 16,477 | main | 1,829 | # frozen_string_literal: true
class TrackDomainsController < ApplicationController
include WithinOrganization
before_action { @server = organization.servers.present.find_by_permalink!(params[:server_id]) }
before_action { params[:id] && @track_domain = @server.track_domains.find_by_uuid!(params[:id]) }
def i... |
github | postalserver/postal | https://github.com/postalserver/postal | app/controllers/user_controller.rb | Ruby | mit | 16,477 | main | 1,851 | # frozen_string_literal: true
class UserController < ApplicationController
skip_before_action :login_required, only: [:new, :create, :join]
def new
@user_invite = UserInvite.active.find_by!(uuid: params[:invite_token])
@user = User.new
@user.email_address = @user_invite.email_address
render layou... |
github | postalserver/postal | https://github.com/postalserver/postal | app/controllers/servers_controller.rb | Ruby | mit | 16,477 | main | 3,201 | # frozen_string_literal: true
class ServersController < ApplicationController
include WithinOrganization
before_action :admin_required, only: [:advanced, :suspend, :unsuspend]
before_action { params[:id] && @server = organization.servers.present.find_by_permalink!(params[:id]) }
def index
@servers = org... |
github | postalserver/postal | https://github.com/postalserver/postal | app/controllers/routes_controller.rb | Ruby | mit | 16,477 | main | 1,069 | # frozen_string_literal: true
class RoutesController < ApplicationController
include WithinOrganization
before_action { @server = organization.servers.present.find_by_permalink!(params[:server_id]) }
before_action { params[:id] && @route = @server.routes.find_by_uuid!(params[:id]) }
def index
@routes = ... |
github | postalserver/postal | https://github.com/postalserver/postal | app/controllers/domains_controller.rb | Ruby | mit | 16,477 | main | 3,905 | # frozen_string_literal: true
class DomainsController < ApplicationController
include WithinOrganization
before_action do
if params[:server_id]
@server = organization.servers.present.find_by_permalink!(params[:server_id])
params[:id] && @domain = @server.domains.find_by_uuid!(params[:id])
els... |
github | postalserver/postal | https://github.com/postalserver/postal | app/controllers/application_controller.rb | Ruby | mit | 16,477 | main | 2,862 | # frozen_string_literal: true
require "authie/session"
class ApplicationController < ActionController::Base
protect_from_forgery with: :exception
before_action :login_required
before_action :set_timezone
rescue_from Authie::Session::InactiveSession, with: :auth_session_error
rescue_from Authie::Session::... |
github | postalserver/postal | https://github.com/postalserver/postal | app/controllers/credentials_controller.rb | Ruby | mit | 16,477 | main | 1,067 | # frozen_string_literal: true
class CredentialsController < ApplicationController
include WithinOrganization
before_action { @server = organization.servers.present.find_by_permalink!(params[:server_id]) }
before_action { params[:id] && @credential = @server.credentials.find_by_uuid!(params[:id]) }
def index... |
github | postalserver/postal | https://github.com/postalserver/postal | app/controllers/webhooks_controller.rb | Ruby | mit | 16,477 | main | 1,291 | # frozen_string_literal: true
class WebhooksController < ApplicationController
include WithinOrganization
before_action { @server = organization.servers.present.find_by_permalink!(params[:server_id]) }
before_action { params[:id] && @webhook = @server.webhooks.find_by_uuid!(params[:id]) }
def index
@webh... |
github | postalserver/postal | https://github.com/postalserver/postal | app/controllers/messages_controller.rb | Ruby | mit | 16,477 | main | 8,376 | # frozen_string_literal: true
class MessagesController < ApplicationController
include WithinOrganization
before_action { @server = organization.servers.present.find_by_permalink!(params[:server_id]) }
before_action { params[:id] && @message = @server.message_db.message(params[:id].to_i) }
def new
if pa... |
github | postalserver/postal | https://github.com/postalserver/postal | app/controllers/sessions_controller.rb | Ruby | mit | 16,477 | main | 3,206 | # frozen_string_literal: true
class SessionsController < ApplicationController
layout "sub"
before_action :require_local_authentication, only: [:create, :begin_password_reset, :finish_password_reset]
skip_before_action :login_required, only: [:new, :create, :begin_password_reset, :finish_password_reset, :ip, :... |
github | postalserver/postal | https://github.com/postalserver/postal | app/controllers/http_endpoints_controller.rb | Ruby | mit | 16,477 | main | 1,278 | # frozen_string_literal: true
class HTTPEndpointsController < ApplicationController
include WithinOrganization
before_action { @server = organization.servers.present.find_by_permalink!(params[:server_id]) }
before_action { params[:id] && @http_endpoint = @server.http_endpoints.find_by_uuid!(params[:id]) }
d... |
github | postalserver/postal | https://github.com/postalserver/postal | app/controllers/users_controller.rb | Ruby | mit | 16,477 | main | 1,599 | # frozen_string_literal: true
class UsersController < ApplicationController
before_action :admin_required
before_action { params[:id] && @user = User.find_by!(uuid: params[:id]) }
def index
@users = User.order(:first_name, :last_name).includes(:organization_users)
end
def new
@user = User.new(admi... |
github | postalserver/postal | https://github.com/postalserver/postal | app/controllers/smtp_endpoints_controller.rb | Ruby | mit | 16,477 | main | 1,232 | # frozen_string_literal: true
class SMTPEndpointsController < ApplicationController
include WithinOrganization
before_action { @server = organization.servers.present.find_by_permalink!(params[:server_id]) }
before_action { params[:id] && @smtp_endpoint = @server.smtp_endpoints.find_by_uuid!(params[:id]) }
de... |
github | postalserver/postal | https://github.com/postalserver/postal | app/controllers/help_controller.rb | Ruby | mit | 16,477 | main | 280 | # frozen_string_literal: true
class HelpController < ApplicationController
include WithinOrganization
before_action { @server = organization.servers.find_by_permalink!(params[:server_id]) }
def outgoing
@credentials = @server.credentials.group_by(&:type)
end
end |
github | postalserver/postal | https://github.com/postalserver/postal | app/controllers/ip_addresses_controller.rb | Ruby | mit | 16,477 | main | 923 | # frozen_string_literal: true
class IPAddressesController < ApplicationController
before_action :admin_required
before_action { @ip_pool = IPPool.find_by_uuid!(params[:ip_pool_id]) }
before_action { params[:id] && @ip_address = @ip_pool.ip_addresses.find(params[:id]) }
def new
@ip_address = @ip_pool.ip_a... |
github | postalserver/postal | https://github.com/postalserver/postal | app/controllers/organizations_controller.rb | Ruby | mit | 16,477 | main | 2,238 | # frozen_string_literal: true
class OrganizationsController < ApplicationController
before_action :admin_required, only: [:new, :create, :delete, :destroy]
def index
if current_user.admin?
@organizations = Organization.present.order(:name).to_a
else
@organizations = current_user.organizations... |
github | postalserver/postal | https://github.com/postalserver/postal | app/controllers/well_known_controller.rb | Ruby | mit | 16,477 | main | 299 | # frozen_string_literal: true
class WellKnownController < ApplicationController
layout false
skip_before_action :set_browser_id
skip_before_action :login_required
skip_before_action :set_timezone
def jwks
render json: JWT::JWK::Set.new(Postal.signer.jwk).export.to_json
end
end |
github | postalserver/postal | https://github.com/postalserver/postal | app/controllers/ip_pools_controller.rb | Ruby | mit | 16,477 | main | 1,163 | # frozen_string_literal: true
class IPPoolsController < ApplicationController
before_action :admin_required
before_action { params[:id] && @ip_pool = IPPool.find_by_uuid!(params[:id]) }
def index
@ip_pools = IPPool.order(:name).to_a
end
def new
@ip_pool = IPPool.new
end
def create
@ip_poo... |
github | postalserver/postal | https://github.com/postalserver/postal | app/controllers/organization_ip_pools_controller.rb | Ruby | mit | 16,477 | main | 453 | # frozen_string_literal: true
class OrganizationIPPoolsController < ApplicationController
include WithinOrganization
before_action :admin_required, only: [:assignments]
def index
@ip_pools = organization.ip_pools.order(:name)
end
def assignments
organization.ip_pool_ids = params[:ip_pools]
org... |
github | postalserver/postal | https://github.com/postalserver/postal | app/controllers/address_endpoints_controller.rb | Ruby | mit | 16,477 | main | 1,264 | # frozen_string_literal: true
class AddressEndpointsController < ApplicationController
include WithinOrganization
before_action { @server = organization.servers.present.find_by_permalink!(params[:server_id]) }
before_action { params[:id] && @address_endpoint = @server.address_endpoints.find_by_uuid!(params[:id... |
github | postalserver/postal | https://github.com/postalserver/postal | app/controllers/ip_pool_rules_controller.rb | Ruby | mit | 16,477 | main | 1,417 | # frozen_string_literal: true
class IPPoolRulesController < ApplicationController
include WithinOrganization
before_action do
if params[:server_id]
@server = organization.servers.present.find_by_permalink!(params[:server_id])
params[:id] && @ip_pool_rule = @server.ip_pool_rules.find_by_uuid!(para... |
github | postalserver/postal | https://github.com/postalserver/postal | app/controllers/concerns/within_organization.rb | Ruby | mit | 16,477 | main | 413 | # frozen_string_literal: true
module WithinOrganization
extend ActiveSupport::Concern
included do
helper_method :organization
before_action :add_organization_to_page_title
end
private
def organization
@organization ||= current_user.organizations_scope.find_by_permalink!(params[:org_permalink]... |
github | postalserver/postal | https://github.com/postalserver/postal | app/controllers/legacy_api/messages_controller.rb | Ruby | mit | 16,477 | main | 4,859 | # frozen_string_literal: true
module LegacyAPI
class MessagesController < BaseController
# Returns details about a given message
#
# URL: /api/v1/messages/message
#
# Parameters: id => REQ: The ID of the message
# _expansions => An array ... |
github | postalserver/postal | https://github.com/postalserver/postal | app/controllers/legacy_api/base_controller.rb | Ruby | mit | 16,477 | main | 4,600 | # frozen_string_literal: true
module LegacyAPI
# The Legacy API is the Postal v1 API which existed from the start with main
# aim of allowing e-mails to sent over HTTP rather than SMTP. The API itself
# did not feature much functionality. This API was implemented using Moonrope
# which was a self documenting A... |
github | postalserver/postal | https://github.com/postalserver/postal | app/controllers/legacy_api/send_controller.rb | Ruby | mit | 16,477 | main | 5,923 | # frozen_string_literal: true
module LegacyAPI
class SendController < BaseController
ERROR_MESSAGES = {
"NoRecipients" => "There are no recipients defined to receive this message",
"NoContent" => "There is no content defined for this e-mail",
"TooManyToAddresses" => "The maximum number of To a... |
github | postalserver/postal | https://github.com/postalserver/postal | app/util/has_prometheus_metrics.rb | Ruby | mit | 16,477 | main | 771 | # frozen_string_literal: true
module HasPrometheusMetrics
def register_prometheus_counter(name, **kwargs)
counter = Prometheus::Client::Counter.new(name, **kwargs)
registry.register(counter)
end
def register_prometheus_histogram(name, **kwargs)
histogram = Prometheus::Client::Histogram.new(name, **... |
github | postalserver/postal | https://github.com/postalserver/postal | app/util/health_server.rb | Ruby | mit | 16,477 | main | 2,771 | # frozen_string_literal: true
require "socket"
require "rackup/handler/webrick"
require "prometheus/client/formats/text"
class HealthServer
def initialize(name: "unnamed-process")
@name = name
end
def call(env)
case env["PATH_INFO"]
when "/health"
ok
when "/metrics"
metrics
whe... |
github | postalserver/postal | https://github.com/postalserver/postal | app/util/user_creator.rb | Ruby | mit | 16,477 | main | 1,025 | # frozen_string_literal: true
require "highline"
module UserCreator
class << self
def start(&block)
cli = HighLine.new
puts "\e[32mPostal User Creator\e[0m"
puts "Enter the information required to create a new Postal user."
puts "This tool is usually only used to create your initial ad... |
github | postalserver/postal | https://github.com/postalserver/postal | app/helpers/application_helper.rb | Ruby | mit | 16,477 | main | 3,787 | # frozen_string_literal: true
module ApplicationHelper
def format_delivery_details(server, text)
text = h(text)
text.gsub!(/<msg:(\d+)>/) do
id = ::Regexp.last_match(1).to_i
link_to("message ##{id}", organization_server_message_path(server.organization, server, id), class: "u-link")
end
... |
github | postalserver/postal | https://github.com/postalserver/postal | db/schema.rb | Ruby | mit | 16,477 | main | 14,230 | # This file is auto-generated from the current state of the database. Instead
# of editing this file, please use the migrations feature of Active Record to
# incrementally modify your database, and then regenerate this schema definition.
#
# This file is the source Rails uses to define your schema when running `bin/rai... |
github | postalserver/postal | https://github.com/postalserver/postal | db/migrate/20170418200606_initial_schema.rb | Ruby | mit | 16,477 | main | 15,060 | # frozen_string_literal: true
class InitialSchema < ActiveRecord::Migration
def up
create_table "additional_route_endpoints", force: :cascade, options: "ENGINE=InnoDB DEFAULT CHARSET=utf8mb4" do |t|
t.integer "route_id"
t.string "endpoint_type"
t.integer "endpoint_id"
t.datetime "cre... |
github | postalserver/postal | https://github.com/postalserver/postal | db/migrate/20210727210551_add_priority_to_ip_addresses.rb | Ruby | mit | 16,477 | main | 229 | # frozen_string_literal: true
class AddPriorityToIPAddresses < ActiveRecord::Migration[5.2]
def change
add_column :ip_addresses, :priority, :integer
IPAddress.where(priority: nil).update_all(priority: 100)
end
end |
github | postalserver/postal | https://github.com/postalserver/postal | db/migrate/20170421195415_add_index_to_token_hashes_on_authie_sessions.authie.rb | Ruby | mit | 16,477 | main | 244 | # frozen_string_literal: true
# This migration comes from authie (originally 20170421174100)
class AddIndexToTokenHashesOnAuthieSessions < ActiveRecord::Migration
def change
add_index :authie_sessions, :token_hash, length: 8
end
end |
github | postalserver/postal | https://github.com/postalserver/postal | db/migrate/20240213165450_create_worker_roles.rb | Ruby | mit | 16,477 | main | 265 | # frozen_string_literal: true
class CreateWorkerRoles < ActiveRecord::Migration[6.1]
def change
create_table :worker_roles do |t|
t.string :role
t.string :worker
t.datetime :acquired_at
t.index :role, unique: true
end
end
end |
github | postalserver/postal | https://github.com/postalserver/postal | db/migrate/20240223141500_add_two_factor_required_to_sessions.authie.rb | Ruby | mit | 16,477 | main | 263 | # frozen_string_literal: true
# This migration comes from authie (originally 20220502180100)
class AddTwoFactorRequiredToSessions < ActiveRecord::Migration[6.1]
def change
add_column :authie_sessions, :skip_two_factor, :boolean, default: false
end
end |
github | postalserver/postal | https://github.com/postalserver/postal | db/migrate/20180216114344_add_host_to_authie_sessions.authie.rb | Ruby | mit | 16,477 | main | 228 | # frozen_string_literal: true
# This migration comes from authie (originally 20180215152200)
class AddHostToAuthieSessions < ActiveRecord::Migration[4.2]
def change
add_column :authie_sessions, :host, :string
end
end |
github | postalserver/postal | https://github.com/postalserver/postal | db/migrate/20200717083943_add_uuid_to_credentials.rb | Ruby | mit | 16,477 | main | 246 | # frozen_string_literal: true
class AddUUIDToCredentials < ActiveRecord::Migration[5.2]
def change
add_column :credentials, :uuid, :string
Credential.find_each do |c|
c.update_column(:uuid, SecureRandom.uuid)
end
end
end |
github | postalserver/postal | https://github.com/postalserver/postal | db/migrate/20240311205229_add_oidc_fields_to_user.rb | Ruby | mit | 16,477 | main | 200 | # frozen_string_literal: true
class AddOIDCFieldsToUser < ActiveRecord::Migration[7.0]
def change
add_column :users, :oidc_uid, :string
add_column :users, :oidc_issuer, :string
end
end |
github | postalserver/postal | https://github.com/postalserver/postal | db/migrate/20240213171830_create_scheduled_tasks.rb | Ruby | mit | 16,477 | main | 251 | # frozen_string_literal: true
class CreateScheduledTasks < ActiveRecord::Migration[6.1]
def change
create_table :scheduled_tasks do |t|
t.string :name
t.datetime :next_run_after
t.index :name, unique: true
end
end
end |
github | postalserver/postal | https://github.com/postalserver/postal | db/migrate/20240223141501_add_countries_to_authie_sessions.authie.rb | Ruby | mit | 16,477 | main | 380 | # frozen_string_literal: true
# This migration comes from authie (originally 20230627165500)
class AddCountriesToAuthieSessions < ActiveRecord::Migration[6.1]
def change
add_column :authie_sessions, :login_ip_country, :string
add_column :authie_sessions, :two_factored_ip_country, :string
add_column :aut... |
github | postalserver/postal | https://github.com/postalserver/postal | db/migrate/20240214132253_add_lock_fields_to_webhook_requests.rb | Ruby | mit | 16,477 | main | 279 | # frozen_string_literal: true
class AddLockFieldsToWebhookRequests < ActiveRecord::Migration[6.1]
def change
add_column :webhook_requests, :locked_by, :string
add_column :webhook_requests, :locked_at, :datetime
add_index :webhook_requests, :locked_by
end
end |
github | postalserver/postal | https://github.com/postalserver/postal | spec/spec_helper.rb | Ruby | mit | 16,477 | main | 299 | # frozen_string_literal: true
RSpec.configure do |config|
config.color = true
config.expect_with :rspec do |expectations|
expectations.include_chain_clauses_in_custom_matcher_descriptions = true
end
config.mock_with :rspec do |mocks|
mocks.verify_partial_doubles = true
end
end |
github | postalserver/postal | https://github.com/postalserver/postal | spec/rails_helper.rb | Ruby | mit | 16,477 | main | 1,435 | # frozen_string_literal: true
ENV["POSTAL_CONFIG_FILE_PATH"] ||= "config/postal/postal.test.yml"
require "dotenv"
Dotenv.load(".env.test")
require File.expand_path("../config/environment", __dir__)
require "rspec/rails"
require "spec_helper"
require "factory_bot"
require "timecop"
require "webmock/rspec"
require "sh... |
github | postalserver/postal | https://github.com/postalserver/postal | spec/apis/legacy_api/messages/deliveries_spec.rb | Ruby | mit | 16,477 | main | 5,320 | # frozen_string_literal: true
require "rails_helper"
RSpec.describe "Legacy Messages API", type: :request do
describe "/api/v1/messages/deliveries" do
context "when no authentication is provided" do
it "returns an error" do
post "/api/v1/messages/deliveries"
expect(response.status).to eq 2... |
github | postalserver/postal | https://github.com/postalserver/postal | spec/apis/legacy_api/messages/message_spec.rb | Ruby | mit | 16,477 | main | 12,379 | # frozen_string_literal: true
require "rails_helper"
RSpec.describe "Legacy Messages API", type: :request do
describe "/api/v1/messages/message" do
context "when no authentication is provided" do
it "returns an error" do
post "/api/v1/messages/message"
expect(response.status).to eq 200
... |
github | postalserver/postal | https://github.com/postalserver/postal | spec/apis/legacy_api/send/message_spec.rb | Ruby | mit | 16,477 | main | 10,474 | # frozen_string_literal: true
require "rails_helper"
RSpec.describe "Legacy Send API", type: :request do
describe "/api/v1/send/message" do
context "when no authentication is provided" do
it "returns an error" do
post "/api/v1/send/message"
expect(response.status).to eq 200
parsed_... |
github | postalserver/postal | https://github.com/postalserver/postal | spec/apis/legacy_api/send/raw_spec.rb | Ruby | mit | 16,477 | main | 6,468 | # frozen_string_literal: true
require "rails_helper"
RSpec.describe "Legacy Send API", type: :request do
describe "/api/v1/send/raw" do
context "when no authentication is provided" do
it "returns an error" do
post "/api/v1/send/raw"
expect(response.status).to eq 200
parsed_body = J... |
github | postalserver/postal | https://github.com/postalserver/postal | spec/scheduled_tasks/tidy_queued_messages_task_spec.rb | Ruby | mit | 16,477 | main | 971 | # frozen_string_literal: true
require "rails_helper"
RSpec.describe TidyQueuedMessagesTask do
let(:logger) { TestLogger.new }
subject(:task) { described_class.new(logger: logger) }
describe "#call" do
it "destroys queued messages with stale locks" do
stale_message = create(:queued_message, locked_at... |
github | postalserver/postal | https://github.com/postalserver/postal | spec/models/domain_spec.rb | Ruby | mit | 16,477 | main | 10,779 | # frozen_string_literal: true
# == Schema Information
#
# Table name: domains
#
# id :integer not null, primary key
# dkim_error :string(255)
# dkim_identifier_string :string(255)
# dkim_private_key :text(65535)
# dkim_status :string(255)
# dns_checked_at... |
github | postalserver/postal | https://github.com/postalserver/postal | spec/models/queued_message_spec.rb | Ruby | mit | 16,477 | main | 8,028 | # frozen_string_literal: true
# == Schema Information
#
# Table name: queued_messages
#
# id :integer not null, primary key
# attempts :integer default(0)
# batch_key :string(255)
# domain :string(255)
# locked_at :datetime
# locked_by :string(255)
# manual ... |
github | postalserver/postal | https://github.com/postalserver/postal | spec/models/server_spec.rb | Ruby | mit | 16,477 | main | 23,325 | # frozen_string_literal: true
# == Schema Information
#
# Table name: servers
#
# id :integer not null, primary key
# allow_sender :boolean default(FALSE)
# deleted_at :datetime
# domains_not_to_click_track :tex... |
github | postalserver/postal | https://github.com/postalserver/postal | spec/models/organization_spec.rb | Ruby | mit | 16,477 | main | 879 | # frozen_string_literal: true
# == Schema Information
#
# Table name: organizations
#
# id :integer not null, primary key
# deleted_at :datetime
# name :string(255)
# permalink :string(255)
# suspended_at :datetime
# suspension_reason :string(255)
# time_... |
github | postalserver/postal | https://github.com/postalserver/postal | spec/models/user_spec.rb | Ruby | mit | 16,477 | main | 4,145 | # frozen_string_literal: true
# == Schema Information
#
# Table name: users
#
# id :integer not null, primary key
# admin :boolean default(FALSE)
# email_address :string(255)
# email_verification_token :string(255... |
github | postalserver/postal | https://github.com/postalserver/postal | spec/models/worker_role_spec.rb | Ruby | mit | 16,477 | main | 2,074 | # frozen_string_literal: true
# == Schema Information
#
# Table name: worker_roles
#
# id :bigint not null, primary key
# acquired_at :datetime
# role :string(255)
# worker :string(255)
#
# Indexes
#
# index_worker_roles_on_role (role) UNIQUE
#
require "rails_helper"
RSpec.describ... |
github | postalserver/postal | https://github.com/postalserver/postal | spec/models/outgoing_message_prototype_spec.rb | Ruby | mit | 16,477 | main | 654 | # frozen_string_literal: true
require "rails_helper"
describe OutgoingMessagePrototype do
let(:server) { create(:server) }
it "should create a new message" do
domain = create(:domain, owner: server)
prototype = OutgoingMessagePrototype.new(server, "127.0.0.1", "TestSuite", {
from: "test@#{domain.nam... |
github | postalserver/postal | https://github.com/postalserver/postal | spec/models/user/authentication_spec.rb | Ruby | mit | 16,477 | main | 883 | # frozen_string_literal: true
require "rails_helper"
RSpec.describe User do
describe ".authenticate" do
it "does not authenticate users with invalid emails" do
expect { User.authenticate("nothing@nothing.com", "hello") }.to raise_error(Postal::Errors::AuthenticationError) do |e|
expect(e.error).to... |
github | postalserver/postal | https://github.com/postalserver/postal | spec/models/user/oidc_spec.rb | Ruby | mit | 16,477 | main | 3,534 | # frozen_string_literal: true
require "rails_helper"
RSpec.describe User do
let(:user) { build(:user) }
describe "#oidc?" do
it "returns true if the user has an OIDC UID" do
user.oidc_uid = "123"
expect(user.oidc?).to be true
end
it "returns false if the user does not have an OIDC UID" d... |
github | postalserver/postal | https://github.com/postalserver/postal | spec/factories/ip_pool_factory.rb | Ruby | mit | 16,477 | main | 590 | # frozen_string_literal: true
# == Schema Information
#
# Table name: ip_pools
#
# id :integer not null, primary key
# default :boolean default(FALSE)
# name :string(255)
# uuid :string(255)
# created_at :datetime
# updated_at :datetime
#
# Indexes
#
# index_ip_pools_on_... |
github | postalserver/postal | https://github.com/postalserver/postal | spec/factories/domain_factory.rb | Ruby | mit | 16,477 | main | 1,714 | # frozen_string_literal: true
# == Schema Information
#
# Table name: domains
#
# id :integer not null, primary key
# server_id :integer
# uuid :string(255)
# name :string(255)
# verification_token :string(255)
# verification_metho... |
github | postalserver/postal | https://github.com/postalserver/postal | spec/factories/http_endpoint_factory.rb | Ruby | mit | 16,477 | main | 870 | # frozen_string_literal: true
# == Schema Information
#
# Table name: http_endpoints
#
# id :integer not null, primary key
# disabled_until :datetime
# encoding :string(255)
# error :text(65535)
# format :string(255)
# include_attachments :bool... |
github | postalserver/postal | https://github.com/postalserver/postal | spec/factories/route_factory.rb | Ruby | mit | 16,477 | main | 756 | # frozen_string_literal: true
# == Schema Information
#
# Table name: routes
#
# id :integer not null, primary key
# endpoint_type :string(255)
# mode :string(255)
# name :string(255)
# spam_mode :string(255)
# token :string(255)
# uuid :string(255)
# ... |
github | postalserver/postal | https://github.com/postalserver/postal | spec/factories/server_factory.rb | Ruby | mit | 16,477 | main | 2,273 | # frozen_string_literal: true
# == Schema Information
#
# Table name: servers
#
# id :integer not null, primary key
# allow_sender :boolean default(FALSE)
# deleted_at :datetime
# domains_not_to_click_track :tex... |
github | postalserver/postal | https://github.com/postalserver/postal | spec/factories/track_domain_factory.rb | Ruby | mit | 16,477 | main | 983 | # frozen_string_literal: true
# == Schema Information
#
# Table name: track_domains
#
# id :integer not null, primary key
# uuid :string(255)
# server_id :integer
# domain_id :integer
# name :string(255)
# dns_checked_at ... |
github | postalserver/postal | https://github.com/postalserver/postal | spec/factories/queued_message_factory.rb | Ruby | mit | 16,477 | main | 1,488 | # frozen_string_literal: true
# == Schema Information
#
# Table name: queued_messages
#
# id :integer not null, primary key
# attempts :integer default(0)
# batch_key :string(255)
# domain :string(255)
# locked_at :datetime
# locked_by :string(255)
# manual ... |
github | postalserver/postal | https://github.com/postalserver/postal | spec/factories/organization_factory.rb | Ruby | mit | 16,477 | main | 877 | # frozen_string_literal: true
# == Schema Information
#
# Table name: organizations
#
# id :integer not null, primary key
# uuid :string(255)
# name :string(255)
# permalink :string(255)
# time_zone :string(255)
# created_at :datetime
# up... |
github | postalserver/postal | https://github.com/postalserver/postal | spec/factories/address_endpoint_factory.rb | Ruby | mit | 16,477 | main | 471 | # frozen_string_literal: true
# == Schema Information
#
# Table name: address_endpoints
#
# id :integer not null, primary key
# address :string(255)
# last_used_at :datetime
# uuid :string(255)
# created_at :datetime not null
# updated_at :datetime not null
# ... |
github | postalserver/postal | https://github.com/postalserver/postal | spec/factories/ip_address_factory.rb | Ruby | mit | 16,477 | main | 498 | # frozen_string_literal: true
# == Schema Information
#
# Table name: ip_addresses
#
# id :integer not null, primary key
# hostname :string(255)
# ipv4 :string(255)
# ipv6 :string(255)
# priority :integer
# created_at :datetime
# updated_at :datetime
# ip_pool_id :integer
#
Fac... |
github | postalserver/postal | https://github.com/postalserver/postal | spec/factories/worker_role_factory.rb | Ruby | mit | 16,477 | main | 360 | # frozen_string_literal: true
# == Schema Information
#
# Table name: worker_roles
#
# id :bigint not null, primary key
# acquired_at :datetime
# role :string(255)
# worker :string(255)
#
# Indexes
#
# index_worker_roles_on_role (role) UNIQUE
#
FactoryBot.define do
factory :worke... |
github | postalserver/postal | https://github.com/postalserver/postal | spec/factories/user_factory.rb | Ruby | mit | 16,477 | main | 1,227 | # frozen_string_literal: true
# == Schema Information
#
# Table name: users
#
# id :integer not null, primary key
# admin :boolean default(FALSE)
# email_address :string(255)
# email_verification_token :string(255... |
github | postalserver/postal | https://github.com/postalserver/postal | spec/factories/webhook_request_factory.rb | Ruby | mit | 16,477 | main | 927 | # frozen_string_literal: true
# == Schema Information
#
# Table name: webhook_requests
#
# id :integer not null, primary key
# attempts :integer default(0)
# error :text(65535)
# event :string(255)
# locked_at :datetime
# locked_by :string(255)
# payload :text(6... |
github | postalserver/postal | https://github.com/postalserver/postal | spec/factories/smtp_endpoint_factory.rb | Ruby | mit | 16,477 | main | 647 | # frozen_string_literal: true
# == Schema Information
#
# Table name: smtp_endpoints
#
# id :integer not null, primary key
# disabled_until :datetime
# error :text(65535)
# hostname :string(255)
# last_used_at :datetime
# name :string(255)
# port :intege... |
github | postalserver/postal | https://github.com/postalserver/postal | spec/factories/webhook_factory.rb | Ruby | mit | 16,477 | main | 686 | # frozen_string_literal: true
# == Schema Information
#
# Table name: webhooks
#
# id :integer not null, primary key
# all_events :boolean default(FALSE)
# enabled :boolean default(TRUE)
# last_used_at :datetime
# name :string(255)
# sign :boolean ... |
github | postalserver/postal | https://github.com/postalserver/postal | spec/factories/ip_pool_rule_factory.rb | Ruby | mit | 16,477 | main | 724 | # frozen_string_literal: true
# == Schema Information
#
# Table name: ip_pool_rules
#
# id :integer not null, primary key
# from_text :text(65535)
# owner_type :string(255)
# to_text :text(65535)
# uuid :string(255)
# created_at :datetime not null
# updated_at :datetime ... |
github | postalserver/postal | https://github.com/postalserver/postal | spec/factories/credential_factory.rb | Ruby | mit | 16,477 | main | 560 | # frozen_string_literal: true
# == Schema Information
#
# Table name: credentials
#
# id :integer not null, primary key
# hold :boolean default(FALSE)
# key :string(255)
# last_used_at :datetime
# name :string(255)
# options :text(65535)
# type :... |
github | postalserver/postal | https://github.com/postalserver/postal | spec/senders/smtp_sender_spec.rb | Ruby | mit | 16,477 | main | 20,765 | # frozen_string_literal: true
require "rails_helper"
RSpec.describe SMTPSender do
subject(:sender) { described_class.new("example.com") }
let(:smtp_start_error) { nil }
let(:smtp_send_message_error) { nil }
let(:smtp_send_message_result) { double("Result", string: "accepted") }
before do
# Mock the SM... |
github | postalserver/postal | https://github.com/postalserver/postal | spec/helpers/message_factory.rb | Ruby | mit | 16,477 | main | 1,637 | # frozen_string_literal: true
# This class can be used to generate a message which can be used for the purposes of
# testing within the given server.
class MessageFactory
def initialize(server)
@server = server
end
def incoming(route: nil, &block)
@message = @server.message_db.new_message
@message.... |
github | postalserver/postal | https://github.com/postalserver/postal | spec/helpers/message_db_mocking.rb | Ruby | mit | 16,477 | main | 893 | # frozen_string_literal: true
module GlobalMessageDB
class << self
def find_or_create
return @db if @db
@db = Postal::MessageDB::Database.new(1, 1, database_name: "postal-test-message-db")
@db.provisioner.provision
end
def exists?
!@db.nil?
end
end
end
RSpec.configure... |
github | postalserver/postal | https://github.com/postalserver/postal | spec/helpers/general_helpers.rb | Ruby | mit | 16,477 | main | 550 | # frozen_string_literal: true
module GeneralHelpers
def create_plain_text_message(server, text, to = "test@example.com", override_attributes = {})
domain = create(:domain, owner: server)
attributes = { from: "test@#{domain.name}", subject: "Test Plain Text Message" }.merge(override_attributes)
attribute... |
github | postalserver/postal | https://github.com/postalserver/postal | spec/helpers/test_logger.rb | Ruby | mit | 16,477 | main | 940 | # frozen_string_literal: true
class TestLogger
def initialize
@log_lines = []
@group_set = Klogger::GroupSet.new
@print = false
end
def print!
@print = true
end
def add(level, message, **tags)
@group_set.groups.each do |group|
tags = group[:tags].merge(tags)
end
@log_lin... |
github | postalserver/postal | https://github.com/postalserver/postal | spec/services/webhook_delivery_service_spec.rb | Ruby | mit | 16,477 | main | 4,223 | # frozen_string_literal: true
require "rails_helper"
RSpec.describe WebhookDeliveryService do
let(:server) { create(:server) }
let(:webhook) { create(:webhook, server: server) }
let(:webhook_request) { create(:webhook_request, :locked, webhook: webhook) }
subject(:service) { described_class.new(webhook_reque... |
github | postalserver/postal | https://github.com/postalserver/postal | spec/lib/message_dequeuer_spec.rb | Ruby | mit | 16,477 | main | 537 | # frozen_string_literal: true
require "rails_helper"
RSpec.describe MessageDequeuer do
describe ".process" do
it "calls the initial process with the given message and logger" do
message = create(:queued_message)
logger = TestLogger.new
mock = double("InitialProcessor")
expect(mock).to r... |
github | postalserver/postal | https://github.com/postalserver/postal | spec/lib/dns_resolver_spec.rb | Ruby | mit | 16,477 | main | 9,656 | # frozen_string_literal: true
require "rails_helper"
RSpec.describe DNSResolver do
subject(:resolver) { described_class.local }
# Now, we could mock everything in here which would give us some comfort
# but I do think that we'll benefit more from having a full E2E test here
# so we'll test this using values ... |
github | postalserver/postal | https://github.com/postalserver/postal | spec/lib/postal_spec.rb | Ruby | mit | 16,477 | main | 619 | # frozen_string_literal: true
require "rails_helper"
RSpec.describe Postal do
describe "#signer" do
it "returns a signer with the installation's signing key" do
expect(Postal.signer).to be_a(Postal::Signer)
expect(Postal.signer.private_key.to_pem).to eq OpenSSL::PKey::RSA.new(File.read(Postal::Confi... |
github | postalserver/postal | https://github.com/postalserver/postal | spec/lib/dkim_header_spec.rb | Ruby | mit | 16,477 | main | 1,397 | # frozen_string_literal: true
require "rails_helper"
describe DKIMHeader do
examples = Rails.root.join("spec/examples/dkim_signing/*.msg")
Dir[examples].each do |path|
contents = File.read(path)
frontmatter, email = contents.split(/^---\n/m, 2)
frontmatter = YAML.safe_load(frontmatter)
email.strip... |
github | postalserver/postal | https://github.com/postalserver/postal | spec/lib/received_header_spec.rb | Ruby | mit | 16,477 | main | 1,853 | # frozen_string_literal: true
require "rails_helper"
describe ReceivedHeader do
before do
allow(DNSResolver.local).to receive(:ip_to_hostname).and_return("hostname.com")
end
describe ".generate" do
context "when server is nil" do
it "returns the correct string" do
result = described_class... |
github | postalserver/postal | https://github.com/postalserver/postal | spec/lib/query_string_spec.rb | Ruby | mit | 16,477 | main | 1,425 | # frozen_string_literal: true
require "rails_helper"
describe QueryString do
it "works with a single item" do
qs = described_class.new("to: test@example.com")
expect(qs.hash["to"]).to eq "test@example.com"
end
it "works with a multiple items" do
qs = described_class.new("to: test@example.com from: ... |
github | postalserver/postal | https://github.com/postalserver/postal | spec/lib/message_dequeuer/base_spec.rb | Ruby | mit | 16,477 | main | 962 | # frozen_string_literal: true
require "rails_helper"
module MessageDequeuer
RSpec.describe Base do
describe ".new" do
context "when given state" do
it "uses that state" do
base = described_class.new(nil, logger: nil, state: 1234)
expect(base.state).to eq 1234
end
... |
github | postalserver/postal | https://github.com/postalserver/postal | spec/lib/message_dequeuer/state_spec.rb | Ruby | mit | 16,477 | main | 1,101 | # frozen_string_literal: true
require "rails_helper"
module MessageDequeuer
RSpec.describe State do
subject(:state) { described_class.new }
describe "#send_result" do
it "can be get and set" do
result = instance_double(SendResult)
state.send_result = result
expect(state.send_... |
github | postalserver/postal | https://github.com/postalserver/postal | spec/lib/message_dequeuer/outgoing_message_processor_spec.rb | Ruby | mit | 16,477 | main | 18,705 | # frozen_string_literal: true
require "rails_helper"
module MessageDequeuer
RSpec.describe OutgoingMessageProcessor do
let(:server) { create(:server) }
let(:state) { State.new }
let(:logger) { TestLogger.new }
let(:domain) { create(:domain, server: server) }
let(:credential) { create(:credentia... |
github | postalserver/postal | https://github.com/postalserver/postal | spec/lib/message_dequeuer/single_message_processor_spec.rb | Ruby | mit | 16,477 | main | 4,401 | # frozen_string_literal: true
require "rails_helper"
module MessageDequeuer
RSpec.describe SingleMessageProcessor do
let(:server) { create(:server) }
let(:state) { State.new }
let(:logger) { TestLogger.new }
let(:route) { create(:route, server: server) }
let(:message) { MessageFactory.incoming(... |
github | postalserver/postal | https://github.com/postalserver/postal | spec/lib/message_dequeuer/incoming_message_processor_spec.rb | Ruby | mit | 16,477 | main | 22,669 | # frozen_string_literal: true
require "rails_helper"
module MessageDequeuer
RSpec.describe IncomingMessageProcessor do
let(:server) { create(:server) }
let(:state) { State.new }
let(:logger) { TestLogger.new }
let(:route) { create(:route, server: server) }
let(:message) { MessageFactory.incomin... |
github | postalserver/postal | https://github.com/postalserver/postal | spec/lib/message_dequeuer/initial_message_processor_spec.rb | Ruby | mit | 16,477 | main | 4,007 | # frozen_string_literal: true
require "rails_helper"
module MessageDequeuer
RSpec.describe InitialProcessor do
let(:server) { create(:server) }
let(:logger) { TestLogger.new }
let(:route) { create(:route, server: server) }
let(:message) { MessageFactory.incoming(server, route: route) }
let(:que... |
github | postalserver/postal | https://github.com/postalserver/postal | spec/lib/postal/message_parser_spec.rb | Ruby | mit | 16,477 | main | 959 | # frozen_string_literal: true
require "rails_helper"
describe Postal::MessageParser do
let(:server) { create(:server) }
it "should not do anything when there are no tracking domains" do
expect(server.track_domains.size).to eq 0
message = create_plain_text_message(server, "Hello world!", "test@example.com... |
github | postalserver/postal | https://github.com/postalserver/postal | spec/lib/postal/legacy_config_source_spec.rb | Ruby | mit | 16,477 | main | 11,038 | # frozen_string_literal: true
require "rails_helper"
module Postal
SOURCE_CONFIG = YAML.safe_load(File.read(Rails.root.join("spec/examples/full_legacy_config_file.yml")))
# Rather than actuall test the LegacyConfigSource directly, I have decided
# to test this source via. the Konfig::Config system to ensure i... |
github | postalserver/postal | https://github.com/postalserver/postal | spec/lib/postal/signer_spec.rb | Ruby | mit | 16,477 | main | 2,682 | # frozen_string_literal: true
require "rails_helper"
module Postal
RSpec.describe Signer do
STATIC_PRIVATE_KEY = OpenSSL::PKey::RSA.new(2048) # rubocop:disable Lint/ConstantDefinitionInBlock
subject(:signer) { described_class.new(STATIC_PRIVATE_KEY) }
describe "#private_key" do
it "returns the p... |
github | postalserver/postal | https://github.com/postalserver/postal | spec/lib/postal/message_db/connection_pool_spec.rb | Ruby | mit | 16,477 | main | 1,481 | # frozen_string_literal: true
require "rails_helper"
describe Postal::MessageDB::ConnectionPool do
subject(:pool) { described_class.new }
describe "#use" do
it "yields a connection" do
counter = 0
pool.use do |connection|
expect(connection).to be_a Mysql2::Client
counter += 1
... |
github | postalserver/postal | https://github.com/postalserver/postal | spec/lib/postal/message_db/database_spec.rb | Ruby | mit | 16,477 | main | 438 | # frozen_string_literal: true
require "rails_helper"
describe Postal::MessageDB::Database do
context "when provisioned" do
let(:server) { create(:server) }
subject(:database) { server.message_db }
it "should be a message db" do
expect(database).to be_a Postal::MessageDB::Database
end
it ... |
github | postalserver/postal | https://github.com/postalserver/postal | spec/lib/smtp_client/endpoint_spec.rb | Ruby | mit | 16,477 | main | 9,715 | # frozen_string_literal: true
require "rails_helper"
module SMTPClient
RSpec.describe Endpoint do
let(:ssl_mode) { SSLModes::AUTO }
let(:server) { Server.new("mx1.example.com", port: 25, ssl_mode: ssl_mode) }
let(:ip) { "1.2.3.4" }
before do
allow(Net::SMTP).to receive(:new).and_wrap_origina... |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.