|
| 1 | +/* |
| 2 | + * Licensed to the Apache Software Foundation (ASF) under one |
| 3 | + * or more contributor license agreements. See the NOTICE file |
| 4 | + * distributed with this work for additional information |
| 5 | + * regarding copyright ownership. The ASF licenses this file |
| 6 | + * to you under the Apache License, Version 2.0 (the |
| 7 | + * "License"); you may not use this file except in compliance |
| 8 | + * with the License. You may obtain a copy of the License at |
| 9 | + * |
| 10 | + * http://www.apache.org/licenses/LICENSE-2.0 |
| 11 | + * |
| 12 | + * Unless required by applicable law or agreed to in writing, |
| 13 | + * software distributed under the License is distributed on an |
| 14 | + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY |
| 15 | + * KIND, either express or implied. See the License for the |
| 16 | + * specific language governing permissions and limitations |
| 17 | + * under the License. |
| 18 | + */ |
| 19 | + |
| 20 | +/*************************************************************************** |
| 21 | + * Copyright (C) 2017-2025 ZmartZone Holding BV |
| 22 | + * All rights reserved. |
| 23 | + * |
| 24 | + * DISCLAIMER OF WARRANTIES: |
| 25 | + * |
| 26 | + * THE SOFTWARE PROVIDED HEREUNDER IS PROVIDED ON AN "AS IS" BASIS, WITHOUT |
| 27 | + * ANY WARRANTIES OR REPRESENTATIONS EXPRESS, IMPLIED OR STATUTORY; INCLUDING, |
| 28 | + * WITHOUT LIMITATION, WARRANTIES OF QUALITY, PERFORMANCE, NONINFRINGEMENT, |
| 29 | + * MERCHANTABILITY OR FITNESS FOR A PARTICULAR PURPOSE. NOR ARE THERE ANY |
| 30 | + * WARRANTIES CREATED BY A COURSE OR DEALING, COURSE OF PERFORMANCE OR TRADE |
| 31 | + * USAGE. FURTHERMORE, THERE ARE NO WARRANTIES THAT THE SOFTWARE WILL MEET |
| 32 | + * YOUR NEEDS OR BE FREE FROM ERRORS, OR THAT THE OPERATION OF THE SOFTWARE |
| 33 | + * WILL BE UNINTERRUPTED. IN NO EVENT SHALL THE COPYRIGHT HOLDERS OR |
| 34 | + * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, |
| 35 | + * EXEMPLARY, OR CONSEQUENTIAL DAMAGES HOWEVER CAUSED AND ON ANY THEORY OF |
| 36 | + * LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING |
| 37 | + * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS |
| 38 | + * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. |
| 39 | + * |
| 40 | + * @Author: Hans Zandbelt - [email protected] |
| 41 | + * |
| 42 | + **************************************************************************/ |
| 43 | + |
| 44 | +#include "cfg/provider.h" |
| 45 | +#include "helper.h" |
| 46 | + |
| 47 | +#include <http_config.h> |
| 48 | + |
| 49 | +static cmd_parms cmd = {}; |
| 50 | + |
| 51 | +// provider |
| 52 | + |
| 53 | +START_TEST(test_cmd_provider_token_endpoint_auth_set) { |
| 54 | + void *ptr = NULL; |
| 55 | + const char *arg = NULL; |
| 56 | + const char *rv = NULL; |
| 57 | + |
| 58 | + cmd.server = oidc_test_request_get()->server; |
| 59 | + cmd.pool = oidc_test_request_get()->pool; |
| 60 | + cmd.directive = apr_pcalloc(cmd.pool, sizeof(ap_directive_t)); |
| 61 | + cmd.directive->directive = OIDCProviderTokenEndpointAuth; |
| 62 | + |
| 63 | + arg = "private_key_jwt"; |
| 64 | + rv = oidc_cmd_provider_token_endpoint_auth_set(&cmd, ptr, arg); |
| 65 | + ck_assert_msg(rv == NULL, "failed: %s", rv); |
| 66 | + |
| 67 | + arg = "private_key_jws"; |
| 68 | + rv = oidc_cmd_provider_token_endpoint_auth_set(&cmd, ptr, arg); |
| 69 | + ck_assert_msg(rv != NULL, "should have failed"); |
| 70 | + |
| 71 | + arg = "private_key_jwt:RS256"; |
| 72 | + rv = oidc_cmd_provider_token_endpoint_auth_set(&cmd, ptr, arg); |
| 73 | + ck_assert_msg(rv == NULL, "failed: %s", rv); |
| 74 | + |
| 75 | + arg = "private_key_jwt:RA256"; |
| 76 | + rv = oidc_cmd_provider_token_endpoint_auth_set(&cmd, ptr, arg); |
| 77 | + ck_assert_msg(rv != NULL, "should have failed"); |
| 78 | +} |
| 79 | +END_TEST |
| 80 | + |
| 81 | +int main(void) { |
| 82 | + TCase *core = tcase_create("core"); |
| 83 | + tcase_add_checked_fixture(core, oidc_test_setup, oidc_test_teardown); |
| 84 | + |
| 85 | + tcase_add_test(core, test_cmd_provider_token_endpoint_auth_set); |
| 86 | + |
| 87 | + Suite *s = suite_create("cfg"); |
| 88 | + suite_add_tcase(s, core); |
| 89 | + |
| 90 | + return oidc_test_suite_run(s); |
| 91 | +} |
0 commit comments