Skip to content

Commit 6741d90

Browse files
committed
Use github actions
1 parent 7a197e5 commit 6741d90

File tree

8 files changed

+46
-54
lines changed

8 files changed

+46
-54
lines changed

.github/workflows/CI.yml

Lines changed: 33 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,33 @@
1+
on: [push, pull_request]
2+
3+
name: CI
4+
5+
jobs:
6+
check:
7+
name: Check
8+
runs-on: ubuntu-latest
9+
steps:
10+
- uses: actions/checkout@v4
11+
- uses: dtolnay/rust-toolchain@stable
12+
- run: cargo check
13+
14+
test:
15+
name: Test Suite
16+
runs-on: ${{ matrix.os }}
17+
strategy:
18+
matrix:
19+
os: [ubuntu-latest, macos-latest, windows-latest]
20+
steps:
21+
- uses: actions/checkout@v4
22+
- uses: dtolnay/rust-toolchain@stable
23+
- run: cargo test
24+
25+
fmt:
26+
name: Rustfmt
27+
runs-on: ubuntu-latest
28+
steps:
29+
- uses: actions/checkout@v4
30+
- uses: dtolnay/rust-toolchain@stable
31+
with:
32+
components: rustfmt
33+
- run: cargo fmt --all -- --check

.travis.yml

Lines changed: 0 additions & 25 deletions
This file was deleted.

Cargo.toml

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -9,11 +9,8 @@ name = "otpauth"
99
readme = "README.md"
1010
repository = "https://github.com/messense/otpauth-rs"
1111
version = "0.4.1"
12-
edition = "2018"
12+
edition = "2021"
1313

1414
[dependencies]
1515
base32 = "0.5.1"
1616
ring = "0.17.8"
17-
18-
[features]
19-
unstable = []

appveyor.yml

Lines changed: 0 additions & 12 deletions
This file was deleted.

rustfmt.toml

Lines changed: 0 additions & 3 deletions
This file was deleted.

src/hotp.rs

Lines changed: 3 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -3,17 +3,13 @@
33
//! # Example
44
//!
55
//! ```
6-
//! extern crate otpauth;
7-
//!
86
//! fn main() {
97
//! let auth = otpauth::HOTP::new("python");
108
//! let code = auth.generate(4);
119
//! assert!(auth.verify(code, 0, 100));
1210
//! }
1311
//! ```
1412
15-
use std::convert::TryInto;
16-
1713
use base32::Alphabet::Rfc4648;
1814
use ring::hmac;
1915

@@ -40,7 +36,9 @@ impl HOTP {
4036
/// Constructs a new `HOTP` with secret bytes
4137
#[must_use]
4238
pub fn from_bytes(bytes: &[u8]) -> HOTP {
43-
HOTP { secret: bytes.into() }
39+
HOTP {
40+
secret: bytes.into(),
41+
}
4442
}
4543

4644
/// Generate a HOTP code.

src/lib.rs

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -6,16 +6,14 @@
66
//!
77
//! ```toml
88
//! [dependencies]
9-
//! otpauth = "0.3"
9+
//! otpauth = "0.4"
1010
//! ```
1111
//!
1212
//! # Examples
1313
//!
1414
//! ## HOTP example
1515
//!
1616
//! ```rust
17-
//! extern crate otpauth;
18-
//!
1917
//! use otpauth::HOTP;
2018
//!
2119
//! let auth = HOTP::new("python");

tests/lib.rs

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -12,9 +12,15 @@ fn test_hotp() {
1212
#[test]
1313
fn test_totp() {
1414
let auth = otpauth::TOTP::new("python");
15-
let timestamp1 = SystemTime::now().duration_since(UNIX_EPOCH).unwrap().as_secs();
15+
let timestamp1 = SystemTime::now()
16+
.duration_since(UNIX_EPOCH)
17+
.unwrap()
18+
.as_secs();
1619
let code = auth.generate(30, timestamp1);
17-
let timestamp2 = SystemTime::now().duration_since(UNIX_EPOCH).unwrap().as_secs();
20+
let timestamp2 = SystemTime::now()
21+
.duration_since(UNIX_EPOCH)
22+
.unwrap()
23+
.as_secs();
1824
assert!(auth.verify(code, 30, timestamp2));
1925
assert!(!auth.verify(123456, 30, timestamp2));
2026
assert!(!auth.verify(1234567, 30, timestamp2));

0 commit comments

Comments
 (0)