Compare commits
8 commits
Author | SHA1 | Date | |
---|---|---|---|
|
66d86fb092 | ||
|
bfc94ffc04 | ||
|
997979f1b8 | ||
|
ef93a5772e | ||
|
2aded968d2 | ||
|
cc5aa6c9ed | ||
|
6afd3822b2 | ||
|
b7148fab83 |
6 changed files with 36 additions and 96 deletions
71
.github/workflows/codeql-analysis.yml
vendored
71
.github/workflows/codeql-analysis.yml
vendored
|
@ -1,71 +0,0 @@
|
|||
# For most projects, this workflow file will not need changing; you simply need
|
||||
# to commit it to your repository.
|
||||
#
|
||||
# You may wish to alter this file to override the set of languages analyzed,
|
||||
# or to provide custom queries or build logic.
|
||||
name: "CodeQL"
|
||||
|
||||
on:
|
||||
push:
|
||||
branches: [master]
|
||||
pull_request:
|
||||
# The branches below must be a subset of the branches above
|
||||
branches: [master]
|
||||
schedule:
|
||||
- cron: '0 8 * * 6'
|
||||
|
||||
jobs:
|
||||
analyze:
|
||||
name: Analyze
|
||||
runs-on: ubuntu-latest
|
||||
|
||||
strategy:
|
||||
fail-fast: false
|
||||
matrix:
|
||||
# Override automatic language detection by changing the below list
|
||||
# Supported options are ['csharp', 'cpp', 'go', 'java', 'javascript', 'python']
|
||||
language: ['go']
|
||||
# Learn more...
|
||||
# https://docs.github.com/en/github/finding-security-vulnerabilities-and-errors-in-your-code/configuring-code-scanning#overriding-automatic-language-detection
|
||||
|
||||
steps:
|
||||
- name: Checkout repository
|
||||
uses: actions/checkout@v2.3.4
|
||||
with:
|
||||
# We must fetch at least the immediate parents so that if this is
|
||||
# a pull request then we can checkout the head.
|
||||
fetch-depth: 2
|
||||
|
||||
# If this run was triggered by a pull request event, then checkout
|
||||
# the head of the pull request instead of the merge commit.
|
||||
- run: git checkout HEAD^2
|
||||
if: ${{ github.event_name == 'pull_request' }}
|
||||
|
||||
# Initializes the CodeQL tools for scanning.
|
||||
- name: Initialize CodeQL
|
||||
uses: github/codeql-action/init@v1
|
||||
with:
|
||||
languages: ${{ matrix.language }}
|
||||
# If you wish to specify custom queries, you can do so here or in a config file.
|
||||
# By default, queries listed here will override any specified in a config file.
|
||||
# Prefix the list here with "+" to use these queries and those in the config file.
|
||||
# queries: ./path/to/local/query, your-org/your-repo/queries@main
|
||||
|
||||
# Autobuild attempts to build any compiled languages (C/C++, C#, or Java).
|
||||
# If this step fails, then you should remove it and run the build manually (see below)
|
||||
- name: Autobuild
|
||||
uses: github/codeql-action/autobuild@v1
|
||||
|
||||
# ℹ️ Command-line programs to run using the OS shell.
|
||||
# 📚 https://git.io/JvXDl
|
||||
|
||||
# ✏️ If the Autobuild fails above, remove it and uncomment the following three lines
|
||||
# and modify them (or add more) to build your code if your project
|
||||
# uses a compiled language
|
||||
|
||||
#- run: |
|
||||
# make bootstrap
|
||||
# make release
|
||||
|
||||
- name: Perform CodeQL Analysis
|
||||
uses: github/codeql-action/analyze@v1
|
2
.github/workflows/main.yml
vendored
2
.github/workflows/main.yml
vendored
|
@ -7,7 +7,7 @@ jobs:
|
|||
runs-on: ubuntu-latest
|
||||
|
||||
steps:
|
||||
- uses: actions/checkout@v2.3.4
|
||||
- uses: actions/checkout@v3
|
||||
|
||||
- name: Install dependencies
|
||||
run: go get
|
||||
|
|
10
go.mod
10
go.mod
|
@ -1,5 +1,11 @@
|
|||
module github.com/Sighery/gonjalla
|
||||
|
||||
go 1.14
|
||||
go 1.17
|
||||
|
||||
require github.com/stretchr/testify v1.7.0
|
||||
require github.com/stretchr/testify v1.8.1
|
||||
|
||||
require (
|
||||
github.com/davecgh/go-spew v1.1.1 // indirect
|
||||
github.com/pmezard/go-difflib v1.0.0 // indirect
|
||||
gopkg.in/yaml.v3 v3.0.1 // indirect
|
||||
)
|
||||
|
|
15
go.sum
15
go.sum
|
@ -1,12 +1,17 @@
|
|||
github.com/davecgh/go-spew v1.1.0 h1:ZDRjVQ15GmhC3fiQ8ni8+OwkZQO4DARzQgrnXU1Liz8=
|
||||
github.com/davecgh/go-spew v1.1.0/go.mod h1:J7Y8YcW2NihsgmVo/mv3lAwl/skON4iLHjSsI+c5H38=
|
||||
github.com/davecgh/go-spew v1.1.1 h1:vj9j/u1bqnvCEfJOwUhtlOARqs3+rkHYY13jYWTU97c=
|
||||
github.com/davecgh/go-spew v1.1.1/go.mod h1:J7Y8YcW2NihsgmVo/mv3lAwl/skON4iLHjSsI+c5H38=
|
||||
github.com/pmezard/go-difflib v1.0.0 h1:4DBwDE0NGyQoBHbLQYPwSUPoCMWR5BEzIk/f1lZbAQM=
|
||||
github.com/pmezard/go-difflib v1.0.0/go.mod h1:iKH77koFhYxTK1pcRnkKkqfTogsbg7gZNVY4sRDYZ/4=
|
||||
github.com/stretchr/objx v0.1.0 h1:4G4v2dO3VZwixGIRoQ5Lfboy6nUhCyYzaqnIAPPhYs4=
|
||||
github.com/stretchr/objx v0.1.0/go.mod h1:HFkY916IF+rwdDfMAkV7OtwuqBVzrE8GR6GFx+wExME=
|
||||
github.com/stretchr/testify v1.7.0 h1:nwc3DEeHmmLAfoZucVR881uASk0Mfjw8xYJ99tb5CcY=
|
||||
github.com/stretchr/testify v1.7.0/go.mod h1:6Fq8oRcR53rry900zMqJjRRixrwX3KX962/h/Wwjteg=
|
||||
github.com/stretchr/objx v0.4.0/go.mod h1:YvHI0jy2hoMjB+UWwv71VJQ9isScKT/TqJzVSSt89Yw=
|
||||
github.com/stretchr/objx v0.5.0/go.mod h1:Yh+to48EsGEfYuaHDzXPcE3xhTkx73EhmCGUpEOglKo=
|
||||
github.com/stretchr/testify v1.7.1/go.mod h1:6Fq8oRcR53rry900zMqJjRRixrwX3KX962/h/Wwjteg=
|
||||
github.com/stretchr/testify v1.8.0/go.mod h1:yNjHg4UonilssWZ8iaSj1OCr/vHnekPRkoO+kdMU+MU=
|
||||
github.com/stretchr/testify v1.8.1 h1:w7B6lhMri9wdJUVmEZPGGhZzrYTPvgJArz7wNPgYKsk=
|
||||
github.com/stretchr/testify v1.8.1/go.mod h1:w2LPCIKwWwSfY2zedu0+kehJoqGctiVI29o6fzry7u4=
|
||||
gopkg.in/check.v1 v0.0.0-20161208181325-20d25e280405 h1:yhCVgyC4o1eVCa2tZl7eS0r+SDo693bJlVdllGtEeKM=
|
||||
gopkg.in/check.v1 v0.0.0-20161208181325-20d25e280405/go.mod h1:Co6ibVJAznAaIkqp8huTwlJQCZ016jof/cbN4VW5Yz0=
|
||||
gopkg.in/yaml.v3 v3.0.0-20200313102051-9f266ea9e77c h1:dUUwHk2QECo/6vqA44rthZ8ie2QXMNeKRTHCNY2nXvo=
|
||||
gopkg.in/yaml.v3 v3.0.0-20200313102051-9f266ea9e77c/go.mod h1:K4uyk7z7BCEPqu6E+C64Yfv1cQ7kz7rIZviUmN+EgEM=
|
||||
gopkg.in/yaml.v3 v3.0.1 h1:fxVm/GzAzEWqLHuvctI91KS9hhNmmWOoWu0XTYJS7CA=
|
||||
gopkg.in/yaml.v3 v3.0.1/go.mod h1:K4uyk7z7BCEPqu6E+C64Yfv1cQ7kz7rIZviUmN+EgEM=
|
||||
|
|
|
@ -10,7 +10,7 @@ var ValidPriority = []int{0, 1, 5, 10, 20, 30, 40, 50, 60}
|
|||
|
||||
// Record struct contains data returned by `list-records`
|
||||
type Record struct {
|
||||
ID int `json:"id"`
|
||||
ID string `json:"id"`
|
||||
Name string `json:"name"`
|
||||
Type string `json:"type"`
|
||||
Content string `json:"content"`
|
||||
|
@ -75,7 +75,7 @@ func AddRecord(token string, domain string, record Record) (Record, error) {
|
|||
|
||||
// RemoveRecord removes a given record from a given domain.
|
||||
// If there are no errors it will return `nil`.
|
||||
func RemoveRecord(token string, domain string, id int) error {
|
||||
func RemoveRecord(token string, domain string, id string) error {
|
||||
params := map[string]interface{}{
|
||||
"domain": domain,
|
||||
"id": id,
|
||||
|
|
|
@ -21,28 +21,28 @@ func TestListRecordsExpected(t *testing.T) {
|
|||
"result": {
|
||||
"records": [
|
||||
{
|
||||
"id": 1337,
|
||||
"id": "1337",
|
||||
"name": "_acme-challenge",
|
||||
"type": "TXT",
|
||||
"content": "long-string",
|
||||
"ttl": 10800
|
||||
},
|
||||
{
|
||||
"id": 1338,
|
||||
"id": "1338",
|
||||
"name": "@",
|
||||
"type": "A",
|
||||
"content": "1.2.3.4",
|
||||
"ttl": 3600
|
||||
},
|
||||
{
|
||||
"id": 1339,
|
||||
"id": "1339",
|
||||
"name": "@",
|
||||
"type": "AAAA",
|
||||
"content": "2001:0DB8:0000:0000:0000:8A2E:0370:7334",
|
||||
"ttl": 900
|
||||
},
|
||||
{
|
||||
"id": 1340,
|
||||
"id": "1340",
|
||||
"name": "@",
|
||||
"type": "MX",
|
||||
"content": "mail.protonmail.ch",
|
||||
|
@ -70,28 +70,28 @@ func TestListRecordsExpected(t *testing.T) {
|
|||
|
||||
expected := []Record{
|
||||
{
|
||||
ID: 1337,
|
||||
ID: "1337",
|
||||
Name: "_acme-challenge",
|
||||
Type: "TXT",
|
||||
Content: "long-string",
|
||||
TTL: 10800,
|
||||
},
|
||||
{
|
||||
ID: 1338,
|
||||
ID: "1338",
|
||||
Name: "@",
|
||||
Type: "A",
|
||||
Content: "1.2.3.4",
|
||||
TTL: 3600,
|
||||
},
|
||||
{
|
||||
ID: 1339,
|
||||
ID: "1339",
|
||||
Name: "@",
|
||||
Type: "AAAA",
|
||||
Content: "2001:0DB8:0000:0000:0000:8A2E:0370:7334",
|
||||
TTL: 900,
|
||||
},
|
||||
{
|
||||
ID: 1340,
|
||||
ID: "1340",
|
||||
Name: "@",
|
||||
Type: "MX",
|
||||
Content: "mail.protonmail.ch",
|
||||
|
@ -140,7 +140,7 @@ func TestAddRecordExpected(t *testing.T) {
|
|||
testData := `{
|
||||
"jsonrpc": "2.0",
|
||||
"result": {
|
||||
"id": 1337,
|
||||
"id": "1337",
|
||||
"name": "@",
|
||||
"type": "MX",
|
||||
"content": "testing.com",
|
||||
|
@ -173,7 +173,7 @@ func TestAddRecordExpected(t *testing.T) {
|
|||
}
|
||||
|
||||
expected := Record{
|
||||
ID: 1337,
|
||||
ID: "1337",
|
||||
Name: "@",
|
||||
Type: "MX",
|
||||
Content: "testing.com",
|
||||
|
@ -221,7 +221,7 @@ func TestAddRecordError(t *testing.T) {
|
|||
func TestRemoveRecordExpected(t *testing.T) {
|
||||
token := "test-token"
|
||||
domain := "testing.com"
|
||||
id := 1337
|
||||
id := "1337"
|
||||
Client = &mocks.MockClient{}
|
||||
|
||||
testData := `{
|
||||
|
@ -244,7 +244,7 @@ func TestRemoveRecordExpected(t *testing.T) {
|
|||
func TestRemoveRecordError(t *testing.T) {
|
||||
token := "test-token"
|
||||
domain := "testing.com"
|
||||
id := 1337
|
||||
id := "1337"
|
||||
Client = &mocks.MockClient{}
|
||||
|
||||
testData := `{
|
||||
|
@ -275,7 +275,7 @@ func TestEditRecordExpected(t *testing.T) {
|
|||
testData := `{
|
||||
"jsonrpc": "2.0",
|
||||
"result": {
|
||||
"id": 1337,
|
||||
"id": "1337",
|
||||
"name": "@",
|
||||
"type": "MX",
|
||||
"content": "testing.com",
|
||||
|
@ -294,7 +294,7 @@ func TestEditRecordExpected(t *testing.T) {
|
|||
|
||||
priority := 10
|
||||
editing := Record{
|
||||
ID: 1337,
|
||||
ID: "1337",
|
||||
Name: "@",
|
||||
Type: "MX",
|
||||
Content: "testing.com",
|
||||
|
@ -329,7 +329,7 @@ func TestEditRecordError(t *testing.T) {
|
|||
|
||||
priority := 10
|
||||
editing := Record{
|
||||
ID: 1337,
|
||||
ID: "1337",
|
||||
Name: "@",
|
||||
Type: "MX",
|
||||
Content: "testing.com",
|
||||
|
|
Loading…
Reference in a new issue