|
| 1 | +# -------------------------------------------------------------------- |
| 2 | +# Copyright (c) 2025, WSO2 LLC. (https://www.wso2.com). |
| 3 | +# |
| 4 | +# WSO2 LLC. licenses this file to you under the Apache License, |
| 5 | +# Version 2.0 (the "License"); you may not use this file except |
| 6 | +# in compliance with the License. |
| 7 | +# You may obtain a copy of the License at |
| 8 | +# |
| 9 | +# http://www.apache.org/licenses/LICENSE-2.0 |
| 10 | +# |
| 11 | +# Unless required by applicable law or agreed to in writing, |
| 12 | +# software distributed under the License is distributed on an |
| 13 | +# "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY |
| 14 | +# KIND, either express or implied. See the License for the |
| 15 | +# specific language governing permissions and limitations |
| 16 | +# under the License. |
| 17 | +# -------------------------------------------------------------------- |
| 18 | + |
| 19 | +Feature: LLM Provider Template Management |
| 20 | + As an API administrator |
| 21 | + I want to manage LLM provider templates in the gateway |
| 22 | + So that I can configure token tracking and model extraction metadata for different LLM providers |
| 23 | + |
| 24 | + Background: |
| 25 | + Given the gateway services are running |
| 26 | + |
| 27 | + # ======================================== |
| 28 | + # Scenario Group 1: Template Lifecycle (Happy Path) |
| 29 | + # ======================================== |
| 30 | + |
| 31 | + Scenario: Complete template lifecycle - create, retrieve, update, and delete |
| 32 | + Given I authenticate using basic auth as "admin" |
| 33 | + When I create this LLM provider template: |
| 34 | + """ |
| 35 | + apiVersion: gateway.api-platform.wso2.com/v1alpha1 |
| 36 | + kind: LlmProviderTemplate |
| 37 | + metadata: |
| 38 | + name: openai-test |
| 39 | + spec: |
| 40 | + displayName: OpenAI |
| 41 | + promptTokens: |
| 42 | + location: payload |
| 43 | + identifier: $.usage.prompt_tokens |
| 44 | + completionTokens: |
| 45 | + location: payload |
| 46 | + identifier: $.usage.completion_tokens |
| 47 | + totalTokens: |
| 48 | + location: payload |
| 49 | + identifier: $.usage.total_tokens |
| 50 | + remainingTokens: |
| 51 | + location: header |
| 52 | + identifier: x-ratelimit-remaining-tokens |
| 53 | + requestModel: |
| 54 | + location: payload |
| 55 | + identifier: $.model |
| 56 | + responseModel: |
| 57 | + location: payload |
| 58 | + identifier: $.model |
| 59 | + """ |
| 60 | + Then the response status code should be 201 |
| 61 | + And the response should be valid JSON |
| 62 | + And the JSON response field "status" should be "success" |
| 63 | + And the JSON response field "id" should be "openai-test" |
| 64 | + And the JSON response field "message" should be "LLM provider template created successfully" |
| 65 | + |
| 66 | + Given I authenticate using basic auth as "admin" |
| 67 | + When I retrieve the LLM provider template "openai-test" |
| 68 | + Then the response status code should be 200 |
| 69 | + And the response should be valid JSON |
| 70 | + And the JSON response field "status" should be "success" |
| 71 | + And the JSON response field "template.id" should be "openai-test" |
| 72 | + And the JSON response field "template.configuration.spec.displayName" should be "OpenAI" |
| 73 | + And the JSON response field "template.configuration.spec.promptTokens.location" should be "payload" |
| 74 | + And the JSON response field "template.configuration.spec.promptTokens.identifier" should be "$.usage.prompt_tokens" |
| 75 | + |
| 76 | + Given I authenticate using basic auth as "admin" |
| 77 | + When I update the LLM provider template "openai-test" with: |
| 78 | + """ |
| 79 | + apiVersion: gateway.api-platform.wso2.com/v1alpha1 |
| 80 | + kind: LlmProviderTemplate |
| 81 | + metadata: |
| 82 | + name: openai-test |
| 83 | + spec: |
| 84 | + displayName: OpenAI Updated |
| 85 | + promptTokens: |
| 86 | + location: payload |
| 87 | + identifier: $.usage.promptTokens |
| 88 | + completionTokens: |
| 89 | + location: payload |
| 90 | + identifier: $.usage.completion_tokens |
| 91 | + totalTokens: |
| 92 | + location: payload |
| 93 | + identifier: $.usage.total_tokens |
| 94 | + remainingTokens: |
| 95 | + location: header |
| 96 | + identifier: x-ratelimit-remaining-tokens |
| 97 | + requestModel: |
| 98 | + location: payload |
| 99 | + identifier: $.model |
| 100 | + responseModel: |
| 101 | + location: payload |
| 102 | + identifier: $.model |
| 103 | + """ |
| 104 | + Then the response status code should be 200 |
| 105 | + And the response should be valid JSON |
| 106 | + And the JSON response field "status" should be "success" |
| 107 | + And the JSON response field "id" should be "openai-test" |
| 108 | + And the JSON response field "message" should be "LLM provider template updated successfully" |
| 109 | + |
| 110 | + Given I authenticate using basic auth as "admin" |
| 111 | + When I retrieve the LLM provider template "openai-test" |
| 112 | + Then the response status code should be 200 |
| 113 | + And the JSON response field "template.configuration.spec.displayName" should be "OpenAI Updated" |
| 114 | + And the JSON response field "template.configuration.spec.promptTokens.location" should be "payload" |
| 115 | + And the JSON response field "template.configuration.spec.promptTokens.identifier" should be "$.usage.promptTokens" |
| 116 | + |
| 117 | + Given I authenticate using basic auth as "admin" |
| 118 | + When I delete the LLM provider template "openai-test" |
| 119 | + Then the response status code should be 200 |
| 120 | + And the JSON response field "status" should be "success" |
| 121 | + And the JSON response field "message" should be "LLM provider template deleted successfully" |
| 122 | + |
| 123 | + Given I authenticate using basic auth as "admin" |
| 124 | + When I retrieve the LLM provider template "openai-test" |
| 125 | + Then the response status code should be 404 |
| 126 | + And the response should be valid JSON |
| 127 | + And the JSON response field "status" should be "error" |
| 128 | + |
| 129 | + Scenario: Create template with minimal required fields |
| 130 | + Given I authenticate using basic auth as "admin" |
| 131 | + When I create this LLM provider template: |
| 132 | + """ |
| 133 | + apiVersion: gateway.api-platform.wso2.com/v1alpha1 |
| 134 | + kind: LlmProviderTemplate |
| 135 | + metadata: |
| 136 | + name: minimal-template |
| 137 | + spec: |
| 138 | + displayName: Minimal Template |
| 139 | + """ |
| 140 | + Then the response status code should be 201 |
| 141 | + And the response should be valid JSON |
| 142 | + And the JSON response field "id" should be "minimal-template" |
| 143 | + |
| 144 | + Given I authenticate using basic auth as "admin" |
| 145 | + When I retrieve the LLM provider template "minimal-template" |
| 146 | + Then the response status code should be 200 |
| 147 | + And the JSON response field "template.configuration.spec.displayName" should be "Minimal Template" |
| 148 | + |
| 149 | + Given I authenticate using basic auth as "admin" |
| 150 | + When I delete the LLM provider template "minimal-template" |
| 151 | + Then the response status code should be 200 |
| 152 | + |
| 153 | + Scenario: List LLM provider templates returns valid JSON with OOB Templates |
| 154 | + Given I authenticate using basic auth as "admin" |
| 155 | + When I list all LLM provider templates |
| 156 | + Then the response status code should be 200 |
| 157 | + And the response should be valid JSON |
| 158 | + And the JSON response field "status" should be "success" |
| 159 | + And the response should contain oob-templates |
0 commit comments