62
  L   ˆl–ßi~”Je¶¥	@9q¶î•1hß�þ[++6P¸"‰§�”€þÊƒ`wÉ_•uÐb&=LwªEê?qÈi©_æÿÁÈ ã    # This file is commonly accessed via passdb {} or userdb {} section in
# conf.d/auth-dict.conf.ext

# Dictionary URI
#uri = 

# Default password scheme
default_pass_scheme = MD5

# Username iteration prefix. Keys under this are assumed to contain usernames.
iterate_prefix = userdb/

# Should iteration be disabled for this userdb? If this userdb acts only as a
# cache there's no reason to try to iterate the (partial & duplicate) users.
#iterate_disable = no

# The example here shows how to do multiple dict lookups and merge the replies.
# The "passdb" and "userdb" keys are JSON objects containing key/value pairs,
# for example: { "uid": 1000, "gid": 1000, "home": "/home/user" }

key passdb {
  key = passdb/%u
  format = json
}
key userdb {
  key = userdb/%u
  format = json
}
key quota {
  key = userdb/%u/quota
  #format = value
  # The default_value is used if the key isn't found. If default_value setting
  # isn't specified at all (even as empty), the passdb/userdb lookup fails with
  # "user doesn't exist".
  default_value = 100M
}

# Space separated list of keys whose values contain key/value paired objects.
# All the key/value pairs inside the object are added as passdb fields.
passdb_objects = passdb

#passdb_fields {
#}

# Userdb key/value object list.
userdb_objects = userdb

userdb_fields {
  # dict:<key> refers to key names
  quota_rule = *:storage=%{dict:quota}

  # dict:<key>.<objkey> refers to the objkey inside (JSON) object
  mail = maildir:%{dict:userdb.home}/Maildir
}
  F   ˆl–ßi~”Šj"Tâ‚Æ[¸ØÅ£�þdm¡¬ãr2C]ìÿ?Ì„m§ /Ë_�uÐb&=LyZËcõÃÊ ?÷     # Copyright (C) 2012-2026 Zammad Foundation, https://zammad-foundation.org/

require 'rails_helper'

RSpec.describe AI::ProviderConnection, type: :model do
  subject(:provider_connection) { create(:ai_provider_connection) }

  describe 'Validations' do
    it { is_expected.to validate_presence_of(:name) }
    it { is_expected.to validate_presence_of(:provider) }
    it { is_expected.to validate_uniqueness_of(:name).case_insensitive }

    it 'accepts a supported provider' do
      expect(build(:ai_provider_connection, provider: 'open_ai')).to be_valid
    end

    it 'rejects an unknown provider' do
      expect(build(:ai_provider_connection, provider: 'does_not_exist')).not_to be_valid
    end

    # The embedding model used to be resolved from the adapter at request time, so the connection
    # serving embeddings could carry none: Setting::Validation::VectorDB kept passing and the
    # failure only surfaced when indexing ran.
    describe 'embedding model of the connection serving embeddings' do
      it 'accepts a connection that names its embedding model' do
        connection = build(:ai_provider_connection, :default_embedding, provider: 'open_ai',
                                                                        config:   { token: 'a', embedding_model: 'text-embedding-3-small' })

        expect(connection).to be_valid
      end

      it 'rejects one that does not' do
        connection = build(:ai_provider_connection, :default_embedding, provider: 'open_ai', config: { token: 'a' })

        expect(connection).not_to be_valid
      end

      it 'rejects one whose embedding model was cleared' do
        connection = build(:ai_provider_connection, :default_embedding, provider: 'open_ai',
                                                                        config:   { token: 'a', embedding_model: '' })

        expect(connection).not_to be_valid
      end

      # The dialog clears the field, the API replaces the whole config - either way semantic search
      # must not switch itself off behind a "successfully updated".
      context 'with a stored connection' do
        let(:connection) { create(:ai_provider_connection, provider: 'open_ai', config: { token: 'a' }).reload }

        it 'rejects clearing its embedding model', :aggregate_failures do
          expect(connection.update(config: { 'token' => 'a', 'embedding_model' => '' })).to be(fals