-
Notifications
You must be signed in to change notification settings - Fork 22
Add simple automated (but network-requiring) test for the asynch interface #131
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: master
Are you sure you want to change the base?
Changes from 3 commits
eb56446
141b29c
e9098de
e334259
4fc9ae6
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change | ||||||||||||||||||||||||||||||||||
|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
| @@ -0,0 +1,125 @@ | ||||||||||||||||||||||||||||||||||||
| #include <stdio.h> | ||||||||||||||||||||||||||||||||||||
| #include <stdlib.h> | ||||||||||||||||||||||||||||||||||||
djw8605 marked this conversation as resolved.
Show resolved
Hide resolved
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. [lint] reported by reviewdog 🐶
Suggested change
|
||||||||||||||||||||||||||||||||||||
| #include <sys/select.h> | ||||||||||||||||||||||||||||||||||||
|
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. [lint] reported by reviewdog 🐶
Suggested change
|
||||||||||||||||||||||||||||||||||||
| #include <unistd.h> | ||||||||||||||||||||||||||||||||||||
djw8605 marked this conversation as resolved.
Show resolved
Hide resolved
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. [lint] reported by reviewdog 🐶
Suggested change
|
||||||||||||||||||||||||||||||||||||
| #include <errno.h> | ||||||||||||||||||||||||||||||||||||
| #include <string.h> | ||||||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||||||
djw8605 marked this conversation as resolved.
Outdated
Show resolved
Hide resolved
|
||||||||||||||||||||||||||||||||||||
| #include "../src/scitokens.h" | ||||||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||||||
| void | ||||||||||||||||||||||||||||||||||||
| usage( const char * self ) { | ||||||||||||||||||||||||||||||||||||
| fprintf( stderr, "usage: %s encoded-scitoken\n", self ); | ||||||||||||||||||||||||||||||||||||
|
||||||||||||||||||||||||||||||||||||
| void | |
| usage( const char * self ) { | |
| fprintf( stderr, "usage: %s encoded-scitoken\n", self ); | |
| void usage(const char *self) { | |
| fprintf(stderr, "usage: %s encoded-scitoken\n", self); |
djw8605 marked this conversation as resolved.
Outdated
Show resolved
Hide resolved
djw8605 marked this conversation as resolved.
Outdated
Show resolved
Hide resolved
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
[lint] reported by reviewdog 🐶
| fprintf( stdout, "%s = %s\n", claim, value ); | |
| fprintf(stdout, "%s = %s\n", claim, value); |
djw8605 marked this conversation as resolved.
Outdated
Show resolved
Hide resolved
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
[lint] reported by reviewdog 🐶
djw8605 marked this conversation as resolved.
Outdated
Show resolved
Hide resolved
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
[lint] reported by reviewdog 🐶
| char * error; | |
| char *error; |
djw8605 marked this conversation as resolved.
Outdated
Show resolved
Hide resolved
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
[lint] reported by reviewdog 🐶
djw8605 marked this conversation as resolved.
Outdated
Show resolved
Hide resolved
Outdated
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
[lint] reported by reviewdog 🐶
| if( getcwd(cache_path, sizeof(cache_path)) == NULL ) { | |
| fprintf( stderr, "Failed to determine cwd, aborting.\n" ); | |
| exit( -5 ); | |
| if (getcwd(cache_path, sizeof(cache_path)) == NULL) { | |
| fprintf(stderr, "Failed to determine cwd, aborting.\n"); | |
| exit(-5); |
djw8605 marked this conversation as resolved.
Outdated
Show resolved
Hide resolved
Outdated
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
[lint] reported by reviewdog 🐶
| const char * key = "keycache.cache_home"; | |
| rv = scitoken_config_set_str( key, cache_path, & error ); | |
| if( rv != 0 ) { | |
| fprintf( stderr, "Failed to set %s: %s, aborting.\n", key, cache_path ); | |
| exit( -5 ); | |
| const char *key = "keycache.cache_home"; | |
| rv = scitoken_config_set_str(key, cache_path, &error); | |
| if (rv != 0) { | |
| fprintf(stderr, "Failed to set %s: %s, aborting.\n", key, cache_path); | |
| exit(-5); |
djw8605 marked this conversation as resolved.
Outdated
Show resolved
Hide resolved
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
[lint] reported by reviewdog 🐶
djw8605 marked this conversation as resolved.
Outdated
Show resolved
Hide resolved
Outdated
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
[lint] reported by reviewdog 🐶
| rv = scitoken_deserialize_start( | |
| encoded, & token, NULL, & status, & error | |
| ); | |
| if( rv != 0 ) { | |
| fprintf( stderr, "scitoken_deserialize_start() failed: %s\n", error ); | |
| exit( -2 ); | |
| rv = scitoken_deserialize_start(encoded, &token, NULL, &status, &error); | |
| if (rv != 0) { | |
| fprintf(stderr, "scitoken_deserialize_start() failed: %s\n", error); | |
| exit(-2); |
djw8605 marked this conversation as resolved.
Outdated
Show resolved
Hide resolved
Outdated
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
[lint] reported by reviewdog 🐶
| if( status == NULL ) { | |
| fprintf( stderr, "scitoken_deserialize_start() returned a token\n" ); | |
| exit( 1 ); | |
| if (status == NULL) { | |
| fprintf(stderr, "scitoken_deserialize_start() returned a token\n"); | |
| exit(1); |
djw8605 marked this conversation as resolved.
Outdated
Show resolved
Hide resolved
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
[lint] reported by reviewdog 🐶
djw8605 marked this conversation as resolved.
Outdated
Show resolved
Hide resolved
Outdated
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
[lint] reported by reviewdog 🐶
| fd_set * read_fds = NULL; | |
| rv = scitoken_status_get_read_fd_set( & status, & read_fds, & error ); | |
| if( rv != 0 ) { | |
| fprintf( stderr, "scitoken_status_get_read_fd_set() failed: %s\n", error ); | |
| exit( -2 ); | |
| fd_set *read_fds = NULL; | |
| rv = scitoken_status_get_read_fd_set(&status, &read_fds, &error); | |
| if (rv != 0) { | |
| fprintf(stderr, "scitoken_status_get_read_fd_set() failed: %s\n", | |
| error); | |
| exit(-2); |
djw8605 marked this conversation as resolved.
Outdated
Show resolved
Hide resolved
Outdated
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
[lint] reported by reviewdog 🐶
| fd_set * write_fds = NULL; | |
| rv = scitoken_status_get_write_fd_set( & status, & write_fds, & error ); | |
| if( rv != 0 ) { | |
| fprintf( stderr, "scitoken_status_get_write_fd_set() failed: %s\n", error ); | |
| exit( -2 ); | |
| fd_set *write_fds = NULL; | |
| rv = scitoken_status_get_write_fd_set(&status, &write_fds, &error); | |
| if (rv != 0) { | |
| fprintf(stderr, "scitoken_status_get_write_fd_set() failed: %s\n", | |
| error); | |
| exit(-2); |
djw8605 marked this conversation as resolved.
Outdated
Show resolved
Hide resolved
Outdated
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
[lint] reported by reviewdog 🐶
| fd_set * except_fds = NULL; | |
| rv = scitoken_status_get_exc_fd_set( & status, & except_fds, & error ); | |
| if( rv != 0 ) { | |
| fprintf( stderr, "scitoken_status_get_exc_fd_set() failed: %s\n", error ); | |
| exit( -2 ); | |
| fd_set *except_fds = NULL; | |
| rv = scitoken_status_get_exc_fd_set(&status, &except_fds, &error); | |
| if (rv != 0) { | |
| fprintf(stderr, "scitoken_status_get_exc_fd_set() failed: %s\n", | |
| error); | |
| exit(-2); |
djw8605 marked this conversation as resolved.
Outdated
Show resolved
Hide resolved
Outdated
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
[lint] reported by reviewdog 🐶
| rv = scitoken_status_get_max_fd( & status, & max_fds, & error ); | |
| if( rv != 0 ) { | |
| fprintf( stderr, "scitoken_status_get_max_fds() failed: %s\n", error ); | |
| exit( -2 ); | |
| rv = scitoken_status_get_max_fd(&status, &max_fds, &error); | |
| if (rv != 0) { | |
| fprintf(stderr, "scitoken_status_get_max_fds() failed: %s\n", | |
| error); | |
| exit(-2); |
djw8605 marked this conversation as resolved.
Outdated
Show resolved
Hide resolved
Outdated
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
[lint] reported by reviewdog 🐶
| struct timeval time_out{1, 0}; | |
| int s = select( max_fds + 1, read_fds, write_fds, except_fds, & time_out ); | |
| if( s == -1 ) { | |
| fprintf( stderr, "select() failed: %s (%d)\n", strerror(errno), errno ); | |
| exit( -4 ); | |
| } else if( s == 0 ) { | |
| fprintf( stderr, "select() timed out, checking for progress.\n" ); | |
| struct timeval time_out { | |
| 1, 0 | |
| }; | |
| int s = select(max_fds + 1, read_fds, write_fds, except_fds, &time_out); | |
| if (s == -1) { | |
| fprintf(stderr, "select() failed: %s (%d)\n", strerror(errno), | |
| errno); | |
| exit(-4); | |
| } else if (s == 0) { | |
| fprintf(stderr, "select() timed out, checking for progress.\n"); |
djw8605 marked this conversation as resolved.
Outdated
Show resolved
Hide resolved
Outdated
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
[lint] reported by reviewdog 🐶
| fprintf( stderr, "Calling scitoken_deserialize_continue()...\n" ); | |
| rv = scitoken_deserialize_continue( & token, & status, & error ); | |
| if( rv != 0 ) { | |
| fprintf( stderr, "scitoken_deserialize_continue() failed: %s\n", error ); | |
| exit( -3 ); | |
| fprintf(stderr, "Calling scitoken_deserialize_continue()...\n"); | |
| rv = scitoken_deserialize_continue(&token, &status, &error); | |
| if (rv != 0) { | |
| fprintf(stderr, "scitoken_deserialize_continue() failed: %s\n", | |
| error); | |
| exit(-3); |
djw8605 marked this conversation as resolved.
Outdated
Show resolved
Hide resolved
Outdated
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
[lint] reported by reviewdog 🐶
| } while( status != NULL ); | |
| } while (status != NULL); |
djw8605 marked this conversation as resolved.
Outdated
Show resolved
Hide resolved
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
[lint] reported by reviewdog 🐶
| scitoken_destroy( token ); | |
| scitoken_destroy(token); |
djw8605 marked this conversation as resolved.
Outdated
Show resolved
Hide resolved
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,38 @@ | ||
| #!/usr/bin/env python3 | ||
|
|
||
| import os | ||
| import json | ||
| import requests | ||
| import subprocess | ||
| import sys | ||
|
|
||
|
|
||
| def get_demo_token(payload: dict): | ||
| data = json.dumps({'algorithm': "ES256", 'payload': payload}) | ||
| resp = requests.post("https://demo.scitokens.org/issue", data=data) | ||
| return resp.text | ||
|
|
||
|
|
||
| demo_payload = { | ||
| "ver": "scitoken:2.0", | ||
| "aud": "https://demo.scitokens.org", | ||
| "iss": "https://demo.scitokens.org", | ||
| } | ||
| demo_token = get_demo_token(demo_payload) | ||
|
|
||
| try: | ||
| scitokens_cache = f"{os.getcwd()}/scitokens/scitokens_cpp.sqllite" | ||
| os.unlink(scitokens_cache) | ||
| except FileNotFoundError: | ||
| pass | ||
|
|
||
| rv = subprocess.run( | ||
| ['./scitokens-asynch-test', demo_token], | ||
| stdout=subprocess.PIPE, | ||
| stderr=subprocess.STDOUT, | ||
| timeout=5, | ||
| universal_newlines=True, | ||
| ) | ||
|
|
||
| print(rv.stdout) | ||
| sys.exit(rv.returncode) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
[lint] reported by reviewdog 🐶