Espone API JSON e MCP HTTP per far lavorare gli agenti sul CRM.
Gli agenti autenticati con token Bearer possono leggere today/pipeline e annotare attività, con host MCP allineati a quelli di produzione. Co-authored-by: Cursor <cursoragent@cursor.com>
This commit is contained in:
@@ -0,0 +1,24 @@
|
||||
require "test_helper"
|
||||
|
||||
class ApiTokenTest < ActiveSupport::TestCase
|
||||
test "issue returns plaintext once and authenticates" do
|
||||
token = ApiToken.issue!(user: users(:marco), name: "Cursor")
|
||||
assert token.plaintext.start_with?("crm_")
|
||||
assert_equal token.plaintext[0, 8], token.token_prefix
|
||||
|
||||
found = ApiToken.authenticate(token.plaintext)
|
||||
assert_equal token.id, found.id
|
||||
end
|
||||
|
||||
test "revoked or inactive user does not authenticate" do
|
||||
token = ApiToken.issue!(user: users(:marco), name: "tmp")
|
||||
raw = token.plaintext
|
||||
token.revoke!
|
||||
assert_nil ApiToken.authenticate(raw)
|
||||
end
|
||||
|
||||
test "blank token does not authenticate" do
|
||||
assert_nil ApiToken.authenticate(nil)
|
||||
assert_nil ApiToken.authenticate("")
|
||||
end
|
||||
end
|
||||
Reference in New Issue
Block a user