Skip to content

Instantly share code, notes, and snippets.

View marcelocg's full-sized avatar

Marcelo Gonçalves marcelocg

View GitHub Profile
@marcelocg
marcelocg / UserRestControllerTest.java
Created June 5, 2021 13:54 — forked from ekswai/UserRestControllerTest.java
spring oauth2 rest template with client credentials grant sample
import org.junit.Test;
import org.junit.runner.RunWith;
import org.master.Application;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.boot.test.IntegrationTest;
import org.springframework.boot.test.SpringApplicationConfiguration;
import org.springframework.http.converter.json.MappingJackson2HttpMessageConverter;
import org.springframework.security.oauth2.client.DefaultOAuth2ClientContext;
import org.springframework.security.oauth2.client.OAuth2RestTemplate;
import org.springframework.security.oauth2.client.token.grant.client.ClientCredentialsResourceDetails;
@marcelocg
marcelocg / psqlfix.sh
Last active November 30, 2016 23:22 — forked from fgrehm/psqlfix.sh
if [[ -z "$1" ]]; then
echo "No argument supplied. Usage: pgsqlconfig.sh <appname>"
exit 1
fi
if ! $(psql template1 -c 'SHOW SERVER_ENCODING' | grep -q UTF8); then
psql postgres -c "update pg_database set datallowconn = TRUE where datname = 'template0';"
psql template0 -c "update pg_database set datistemplate = FALSE where datname = 'template1';"
psql template0 -c "drop database template1;"
psql template0 -c "create database template1 with template = template0 encoding = 'UTF8';"