-
Notifications
You must be signed in to change notification settings - Fork 98
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Reorganize files, add rebar3 build, GH actions.
- Loading branch information
Showing
22 changed files
with
201 additions
and
36 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,18 @@ | ||
name: Hex Publish | ||
|
||
on: | ||
push: | ||
tags: | ||
- '*' | ||
|
||
jobs: | ||
publish: | ||
runs-on: ubuntu-latest | ||
steps: | ||
- name: Check out | ||
uses: actions/checkout@v2 | ||
|
||
- name: Publish to Hex.pm | ||
uses: erlangpack/github-action@v1 | ||
env: | ||
HEX_API_KEY: ${{ secrets.HEX_API_KEY }} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,36 +1,36 @@ | ||
# This workflow checks the tests and dialyzer. | ||
|
||
name: Test | ||
|
||
on: [push, pull_request] | ||
# Controls when the action will run. Triggers the workflow on push or pull request | ||
# events but only for the master branch | ||
on: | ||
push: | ||
branches: [ master ] | ||
pull_request: | ||
branches: [ master ] | ||
|
||
# A workflow run is made up of one or more jobs that can run sequentially or in parallel | ||
jobs: | ||
test-ubuntu: | ||
runs-on: ubuntu-18.04 | ||
name: OTP ${{matrix.otp_version}} | ||
linux: | ||
name: Test on OTP ${{ matrix.otp_version }} | ||
runs-on: ${{ matrix.os }} | ||
|
||
strategy: | ||
matrix: | ||
otp_version: | ||
- 21.3 | ||
- 22.3 | ||
- 23.2 | ||
steps: | ||
- uses: actions/checkout@v2 | ||
- uses: gleam-lang/[email protected] | ||
with: | ||
otp-version: ${{matrix.otp_version}} | ||
- run: | | ||
erl -make | ||
escript test.escript | ||
otp_version: [22.3, 23.3, 24.0.5] | ||
os: [ubuntu-latest] | ||
|
||
container: | ||
image: erlang:${{ matrix.otp_version }} | ||
|
||
test-windows: | ||
runs-on: windows-latest | ||
name: Windows | ||
steps: | ||
- uses: actions/checkout@v2 | ||
- uses: gleam-lang/[email protected] | ||
with: | ||
otp-version: 23.2 | ||
id: setup | ||
- run: | | ||
$env:PATH = "${{ steps.setup.outputs.erlpath }}\bin;$env:PATH" | ||
erl.exe -make | ||
escript.exe test.escript | ||
- uses: actions/checkout@v2 | ||
- name: Compile | ||
run: make | ||
- name: Test | ||
run: make test | ||
- name: XRef | ||
run: make xref | ||
- name: Dialyzer | ||
run: make dialyzer |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,31 @@ | ||
REBAR := ./rebar3 | ||
REBAR_URL := https://s3.amazonaws.com/rebar3/rebar3 | ||
ERL ?= erl | ||
|
||
.PHONY: all compile shell test clean xref dialyzer | ||
|
||
all: compile | ||
|
||
compile: $(REBAR) | ||
$(REBAR) compile | ||
|
||
shell: $(REBAR) | ||
$(REBAR) shell | ||
|
||
test: $(REBAR) | ||
$(REBAR) as test ct | ||
|
||
clean: $(REBAR) | ||
$(REBAR) clean | ||
|
||
xref: $(REBAR) | ||
$(REBAR) as test xref | ||
|
||
dialyzer: $(REBAR) | ||
$(REBAR) as test dialyzer | ||
|
||
./rebar3: | ||
$(ERL) -noshell -s inets -s ssl \ | ||
-eval '{ok, saved_to_file} = httpc:request(get, {"$(REBAR_URL)", []}, [], [{stream, "./rebar3"}])' \ | ||
-s init stop | ||
chmod +x ./rebar3 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,9 @@ | ||
{application, oauth, [ | ||
{description, "An Erlang OAuth 1.0 implementation"}, | ||
{vsn, git}, | ||
{modules, [oauth]}, | ||
{registered, []}, | ||
{applications, [kernel, stdlib, crypto, public_key, inets]}, | ||
{licenses, ["MIT License"]}, | ||
{links, [{"GitHub", "https://github.com/erlangpack/erlang-oauth"}]} | ||
]}. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,98 @@ | ||
%% -*- coding: utf-8 -*- | ||
%% ------------------------------------------------------------------- | ||
%% | ||
%% Copyright (c) 2021 Marc Worrell | ||
%% | ||
%% ------------------------------------------------------------------- | ||
|
||
-module(oauth_SUITE). | ||
-compile(export_all). | ||
|
||
-include_lib("common_test/include/ct.hrl"). | ||
-include_lib("eunit/include/eunit.hrl"). | ||
|
||
%% ------------------------------------------------------------ | ||
%% Tests list | ||
%% ------------------------------------------------------------ | ||
|
||
all() -> | ||
[ | ||
signature_base_string, | ||
plaintext, | ||
hmac_sha1, | ||
rsa_sha1 | ||
]. | ||
|
||
%% ------------------------------------------------------------ | ||
%% Init & clean | ||
%% ------------------------------------------------------------ | ||
|
||
init_per_suite(Config) -> | ||
Config. | ||
|
||
end_per_suite(_Config) -> | ||
ok. | ||
|
||
init_per_testcase(_TestCase, Config) -> | ||
Config. | ||
|
||
end_per_testcase(_TestCase, _Config) -> | ||
ok. | ||
|
||
%% ------------------------------------------------------------ | ||
%% Test cases | ||
%% ------------------------------------------------------------ | ||
|
||
|
||
signature_base_string(Config) -> | ||
test_with( | ||
Config, | ||
"base_string_test_*", | ||
[method, url, params, base_string], | ||
fun (Method, URL, Params, BaseString) -> | ||
[?_assertEqual(BaseString, oauth:signature_base_string(Method, URL, Params))] | ||
end). | ||
|
||
plaintext(Config) -> | ||
test_with( | ||
Config, | ||
"plaintext_test_*", | ||
[consumer, token_secret, signature], | ||
fun (Consumer, TokenSecret, Signature) -> | ||
SignatureTest = ?_assertEqual(Signature, oauth:plaintext_signature(Consumer, TokenSecret)), | ||
VerifyTest = ?_assertEqual(true, oauth:plaintext_verify(Signature, Consumer, TokenSecret)), | ||
[SignatureTest, VerifyTest] | ||
end). | ||
|
||
hmac_sha1(Config) -> | ||
test_with( | ||
Config, | ||
"hmac_sha1_test_*", | ||
[base_string, consumer, token_secret, signature], | ||
fun (BaseString, Consumer, TokenSecret, Signature) -> | ||
SignatureTest = ?_assertEqual(Signature, oauth:hmac_sha1_signature(BaseString, Consumer, TokenSecret)), | ||
VerifyTest = ?_assertEqual(true, oauth:hmac_sha1_verify(Signature, BaseString, Consumer, TokenSecret)), | ||
[SignatureTest, VerifyTest] | ||
end). | ||
|
||
rsa_sha1(Config) -> | ||
Pkey = data_path(Config, "rsa_sha1_private_key.pem"), | ||
Cert = data_path(Config, "rsa_sha1_certificate.pem"), | ||
[BaseString, Signature] = read([base_string, signature], data_path(Config, "rsa_sha1_test")), | ||
SignatureTest = ?_assertEqual(Signature, oauth:rsa_sha1_signature(BaseString, {"", Pkey, rsa_sha1})), | ||
VerifyTest = ?_assertEqual(true, oauth:rsa_sha1_verify(Signature, BaseString, {"", Cert, rsa_sha1})), | ||
[SignatureTest, VerifyTest]. | ||
|
||
test_with(Config, FilenamePattern, Keys, Fun) -> | ||
lists:flatten( | ||
lists:map( | ||
fun (Path) -> apply(Fun, read(Keys, Path)) end, | ||
filelib:wildcard(data_path(Config, FilenamePattern)))). | ||
|
||
data_path(Config, Basename) -> | ||
DataDir = ?config(data_dir, Config), | ||
filename:join([DataDir, Basename]). | ||
|
||
read(Keys, Path) -> | ||
{ok, Proplist} = file:consult(Path), | ||
[ proplists:get_value(K, Proplist) || K <- Keys ]. |
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.