Skip to content
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

Add simple automated (but network-requiring) test for the asynch interface #131

Open
wants to merge 5 commits into
base: master
Choose a base branch
from

Conversation

Todd-L-Miller
Copy link
Contributor

No description provided.

test/asynch.cc Show resolved Hide resolved
test/asynch.cc Show resolved Hide resolved
test/asynch.cc Outdated Show resolved Hide resolved
test/asynch.cc Outdated Show resolved Hide resolved
test/asynch.cc Outdated Show resolved Hide resolved
test/asynch.cc Outdated Show resolved Hide resolved
test/asynch.cc Outdated Show resolved Hide resolved
test/asynch.cc Outdated Show resolved Hide resolved
test/asynch.cc Outdated Show resolved Hide resolved
test/asynch.cc Outdated Show resolved Hide resolved
Co-authored-by: github-actions[bot] <41898282+github-actions[bot]@users.noreply.github.com>
@@ -0,0 +1,124 @@
#include <stdio.h>
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

[lint] reported by reviewdog 🐶

Suggested change
#include <stdio.h>
#include "../src/scitokens.h"

@@ -0,0 +1,124 @@
#include <stdio.h>
#include <errno.h>
#include <stdlib.h>
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

[lint] reported by reviewdog 🐶

Suggested change
#include <stdlib.h>
#include <stdio.h>
#include <stdlib.h>

#include <stdio.h>
#include <errno.h>
#include <stdlib.h>
#include <sys/select.h>
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

[lint] reported by reviewdog 🐶

Suggested change
#include <sys/select.h>

#include <stdlib.h>
#include <sys/select.h>
#include <string.h>
#include <unistd.h>
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

[lint] reported by reviewdog 🐶

Suggested change
#include <unistd.h>
#include <sys/select.h>
#include <unistd.h>

Comment on lines +7 to +8
#include <errno.h>
#include "../src/scitokens.h"
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

[lint] reported by reviewdog 🐶

Suggested change
#include <errno.h>
#include "../src/scitokens.h"

test/asynch.cc Outdated
Comment on lines 93 to 96
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 );
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

[lint] reported by reviewdog 🐶

Suggested change
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);

test/asynch.cc Outdated
Comment on lines 99 to 105
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" );
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

[lint] reported by reviewdog 🐶

Suggested change
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");

test/asynch.cc Outdated
Comment on lines 108 to 112
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 );
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

[lint] reported by reviewdog 🐶

Suggested change
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);

test/asynch.cc Outdated
Comment on lines 114 to 115
} while( status != NULL );

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

[lint] reported by reviewdog 🐶

Suggested change
} while( status != NULL );
} while (status != NULL);

print_claim(token, "iss");
print_claim(token, "jti");

scitoken_destroy( token );
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

[lint] reported by reviewdog 🐶

Suggested change
scitoken_destroy( token );
scitoken_destroy(token);

Co-authored-by: github-actions[bot] <41898282+github-actions[bot]@users.noreply.github.com>
Comment on lines +10 to +11
void
void usage(const char *self) {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

[lint] reported by reviewdog 🐶

Suggested change
void
void usage(const char *self) {
void void usage(const char *self) {

Comment on lines +14 to +53
void
void print_claim(SciToken &token, const char *claim) {
char *value;
char *error;
int rv = scitoken_get_claim_string(token, claim, &value, &error);
if (rv != 0) {
fprintf(stderr, "scitoken_get_claim_string('%s') failed: %s\n", claim,
error);
return;
}
fprintf( stdout, "%s = %s\n", claim, value );
fprintf(stdout, "%s = %s\n", claim, value);


int main(int argc, char **argv) {
if (argc < 2) {
usage(argv[0]);
exit(-1);
}
const char *encoded = argv[1];
int rv;
char * error;
char *error;


char cache_path[FILENAME_MAX];
if( getcwd(cache_path, sizeof(cache_path)) == NULL ) {
if (getcwd(cache_path, sizeof(cache_path)) == NULL) {
fprintf(stderr, "Failed to determine cwd, aborting.\n");
exit(-5);

const char * key = "keycache.cache_home";
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);


SciTokenStatus status;
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

[lint] reported by reviewdog 🐶

Suggested change
void
void print_claim(SciToken &token, const char *claim) {
char *value;
char *error;
int rv = scitoken_get_claim_string(token, claim, &value, &error);
if (rv != 0) {
fprintf(stderr, "scitoken_get_claim_string('%s') failed: %s\n", claim,
error);
return;
}
fprintf( stdout, "%s = %s\n", claim, value );
fprintf(stdout, "%s = %s\n", claim, value);
int main(int argc, char **argv) {
if (argc < 2) {
usage(argv[0]);
exit(-1);
}
const char *encoded = argv[1];
int rv;
char * error;
char *error;
char cache_path[FILENAME_MAX];
if( getcwd(cache_path, sizeof(cache_path)) == NULL ) {
if (getcwd(cache_path, sizeof(cache_path)) == NULL) {
fprintf(stderr, "Failed to determine cwd, aborting.\n");
exit(-5);
const char * key = "keycache.cache_home";
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);
SciTokenStatus status;
void void print_claim(SciToken & token, const char *claim) {
char *value;
char *error;
int rv = scitoken_get_claim_string(token, claim, &value, &error);
if (rv != 0) {
fprintf(stderr, "scitoken_get_claim_string('%s') failed: %s\n",
claim, error);
return;
}
fprintf(stdout, "%s = %s\n", claim, value);
fprintf(stdout, "%s = %s\n", claim, value);
int main(int argc, char **argv) {
if (argc < 2) {
usage(argv[0]);
exit(-1);
}
const char *encoded = argv[1];
int rv;
char *error;
char *error;
char cache_path[FILENAME_MAX];
if (getcwd(cache_path, sizeof(cache_path)) == NULL) {
if (getcwd(cache_path, sizeof(cache_path)) == NULL) {
fprintf(stderr, "Failed to determine cwd, aborting.\n");
exit(-5);
const char *key = "keycache.cache_home";
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);
SciTokenStatus status;

test/asynch.cc Show resolved Hide resolved
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants